Files
gitea/tests/e2e/label.test.ts
T
silverwindandwxiaoguang e645afbb3f refactor: replace Fomantic modal with native dialog (#39846)
Replace Fomantic's hard-forked jQuery modal with native `<dialog>`
elements, advancing https://github.com/go-gitea/gitea/issues/29849. The
UI is visually unchanged. Dialogs open with `show()` over an `inert`
page, so tooltips, popups and toasts mounted on `<body>` stay usable
above them, unlike with `showModal()`
(https://github.com/whatwg/html/issues/9936).

- Remove the Fomantic modal and dimmer, add `showModal` and `hideModal`
- Declare modals as `<dialog class="modal-dialog">`, shown inside a
`.modal-backdrop`, instead of `ui modal` with its unused size classes
- Remove two modals that could never be opened
- Block the page while a modal is open, close the topmost one on Escape
and restore focus to its opener
- Allow stacked modals, use a confirm modal instead of `window.confirm`
for deleting content history
- Hide popups and toasts when a modal opens or closes
- Keep the release notes modal open when generating notes fails

Fixes: https://github.com/go-gitea/gitea/issues/39643
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-10-20 12:32:27 +02:00

20 lines
1.0 KiB
TypeScript

import {env} from 'node:process';
import {test, expect} from '@playwright/test';
import {login, apiCreateRepo, randomString} from './utils.ts';
test('create a label in the modal with a color from the picker popup', async ({page}) => {
const repoName = `e2e-label-${randomString(8)}`;
await Promise.all([login(page), apiCreateRepo(page.request, {name: repoName, autoInit: false})]);
await page.goto(`/${env.GITEA_TEST_E2E_USER}/${repoName}/labels`);
await page.getByRole('button', {name: 'New Label'}).click();
const modal = page.getByRole('dialog');
await modal.getByRole('button', {name: 'Save'}).click();
await modal.getByPlaceholder('Label name').fill('e2e-label');
const colorInput = modal.locator('.color-picker-combo input');
await colorInput.fill('');
await page.locator('hex-color-picker').click({position: {x: 10, y: 10}});
await expect(colorInput).toHaveValue(/^#[0-9a-f]{6}$/);
await modal.getByRole('button', {name: 'Save'}).click();
await expect(page.locator('.issue-label-list')).toContainText('e2e-label');
});