mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 00:51:12 -05:00
feat: Implement Playwright testing setup
This commit is contained in:
48
tests/helpers/page-objects/LoginPage.ts
Normal file
48
tests/helpers/page-objects/LoginPage.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Login Page Object Model
|
||||
*
|
||||
* Encapsulates interactions with the login page.
|
||||
*/
|
||||
|
||||
import { Page, expect } from '@playwright/test';
|
||||
|
||||
export class LoginPage {
|
||||
constructor(private page: Page) {}
|
||||
|
||||
async goto() {
|
||||
await this.page.goto('/auth');
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
}
|
||||
|
||||
async login(email: string, password: string) {
|
||||
await this.page.fill('input[type="email"]', email);
|
||||
await this.page.fill('input[type="password"]', password);
|
||||
await this.page.click('button[type="submit"]');
|
||||
}
|
||||
|
||||
async expectLoginSuccess() {
|
||||
// Wait for navigation away from auth page
|
||||
await this.page.waitForURL('**/', { timeout: 10000 });
|
||||
|
||||
// Verify we're on homepage or dashboard
|
||||
await expect(this.page).not.toHaveURL(/\/auth/);
|
||||
}
|
||||
|
||||
async expectLoginError(message?: string) {
|
||||
// Check for error toast or message
|
||||
if (message) {
|
||||
await expect(this.page.getByText(message)).toBeVisible();
|
||||
} else {
|
||||
// Just verify we're still on auth page
|
||||
await expect(this.page).toHaveURL(/\/auth/);
|
||||
}
|
||||
}
|
||||
|
||||
async clickSignUp() {
|
||||
await this.page.click('text=Sign up');
|
||||
}
|
||||
|
||||
async clickForgotPassword() {
|
||||
await this.page.click('text=Forgot password');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user