Files
TOJE2E/tests/01-login.spec.ts
ChenKaiLiuG e139daa410 Initialize
2026-01-29 11:48:45 +08:00

42 lines
1.3 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { LoginPage } from '../pages/LoginPage';
import { TEST_USER } from '../utils/test-data';
/**
* Test Suite: User Authentication
* Tests for login and registration functionality
*/
test.describe('User Authentication', () => {
test('should login successfully with valid credentials', async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.goto();
await loginPage.login(TEST_USER.email, TEST_USER.password);
await loginPage.verifyLoginSuccess();
// Verify user menu or logout option is visible
await expect(page.locator('text=/Leave|登出|帳號/i')).toBeVisible();
});
test('should fail login with invalid credentials', async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.goto();
await loginPage.login('invalid@example.org', 'wrongpassword');
// Should remain on login page
await loginPage.verifyLoginFailure();
});
test('should display login page correctly', async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.goto();
// Verify form elements are visible
await expect(loginPage.emailInput).toBeVisible();
await expect(loginPage.passwordInput).toBeVisible();
await expect(loginPage.loginButton).toBeVisible();
});
});