fix: need to intentionally click sort button when Cypress editAccount. Change "visible" to "exist".
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
const TEST_ACCOUNT = 'tester-user';
|
const TEST_ACCOUNT = '000000';
|
||||||
const MODAL_TITLE_ACCOUNT_EDIT = 'Account Edit';
|
const MODAL_TITLE_ACCOUNT_EDIT = 'Account Edit';
|
||||||
const MSG_ACCOUNT_EDITED = 'Saved';
|
const MSG_ACCOUNT_EDITED = 'Saved';
|
||||||
|
const NUM_OF_SCROLLS = 5;
|
||||||
|
|
||||||
|
Cypress.Commands.add('manualScrollToBottom', (repeats = 20) => {
|
||||||
|
for (let i = 0; i < repeats; i++) {
|
||||||
|
cy.scrollTo('bottom', { duration: 500 });
|
||||||
|
cy.wait(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
describe('Edit an account', ()=>{
|
describe('Edit an account', ()=>{
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -16,19 +24,27 @@ describe('Edit an account', ()=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Edit an account; modify name and see saved message.', () => {
|
it('Edit an account; modify name and see saved message.', () => {
|
||||||
cy.contains('.account-cell', TEST_ACCOUNT, { timeout: 10000 }).should('be.visible');
|
// 為了讓帳號出現,必須不斷往下滾動捲軸
|
||||||
|
for(let i = 0; i < NUM_OF_SCROLLS; i++) {
|
||||||
|
cy.get('#acct_mgmt_data_grid').scrollTo('bottom');
|
||||||
|
cy.wait(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 由於可能在畫面上是 hidden ,這邊使用 exist 而不是使用 visible
|
||||||
|
cy.contains('.account-cell', TEST_ACCOUNT, { timeout: 10000 }).should('be.exist');
|
||||||
// 找到包含 TEST_ACCOUNT 字串的 .account-cell 元素
|
// 找到包含 TEST_ACCOUNT 字串的 .account-cell 元素
|
||||||
cy.contains('.account-cell', TEST_ACCOUNT, { timeout: 10000 })
|
cy.contains('.account-cell', TEST_ACCOUNT, { timeout: 10000 })
|
||||||
.parents('tr') // 找到 .account-cell 元素的祖先 tr 元素
|
.parents('tr') // 找到 .account-cell 元素的祖先 tr 元素
|
||||||
.find('.btn-edit') // 在該 tr 元素內找到 .btn-edit 按鈕
|
.find('.btn-edit') // 在該 tr 元素內找到 .btn-edit 按鈕
|
||||||
.should('be.visible') // 驗證該按鈕可見
|
.should('be.exist') // 驗證該按鈕可見
|
||||||
.click(); // 點擊該按鈕
|
.click(); // 點擊該按鈕
|
||||||
|
|
||||||
cy.contains('h1', MODAL_TITLE_ACCOUNT_EDIT).should('be.visible');
|
cy.contains('h1', MODAL_TITLE_ACCOUNT_EDIT).should('be.exist');
|
||||||
const randomNumber = Math.floor(Math.random() * 1001);
|
const randomNumber = Math.floor(Math.random() * 1001);
|
||||||
// 將整數轉換為四位數字串,並補零
|
// 將整數轉換為四位數字串,並補零
|
||||||
const fourDigitString = randomNumber.toString().padStart(4, '0');
|
const fourDigitString = randomNumber.toString().padStart(4, '0');
|
||||||
cy.get('#input_name_field').type( TEST_ACCOUNT + fourDigitString);
|
cy.get('#input_name_field').clear().type( TEST_ACCOUNT + '-' + fourDigitString);
|
||||||
cy.get('#input_first_pwd').type('aaaaaa');
|
cy.get('#input_first_pwd').type('aaaaaa');
|
||||||
cy.get('#input_second_pwd').type('aaaaaa');
|
cy.get('#input_second_pwd').type('aaaaaa');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user