0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-22 19:43:31 +01:00

Add ambient type declarations for e2e env variables

Declare E2E_USER, E2E_PASSWORD and E2E_URL as string in ProcessEnv so
non-null assertions are no longer needed throughout the e2e tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
silverwind 2026-02-17 20:32:40 +01:00
parent 799d525f64
commit 530b86e244
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
5 changed files with 11 additions and 8 deletions

7
tests/e2e/env.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
declare namespace NodeJS {
interface ProcessEnv {
E2E_USER: string;
E2E_PASSWORD: string;
E2E_URL: string;
}
}

View File

@ -10,7 +10,5 @@ test('create a milestone', async ({page}) => {
await page.getByPlaceholder('Title').fill('Test Milestone');
await page.getByRole('button', {name: 'Create Milestone'}).click();
await expect(page.locator('.milestone-list')).toContainText('Test Milestone');
// cleanup
await deleteRepo(page, env.E2E_USER!, repoName);
await deleteRepo(page, env.E2E_USER, repoName);
});

View File

@ -8,7 +8,5 @@ test('README renders on repository page', async ({page}) => {
await createRepo(page, repoName);
await page.goto(`/${env.E2E_USER}/${repoName}`);
await expect(page.locator('#readme')).toContainText(repoName);
// cleanup
await deleteRepo(page, env.E2E_USER!, repoName);
await deleteRepo(page, env.E2E_USER, repoName);
});

View File

@ -9,5 +9,5 @@ test('create a repository', async ({page}) => {
await page.locator('input[name="repo_name"]').fill(repoName);
await page.getByRole('button', {name: 'Create Repository'}).click();
await expect(page).toHaveURL(new RegExp(`/${env.E2E_USER}/${repoName}$`));
await deleteRepo(page, env.E2E_USER!, repoName);
await deleteRepo(page, env.E2E_USER, repoName);
});

View File

@ -43,7 +43,7 @@ export async function clickDropdownItem(page: Page, trigger: Locator, itemText:
await page.getByText(itemText).click();
}
export async function login(page: Page, username = env.E2E_USER!, password = env.E2E_PASSWORD!) {
export async function login(page: Page, username = env.E2E_USER, password = env.E2E_PASSWORD) {
await page.goto('/user/login');
await page.getByLabel('Username or Email Address').fill(username);
await page.getByLabel('Password').fill(password);