mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-18 08:36:18 +09:00
- add pr-review e2e test - speed up most tests by logging in via POST to avoid the login form, login form is still exercised in a dedicated test - speed up most tests be removing post-test cleanup, unnecessary because each repo is created with a unique name - misc parallelization and api call reduction - total suite runtime is about the same as before --------- Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
68 lines
3.0 KiB
TypeScript
68 lines
3.0 KiB
TypeScript
import {env} from 'node:process';
|
|
import {test, expect} from '@playwright/test';
|
|
import {login, logout, randomString} from './utils.ts';
|
|
|
|
test.beforeEach(async ({page}) => {
|
|
await page.goto('/user/sign_up');
|
|
});
|
|
|
|
test('register page has form', async ({page}) => {
|
|
await expect(page.getByLabel('Username')).toBeVisible();
|
|
await expect(page.getByLabel('Email Address')).toBeVisible();
|
|
await expect(page.getByLabel('Password', {exact: true})).toBeVisible();
|
|
await expect(page.getByLabel('Confirm Password')).toBeVisible();
|
|
await expect(page.getByRole('button', {name: 'Register Account'})).toBeVisible();
|
|
});
|
|
|
|
test('register with empty fields shows error', async ({page}) => {
|
|
// HTML5 required attribute prevents submission, so verify the fields are required
|
|
await expect(page.locator('input[name="user_name"][required]')).toBeVisible();
|
|
await expect(page.locator('input[name="email"][required]')).toBeVisible();
|
|
await expect(page.locator('input[name="password"][required]')).toBeVisible();
|
|
await expect(page.locator('input[name="retype"][required]')).toBeVisible();
|
|
});
|
|
|
|
test('register with mismatched passwords shows error', async ({page}) => {
|
|
await page.getByLabel('Username').fill('e2e-register-mismatch');
|
|
await page.getByLabel('Email Address').fill(`e2e-register-mismatch@${env.GITEA_TEST_E2E_DOMAIN}`);
|
|
await page.getByLabel('Password', {exact: true}).fill('password123!');
|
|
await page.getByLabel('Confirm Password').fill('different123!');
|
|
await page.getByRole('button', {name: 'Register Account'}).click();
|
|
await expect(page.locator('.ui.negative.message')).toBeVisible();
|
|
});
|
|
|
|
test('register then login', async ({page}) => {
|
|
const username = `e2e-register-${randomString(8)}`;
|
|
const email = `${username}@${env.GITEA_TEST_E2E_DOMAIN}`;
|
|
const password = 'password123!';
|
|
|
|
await page.getByLabel('Username').fill(username);
|
|
await page.getByLabel('Email Address').fill(email);
|
|
await page.getByLabel('Password', {exact: true}).fill(password);
|
|
await page.getByLabel('Confirm Password').fill(password);
|
|
await page.getByRole('button', {name: 'Register Account'}).click();
|
|
|
|
// After successful registration, should be redirected away from sign_up
|
|
await expect(page).not.toHaveURL(/sign_up/);
|
|
|
|
// Logout then login with the newly created account
|
|
await logout(page);
|
|
await login(page, username, password);
|
|
});
|
|
|
|
test('register with existing username shows error', async ({page}) => {
|
|
await page.getByLabel('Username').fill(env.GITEA_TEST_E2E_USER);
|
|
await page.getByLabel('Email Address').fill(`e2e-duplicate@${env.GITEA_TEST_E2E_DOMAIN}`);
|
|
await page.getByLabel('Password', {exact: true}).fill('password123!');
|
|
await page.getByLabel('Confirm Password').fill('password123!');
|
|
await page.getByRole('button', {name: 'Register Account'}).click();
|
|
await expect(page.locator('.ui.negative.message')).toBeVisible();
|
|
});
|
|
|
|
test('sign in link exists', async ({page}) => {
|
|
const signInLink = page.getByText('Sign in now!');
|
|
await expect(signInLink).toBeVisible();
|
|
await signInLink.click();
|
|
await expect(page).toHaveURL(/\/user\/login$/);
|
|
});
|