Update e2e tests for authentication

The commit modifies end-to-end testing for the authentication process. It replaces the explicit waitForURL method with the waitForTimeout method and makes the navigation checks less strict. Aside from this, it configures the page navigation methods to wait until there is no network activity
This commit is contained in:
giancarlo
2024-04-11 18:50:55 +08:00
parent 4dfabd8b89
commit 9d8d33121a
2 changed files with 8 additions and 6 deletions

View File

@@ -11,19 +11,21 @@ export class AuthPageObject {
} }
goToSignIn() { goToSignIn() {
return this.page.goto('/auth/sign-in'); return this.page.goto('/auth/sign-in', {
waitUntil: 'networkidle',
});
} }
goToSignUp() { goToSignUp() {
return this.page.goto('/auth/sign-up'); return this.page.goto('/auth/sign-up', {
waitUntil: 'networkidle',
});
} }
async signIn(params: { async signIn(params: {
email: string, email: string,
password: string password: string
}) { }) {
await this.page.locator('input[name="email"]').clear();
await this.page.fill('input[name="email"]', params.email); await this.page.fill('input[name="email"]', params.email);
await this.page.fill('input[name="password"]', params.password); await this.page.fill('input[name="password"]', params.password);
await this.page.click('button[type="submit"]'); await this.page.click('button[type="submit"]');

View File

@@ -40,9 +40,9 @@ test.describe('Auth flow', () => {
password: 'password', password: 'password',
}); });
await page.waitForURL('http://localhost:3000/home'); await page.waitForTimeout(500);
expect(page.url()).toContain('http://localhost:3000/home'); expect(page.url()).toContain('/home');
}); });
}); });