jojo/tests/e2e/admin-ui.test.e2e.ts
Gusted 555d88070d feat: migrate show-modal to native dialogs (#10287)
Test coverage:

|Modal|Test|
|-|-|
|admin: adopt unadopted|missing, not needed|
|admin: delete unadopted|missing, not needed|
|admin: delete user|e2e added: `Admin: delete a user`|
|delete package|missing|
|new project|?|
|edit project col|?|
|default project col|?|
|delete project col|?|
|commit cherry-pick|?|
|commit delete note|?|
|fork redirect|?|
|lock/unlock issue|?|
|dismiss PR review|?|
|migration delete|?|
|migration cancel|?|
|lfs delete|?|
|convert mirror|?|
|convert fork|?|
|transfer repo|?|
|delete repo|?|
|archive repo|integration present, selectors adjusted|
|delete wiki|?|
|rename wiki branch|?|
|push mirror edit|?|
|mde: new table|e2e present, selectors adjusted|
|mde: new link|e2e present, selectors adjusted|
|actions: add secret|?|
|actions: edit variable|?|

Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10287
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
2026-05-03 06:42:14 +02:00

84 lines
3.3 KiB
TypeScript

// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
// @watch start
// web_src/js/features/admin/**
// templates/admin/**
// @watch end
import {expect} from '@playwright/test';
import {test} from './utils_e2e.ts';
import {screenshot} from './shared/screenshots.ts';
test.use({user: 'user1'});
test('Admin notices modal', async ({page}) => {
const response = await page.goto('/admin/notices');
expect(response?.status()).toBe(200);
await page.getByText('description1').click();
await expect(page.locator('#detail-modal .content')).toHaveText('description1');
await screenshot(page, page.locator('#detail-modal'));
await page.getByText('Cancel').click();
await expect(page.locator('#change-email-modal')).toBeHidden();
await page.getByText('description2').click();
await expect(page.locator('#detail-modal .content')).toHaveText('description2');
await screenshot(page, page.locator('#detail-modal'));
await page.getByText('Cancel').click();
await expect(page.locator('#change-email-modal')).toBeHidden();
await page.getByText('description3').click();
await expect(page.locator('#detail-modal .content')).toHaveText('description3');
await screenshot(page, page.locator('#detail-modal'));
await page.getByText('Cancel').click();
await expect(page.locator('#change-email-modal')).toBeHidden();
});
test('Admin email list', async ({page}) => {
const response = await page.goto('/admin/emails');
expect(response?.status()).toBe(200);
await page.locator('[data-uid="21"]').click();
await expect(page.locator('#change-email-modal .content')).toHaveText('Are you sure you want to update this email address?');
await screenshot(page, page.locator('#change-email-modal .content'));
await page.locator('#email-action-form').getByText('No').click();
await expect(page.locator('#change-email-modal')).toBeHidden();
const activated = await page.locator('[data-uid="9"] .svg').evaluate((node) => node.classList.contains('octicon-check'));
await page.locator('[data-uid="9"]').click();
await page.getByRole('button', {name: 'Yes'}).click();
// Retry-proof
if (activated) {
await expect(page.locator('[data-uid="9"] .svg')).toHaveClass(/octicon-x/);
} else {
await expect(page.locator('[data-uid="9"] svg')).toHaveClass(/octicon-check/);
}
});
test('Admin: delete a user', async ({page}) => {
const response = await page.goto('/admin/users/1/edit');
expect(response?.status()).toBe(200);
const modal = page.locator('#delete-user-modal');
const okButton = page.locator('#delete-user-modal .primary.button');
// Check that modal appears after clicking
await expect(modal).toBeHidden();
await expect(okButton).toBeHidden();
await page.locator('[data-modal="#delete-user-modal"]').click();
await expect(modal).toBeVisible();
await expect(okButton).toBeVisible();
// Agree with deletion
await okButton.click();
// Should have been redirected to /admin/users/1
await expect(page).toHaveURL(/\/admin\/users\/1$/);
// This test doesn't actually delete a user as it attempts to delete the doer and
// receives an error. This is enough to test that the request reaches the correct
// endpoint without causing e2e retry headache
await expect(page.locator('#flash-message')).toBeVisible();
});