mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-27 04:07:08 +00:00
- Ensure that the dimmer always covers the whole page and that the modal is centered. - Ensure that `body` hides overflow so you cannot scroll on the page after the modal is opened. - The adjusted CSS 'behavior' originates from the original dimmer module. - Regression of https://codeberg.org/forgejo/forgejo/pulls/7416. - E2E test added. Screenshots Before: https://codeberg.org/attachments/fb8c84b3-94ba-4597-b468-4bf344f356ed After: https://codeberg.org/attachments/a6583eb9-1ec7-4e40-960a-4986f6e17535 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7471 Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
72 lines
2.5 KiB
TypeScript
72 lines
2.5 KiB
TypeScript
// @watch start
|
|
// templates/shared/user/**
|
|
// web_src/css/modules/dimmer.ts
|
|
// web_src/css/modules/dimmer.css
|
|
// @watch end
|
|
|
|
import {expect} from '@playwright/test';
|
|
import {save_visual, test} from './utils_e2e.ts';
|
|
|
|
test.use({user: 'user2'});
|
|
|
|
test('Dimmed modal', async ({page}) => {
|
|
await page.goto('/user1');
|
|
|
|
await expect(page.locator('.block')).toContainText('Block');
|
|
|
|
// Ensure the modal is hidden
|
|
await expect(page.locator('#block-user')).toBeHidden();
|
|
|
|
await page.locator('.block').click();
|
|
|
|
// Modal and dimmer should be visible.
|
|
await expect(page.locator('#block-user')).toBeVisible();
|
|
await expect(page.locator('.ui.dimmer')).toBeVisible();
|
|
await save_visual(page);
|
|
|
|
// After canceling, modal and dimmer should be hidden.
|
|
await page.locator('#block-user .cancel').click();
|
|
await expect(page.locator('.ui.dimmer')).toBeHidden();
|
|
await expect(page.locator('#block-user')).toBeHidden();
|
|
await save_visual(page);
|
|
|
|
// Open the block modal and make the dimmer visible again.
|
|
await page.locator('.block').click();
|
|
await expect(page.locator('#block-user')).toBeVisible();
|
|
await expect(page.locator('.ui.dimmer')).toBeVisible();
|
|
await expect(page.locator('.ui.dimmer')).toHaveCount(1);
|
|
await save_visual(page);
|
|
});
|
|
|
|
test('Dimmed overflow', async ({page}, workerInfo) => {
|
|
test.skip(['Mobile Safari'].includes(workerInfo.project.name), 'Mouse wheel is not supported in mobile WebKit');
|
|
await page.goto('/user2/repo1/_new/master/');
|
|
|
|
// Type in a file name.
|
|
await page.locator('#file-name').click();
|
|
await page.keyboard.type('todo.txt');
|
|
|
|
// Scroll to the bottom.
|
|
const scrollY = await page.evaluate(() => document.body.scrollHeight);
|
|
await page.mouse.wheel(0, scrollY);
|
|
|
|
// Click on 'Commit changes'
|
|
await page.locator('#commit-button').click();
|
|
|
|
// Expect a 'are you sure, this file is empty' modal.
|
|
await expect(page.locator('.ui.dimmer')).toBeVisible();
|
|
await expect(page.locator('.ui.dimmer .header')).toContainText('Commit an empty file');
|
|
await save_visual(page);
|
|
|
|
// Trickery to check that the dimmer covers the whole page.
|
|
const viewport = page.viewportSize();
|
|
const box = await page.locator('.ui.dimmer').boundingBox();
|
|
expect(box.x).toBe(0);
|
|
expect(box.y).toBe(0);
|
|
expect(box.width).toBe(viewport.width);
|
|
expect(box.height).toBe(viewport.height);
|
|
|
|
// Trickery to check the page cannot be scrolled.
|
|
const {scrollHeight, clientHeight} = await page.evaluate(() => document.body);
|
|
expect(scrollHeight).toBe(clientHeight);
|
|
});
|