feat: Add tests for signup
This commit is contained in:
parent
761d73c27f
commit
fc00659d73
@ -1,12 +1,33 @@
|
|||||||
import { defineConfig } from '@playwright/test';
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
testDir: 'tests',
|
testDir: 'tests',
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: 'signup',
|
||||||
|
testMatch: /signup\.setup\.ts/,
|
||||||
|
use: { ...devices['Desktop Chrome'] },
|
||||||
|
},
|
||||||
|
|
||||||
|
// Make all other tests depend on the signup,
|
||||||
|
// since they need user accounts to run
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'tests',
|
||||||
|
use: { ...devices['Desktop Chrome'] },
|
||||||
|
dependencies: ['signup'],
|
||||||
|
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
|
||||||
|
fullyParallel: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
reporter: 'list',
|
reporter: 'list',
|
||||||
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
|
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'npm run dev',
|
command: 'npm run dev',
|
||||||
port: 5174,
|
port: 5173,
|
||||||
reuseExistingServer: true,
|
reuseExistingServer: true,
|
||||||
},
|
},
|
||||||
|
use: {
|
||||||
|
baseURL: 'http://localhost:5173',
|
||||||
|
trace: 'on-first-retry',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
6
tests/signup.setup.ts
Normal file
6
tests/signup.setup.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { test } from '@playwright/test';
|
||||||
|
import { signup } from './utils';
|
||||||
|
|
||||||
|
test('Signup', async ({ page }) => {
|
||||||
|
await signup(page);
|
||||||
|
});
|
@ -1,7 +1,6 @@
|
|||||||
import { test, expect, type Page, type Locator } from '@playwright/test';
|
import { test, expect, type Page, type Locator } from '@playwright/test';
|
||||||
import { login } from './utils';
|
import { login } from './utils';
|
||||||
|
|
||||||
test.describe.configure({ mode: 'parallel' });
|
|
||||||
test.describe('Username Update Form', () => {
|
test.describe('Username Update Form', () => {
|
||||||
let page: Page;
|
let page: Page;
|
||||||
let usernameInput: Locator;
|
let usernameInput: Locator;
|
||||||
@ -17,11 +16,12 @@ test.describe('Username Update Form', () => {
|
|||||||
currentUsernameElement = page.locator('#currentuser-username');
|
currentUsernameElement = page.locator('#currentuser-username');
|
||||||
|
|
||||||
await login(page);
|
await login(page);
|
||||||
page.goto('http://localhost:5173/account');
|
page.goto('/account');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test that the username will change
|
// Test that the username will change
|
||||||
test('should successfully update the username', async () => {
|
test('should successfully update the username', async () => {
|
||||||
|
await page.waitForLoadState('domcontentloaded');
|
||||||
await usernameInput.fill(newUsername);
|
await usernameInput.fill(newUsername);
|
||||||
await submitButton.click();
|
await submitButton.click();
|
||||||
|
|
||||||
@ -36,6 +36,7 @@ test.describe('Username Update Form', () => {
|
|||||||
|
|
||||||
// Test invalidator
|
// Test invalidator
|
||||||
test('should show validation error for invalid username', async () => {
|
test('should show validation error for invalid username', async () => {
|
||||||
|
await page.waitForLoadState('domcontentloaded');
|
||||||
await usernameInput.fill('a');
|
await usernameInput.fill('a');
|
||||||
await submitButton.click();
|
await submitButton.click();
|
||||||
|
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
import type { Page } from '@playwright/test';
|
import type { Page } from '@playwright/test';
|
||||||
|
|
||||||
export async function login(page: Page): Promise<void> {
|
export async function login(page: Page): Promise<void> {
|
||||||
await page.goto('http://localhost:5174/login');
|
await page.goto('/login');
|
||||||
await page.waitForLoadState('domcontentloaded');
|
await page.waitForLoadState('domcontentloaded');
|
||||||
console.log('loaded');
|
|
||||||
await page.fill('#email', 'playwright@playwright.com');
|
await page.fill('#email', 'playwright@playwright.com');
|
||||||
await page.fill('#password', 'Password1234!');
|
await page.fill('#password', 'Password1234!');
|
||||||
await page.click('button[type="submit"]');
|
await page.click('button[type="submit"]');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function signup(page: Page): Promise<void> {
|
||||||
|
await page.goto('/signup');
|
||||||
|
await page.waitForLoadState('domcontentloaded');
|
||||||
|
await page.fill('#username', 'playwrightuser');
|
||||||
|
await page.fill('#email', 'playwright@playwright.com');
|
||||||
|
await page.fill('#password', 'Password1234!');
|
||||||
|
await page.fill('#verify', 'Password1234!');
|
||||||
|
await page.click('button[type="submit"]');
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user