Refactor e2e tests for improved efficiency

The commit has made key changes to enhance the efficiency of end-to-end tests. The password generation logic and random email creation method have been modified to use bigger random numbers, ensuring
This commit is contained in:
giancarlo
2024-04-11 21:54:03 +08:00
parent 93964e174a
commit fb86e6e6b2
3 changed files with 8 additions and 16 deletions

View File

@@ -37,8 +37,7 @@ test.describe('Account Settings', () => {
});
test('user can update their password', async () => {
const password = (Math.random() * 1000).toString();
const password = (Math.random() * 100000).toString();
await account.updatePassword(password);
await page.waitForResponse((resp) => {
@@ -50,17 +49,10 @@ test.describe('Account Settings', () => {
});
test.describe('Account Deletion', () => {
let page: Page;
let account: AccountPageObject;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
account = new AccountPageObject(page);
test('user can delete their own account', async ({ page }) => {
const account = new AccountPageObject(page);
await account.setup();
});
test('user can delete their own account', async () => {
await account.deleteAccount();
await page.waitForURL('http://localhost:3000');

View File

@@ -48,8 +48,6 @@ export class AuthPageObject {
}
async visitConfirmEmailLink(email: string) {
await this.page.waitForTimeout(300);
return expect(async() => {
const res = await this.mailbox.visitMailbox(email);
@@ -58,7 +56,7 @@ export class AuthPageObject {
}
createRandomEmail() {
const value = Math.random() * 1000;
const value = Math.random() * 10000000000;
return `${value.toFixed(0)}@makerkit.dev`;
}
@@ -76,6 +74,10 @@ export class AuthPageObject {
repeatPassword: 'password',
});
await this.page.waitForResponse((resp) => {
return resp.url().includes('auth');
});
await this.visitConfirmEmailLink(email);
}
}

View File

@@ -19,8 +19,6 @@ export class Mailbox {
const json = await this.getInviteEmail(mailbox);
if (!json.body) {
console.log(json);
throw new Error('Email body was not found');
}