mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-17 14:24:07 +00:00
- Replace the e2e tests initialization with a simple bash script, removing the previous Go harness. - `make test-e2e` is the single entry point. It always starts a fully isolated ephemeral Gitea instance with its own temp directory, SQLite database, and config — no interference with the developer's running instance. - A separate `gitea-e2e` binary is built via `EXECUTABLE_E2E` using `TEST_TAGS` (auto-includes sqlite with `CGO_ENABLED=1`), keeping the developer's regular `gitea` binary untouched. - No more split into database-specific e2e tests. Test timeouts are strict, can be relaxed later if needed. - Simplified and streamlined the playwright config and test files. - Remove all output generation of playwright and all references to visual testing. - Tests run on Chrome locally, Chrome + Firefox on CI. - Simplified CI workflow — visible separate steps for frontend, backend, and test execution. - All exported env vars use `GITEA_TEST_E2E_*` prefix. - Use `GITEA_TEST_E2E_FLAGS` to pass flags to playwright, e.g. `GITEA_TEST_E2E_FLAGS="--ui" make test-e2e` for UI mode or `GITEA_TEST_E2E_FLAGS="--headed" make test-e2e` for headed mode. - Use `GITEA_TEST_E2E_DEBUG=1 make test-e2e` to show Gitea server output. --------- Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
74 lines
3.3 KiB
TypeScript
74 lines
3.3 KiB
TypeScript
import {env} from 'node:process';
|
|
import {test, expect} from '@playwright/test';
|
|
import {login, logout} 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-${Date.now()}`;
|
|
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);
|
|
|
|
// delete via API because of issues related to form-fetch-action
|
|
const response = await page.request.delete(`/api/v1/admin/users/${username}?purge=true`, {
|
|
headers: {Authorization: `Basic ${btoa(`${env.GITEA_TEST_E2E_USER}:${env.GITEA_TEST_E2E_PASSWORD}`)}`},
|
|
});
|
|
expect(response.ok()).toBeTruthy();
|
|
});
|
|
|
|
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$/);
|
|
});
|