mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-07-05 01:00:03 +02:00

Related: https://codeberg.org/forgejo/forgejo/pulls/3950#issue-785253, https://codeberg.org/forgejo/forgejo/pulls/3950#issuecomment-1998551. ## Links in dropdown * move _admin only_ User details link here, give it always-visible text * add new _self only_ Edit profile link here * move RSS feed link here * add new Atom feed link here, previously unadvertised * add new SSH keys link here (`.keys`), previously unadvertised * add new GPG keys link here (`.gpg`), previously unadvertised * move Block/Unblock button here * move Report abuse link here If primary action is available (Follow/Unfollow), dropdown with more actions goes after it. If not, it is in line with followers, in place where RSS feed button used to be. ## New dropdown Related: https://codeberg.org/forgejo/design/issues/23, https://codeberg.org/forgejo/forgejo/issues/3853, https://codeberg.org/0ko/forgejo/issues/2. Implemented a new dropdown: noJS-usable, JS-enhanced for better keyboard navigation and a11y. Styling is mostly same as the existing ones have, but row density depends on `@media` pointer type. My choice of CSS properties have been influenced of these: *72a3adb16b
*51dd2293ca
Inspired-by: KiranMantha <kiranv.mantha@gmail.com> Inspired-by: Lucas Larroche <lucas@larroche.com> Co-authored-by: Beowulf <beowulf@beocode.eu> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7906 Reviewed-by: Otto <otto@codeberg.org> Reviewed-by: Beowulf <beowulf@beocode.eu> Co-authored-by: 0ko <0ko@noreply.codeberg.org> Co-committed-by: 0ko <0ko@noreply.codeberg.org>
74 lines
2.6 KiB
TypeScript
74 lines
2.6 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('#action-block')).toContainText('Block');
|
|
|
|
// Ensure the modal is hidden
|
|
await expect(page.locator('#block-user')).toBeHidden();
|
|
|
|
await page.locator('.actions .dropdown').click();
|
|
await page.locator('#action-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('.actions .dropdown').click();
|
|
await page.locator('#action-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);
|
|
});
|