sonnar 8 left. random number fixed
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { getRandomInt } from '../../../src/utils/jsUtils';
|
||||||
const MSG_PWD_NOT_MATCHED = 'Confirm Password does not match.';
|
const MSG_PWD_NOT_MATCHED = 'Confirm Password does not match.';
|
||||||
|
|
||||||
describe('Confirm that two input passwords are equal.', ()=>{
|
describe('Confirm that two input passwords are equal.', ()=>{
|
||||||
@@ -17,7 +18,7 @@ describe('Confirm that two input passwords are equal.', ()=>{
|
|||||||
cy.contains('button', 'Create New').should('be.visible');
|
cy.contains('button', 'Create New').should('be.visible');
|
||||||
cy.contains('button', 'Create New').click();
|
cy.contains('button', 'Create New').click();
|
||||||
|
|
||||||
const randomNumber = Math.floor(Math.random() * 1001);
|
const randomNumber = getRandomInt(1000);
|
||||||
|
|
||||||
// 將整數轉換為四位數字串,並補零
|
// 將整數轉換為四位數字串,並補零
|
||||||
const fourDigitString = randomNumber.toString().padStart(4, '0');
|
const fourDigitString = randomNumber.toString().padStart(4, '0');
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { getRandomInt } from '../../../src/utils/jsUtils';
|
||||||
|
|
||||||
describe('Create an Account', ()=>{
|
describe('Create an Account', ()=>{
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.visit('https://REDACTED-HOST/account-admin');
|
cy.visit('https://REDACTED-HOST/account-admin');
|
||||||
@@ -15,7 +17,7 @@ describe('Create an Account', ()=>{
|
|||||||
cy.contains('button', 'Create New').should('be.visible');
|
cy.contains('button', 'Create New').should('be.visible');
|
||||||
cy.contains('button', 'Create New').click();
|
cy.contains('button', 'Create New').click();
|
||||||
|
|
||||||
const randomNumber = Math.floor(Math.random() * 1001);
|
const randomNumber = getRandomInt(1000);
|
||||||
|
|
||||||
// 將整數轉換為四位數字串,並補零
|
// 將整數轉換為四位數字串,並補零
|
||||||
const fourDigitString = randomNumber.toString().padStart(4, '0');
|
const fourDigitString = randomNumber.toString().padStart(4, '0');
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { getRandomInt } from '../../../src/utils/jsUtils';
|
||||||
|
|
||||||
const TEST_ACCOUNT = '000000';
|
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';
|
||||||
@@ -41,7 +43,7 @@ describe('Edit an account', ()=>{
|
|||||||
.click(); // 點擊該按鈕
|
.click(); // 點擊該按鈕
|
||||||
|
|
||||||
cy.contains('h1', MODAL_TITLE_ACCOUNT_EDIT).should('be.exist');
|
cy.contains('h1', MODAL_TITLE_ACCOUNT_EDIT).should('be.exist');
|
||||||
const randomNumber = Math.floor(Math.random() * 1001);
|
const randomNumber = getRandomInt(1000);
|
||||||
// 將整數轉換為四位數字串,並補零
|
// 將整數轉換為四位數字串,並補零
|
||||||
const fourDigitString = randomNumber.toString().padStart(4, '0');
|
const fourDigitString = randomNumber.toString().padStart(4, '0');
|
||||||
cy.get('#input_name_field').clear().type( TEST_ACCOUNT + '-' + fourDigitString);
|
cy.get('#input_name_field').clear().type( TEST_ACCOUNT + '-' + fourDigitString);
|
||||||
|
|||||||
@@ -12,4 +12,10 @@ export const printObject = (obj, indent = 0) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export const getRandomInt = (max) => {
|
||||||
|
const array = new Uint32Array(1);
|
||||||
|
window.crypto.getRandomValues(array);
|
||||||
|
return Math.floor(array[0] / (0xFFFFFFFF + 1) * (max + 1));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user