mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix: allow modals to be submitted multiple times (#11843)
Fixes #11842. The `once: true` was likely added to prevent multiple concurrent submissions of the same form. This could still be worth preventing, but I suspect it would require wrapping the supplied `onApprove` callback with the corresponding logic, implemented manually, as I am not aware of any native API to prevent concurrent executions of callbacks. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11843 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu> Co-committed-by: Antonin Delpeuch <antonin@delpeuch.eu>
This commit is contained in:
parent
9e3c3e5d53
commit
3763a88c67
2 changed files with 21 additions and 1 deletions
|
|
@ -41,3 +41,23 @@ test('Edit label', async ({page}) => {
|
|||
|
||||
await expect(page.locator('.label-title').filter({hasText: labelName})).toBeVisible();
|
||||
});
|
||||
|
||||
test('New label after a failed validation', async ({page}) => {
|
||||
// for issue https://codeberg.org/forgejo/forgejo/issues/11842
|
||||
const response = await page.goto('/user2/repo1/labels');
|
||||
expect(response?.status()).toBe(200);
|
||||
|
||||
await page.getByRole('button', {name: 'New label'}).click();
|
||||
await expect(page.locator('#new-label-modal')).toBeVisible();
|
||||
|
||||
// attempt to submit the form without having filled it first
|
||||
await page.getByRole('button', {name: 'Create label'}).click();
|
||||
await screenshot(page, page.locator('#new-label-modal'));
|
||||
|
||||
// then fill the form and submit it again
|
||||
const labelName = dynamic_id();
|
||||
await page.getByRole('textbox', {name: 'Label name'}).fill(labelName);
|
||||
await page.getByRole('button', {name: 'Create label'}).click();
|
||||
|
||||
await expect(page.locator('.label-title').filter({hasText: labelName})).toBeVisible();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export function showModal(modalID: string, onApprove: () => void) {
|
|||
modal.querySelector('.cancel')?.addEventListener('click', () => {
|
||||
modal.close();
|
||||
}, {once: true, passive: true});
|
||||
modal.querySelector('.ok')?.addEventListener('click', onApprove, {once: true, passive: true});
|
||||
modal.querySelector('.ok')?.addEventListener('click', onApprove, {passive: true});
|
||||
|
||||
// The modal is ready to be shown.
|
||||
modal.showModal();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue