72 lines
3.5 KiB
TypeScript
72 lines
3.5 KiB
TypeScript
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Authentication', () => {
|
|
const uniqueId = Date.now();
|
|
const candidateUser = {
|
|
name: `Test Candidate ${uniqueId}`,
|
|
username: `candidate_${uniqueId}`,
|
|
email: `candidate_${uniqueId}@example.com`,
|
|
password: 'password123',
|
|
phone: '11999999999',
|
|
birthDate: '1990-01-01',
|
|
};
|
|
|
|
test('should register a new candidate', async ({ page }) => {
|
|
await page.goto('/register/candidate');
|
|
|
|
// Step 1: Personal Info
|
|
await page.fill('input[name="fullName"]', candidateUser.name);
|
|
await page.fill('input[name="username"]', candidateUser.username);
|
|
await page.fill('input[name="email"]', candidateUser.email);
|
|
await page.fill('input[name="password"]', candidateUser.password);
|
|
await page.fill('input[name="confirmPassword"]', candidateUser.password);
|
|
await page.fill('input[name="birthDate"]', candidateUser.birthDate);
|
|
await page.click('button:has-text("Next Step")'); // register.candidate.actions.next
|
|
|
|
// Step 2: Address/Contact
|
|
await page.fill('input[name="phone"]', candidateUser.phone);
|
|
await page.fill('input[name="address"]', "Test Street 123");
|
|
await page.fill('input[name="city"]', "Test City");
|
|
// State is a select, might need click logic
|
|
await page.click('button[role="combobox"]'); // Select trigger
|
|
await page.click('div[role="option"] >> text="São Paulo"'); // Select option
|
|
await page.fill('input[name="zipCode"]', "12345-678");
|
|
await page.click('button:has-text("Next Step")'); // register.candidate.actions.next
|
|
|
|
// Step 3: Professional (skip details, checking optional or required)
|
|
// Assume basics are required or select mock
|
|
// Just click submit to see if validation passes/fails
|
|
// Need to fill required if any.
|
|
// Education: Select
|
|
await page.click('button[role="combobox"] >> nth=0'); // First select in this step (Education)
|
|
await page.click('div[role="option"] >> text="College"'); // register.candidate.education.college
|
|
|
|
// Experience: Select
|
|
await page.click('button[role="combobox"] >> nth=1'); // Second select (Experience)
|
|
// Note: Experience select might be difficult to target by nth if previous selects are still present but hidden?
|
|
// Actually, step 1 and 2 are hidden (removed from DOM or display:none?).
|
|
// Framer motion uses AnimatePresence, usually removes from DOM after exit.
|
|
// So nth=0 and nth=1 might be correct for valid visible selects.
|
|
await page.click('div[role="option"] >> text="1 to 2 years"'); // register.candidate.experience.oneToTwo
|
|
|
|
// Terms
|
|
await page.click('button[role="checkbox"][id="acceptTerms"]');
|
|
|
|
await page.click('button:has-text("Create Account")'); // register.candidate.actions.submit
|
|
|
|
// Expect redirect to login
|
|
await expect(page).toHaveURL(/\/login/);
|
|
await expect(page.getByText('Account created successfully')).toBeVisible();
|
|
});
|
|
|
|
test('should login with registered candidate', async ({ page }) => {
|
|
await page.goto('/login');
|
|
await page.fill('input[name="email"]', candidateUser.email);
|
|
await page.fill('input[name="password"]', candidateUser.password);
|
|
await page.click('button:has-text("Sign in")'); // auth.login.submit
|
|
|
|
// Expect dashboard
|
|
await expect(page).toHaveURL(/\/dashboard/); // dashboard/candidate or just dashboard depending on redirect
|
|
});
|
|
});
|