mirror of
https://github.com/penpot/penpot.git
synced 2026-11-20 17:11:15 +00:00
♻️ Cut the shortcuts and inspect tab e2e specs (#13010)
* ♻️ Cut shortcuts and inspect e2e specs and harden their assertions Shortcuts spec: drop the enable-custom-shortcuts mock, since no frontend, common or backend code reads the flag, and cut 18 tests to 6. A header comment records where the removed rules went: named steps here and the 77 unit tests of settings_shortcuts_test.cljs. The six keep only what a browser proves: the file input and diff modal, the alert for a file with nothing to apply, the download of a bound and an empty entry, the RPC write with reload, the conflict that disables the previous binding, and both reset flows. Fix the shortcuts review findings: the invalid-file step dismisses the timeout-free toast before the next import and covers both removed payloads in one import. The conflict test records a default-bound and a custom-bound key on one page load, then resets and imports a key a default binding holds, so the diff modal's apply path runs with a default in the way, and checks the alert, the disabled row and the exported payload; the export test resets and imports the file it just downloaded. Inspect tab spec: cut 27 tests to 8 with 25 named steps, from 622.9 to 181.5 worker-seconds and 162.5 to 46.7 seconds of wall time. Layout, shadow and blur, fill, stroke, typography and clipboard cases run as steps in one page load per group; the two cases that mutate the shape with Design-tab controls keep their own. Replace 500 ms sleeps with waits on rendered state, make layer expansion idempotent, match layer names exactly, poll row counts and await every matcher. Drop the false comment about name capitalisation, the three unused shapeToLayerName entries and the skip the "Layer info" assertion now covers. Move layerRow and selectLayer into WorkspacePage with the helpers the next PR in the stack needs: layerRow matches an anchored name on the layer-row test id, because a selected row's hide and lock button titles join its accessible name, and selectLayer waits for aria-checked instead of the shape name. waitForSelectedShapeName takes options. The inspect spec drops its escapeRegExp, getLayerRow and inline selection. Rename the fixture token to radius-md so the radius assertion is not satisfied by the row label. Closes #13009 AI-assisted-by: deepseek-v4.1-flash * 🐛 Pass the translation flag in the sync text undo test The merge of staging into develop brought back the required :translation key of an undo entry, and the test added in ef0333eafe calls append-undo without it. check-undo-entry throws, the exception escapes the promise and the whole frontend run exits before printing the summary. The entry stands for the commit of a component sync, which is not a translation, so it carries :translation false, the value the production watcher derives from the commit. AI-assisted-by: deepseek-v4.1-flash
This commit is contained in:
parent
3c4ae62db5
commit
1439bc7605
@ -72,6 +72,8 @@ Integration tests fake backend behavior by intercepting network/websocket traffi
|
||||
|
||||
Locator priority should follow user-facing semantics: `getByRole`, `getByLabel`, `getByPlaceholder`, `getByText`, then semantic alternatives such as alt/title, with `getByTestId` as the last resort. Name tests from the user's perspective and prefer positive, single-purpose assertions.
|
||||
|
||||
Layer rows are the exception: a selected row's hide and lock button titles join its accessible name, so role-plus-name matching breaks on selected rows. Use `WorkspacePage.layerRow`, which anchors on the `layer-row` test id's text, and `selectLayer`, which waits for `aria-checked`.
|
||||
|
||||
## CI (E2E)
|
||||
|
||||
`.github/workflows/tests-e2e.yml` runs the integration specs, the composable component suite, and the mocked Plugin API suite from one workflow that builds the frontend bundle once per SHA. Before adding a job that needs the bundle, read `mem:frontend/e2e-ci-workflow` (build-once contract, cache key, stable check names).
|
||||
|
||||
@ -3224,7 +3224,7 @@
|
||||
"~:r1": 0,
|
||||
"~:id": "~u6ce76eb4-b183-804e-8007-04b6eb5e1080",
|
||||
"~:parent-id": "~u6ce76eb4-b183-804e-8007-04b6f725fae8",
|
||||
"~:applied-tokens": { "~:r2": "radius", "~:r3": "radius" },
|
||||
"~:applied-tokens": { "~:r2": "radius-md", "~:r3": "radius-md" },
|
||||
"~:frame-id": "~u6ce76eb4-b183-804e-8007-04b6f725fae8",
|
||||
"~:strokes": [],
|
||||
"~:x": 1758,
|
||||
@ -5932,11 +5932,11 @@
|
||||
}
|
||||
],
|
||||
[
|
||||
"radius",
|
||||
"radius-md",
|
||||
{
|
||||
"~#penpot/token": {
|
||||
"~:id": "~u6ce76eb4-b183-804e-8007-04b769351486",
|
||||
"~:name": "radius",
|
||||
"~:name": "radius-md",
|
||||
"~:type": "~:border-radius",
|
||||
"~:value": "20px",
|
||||
"~:description": "",
|
||||
|
||||
@ -4,6 +4,8 @@ import { MockWebSocketHelper } from "../../helpers/MockWebSocketHelper";
|
||||
import { BaseWebSocketPage } from "./BaseWebSocketPage";
|
||||
import { Transit } from "../../helpers/Transit";
|
||||
|
||||
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
|
||||
export class WorkspacePage extends BaseWebSocketPage {
|
||||
static TextEditor = class TextEditor {
|
||||
constructor(workspacePage) {
|
||||
@ -564,6 +566,25 @@ export class WorkspacePage extends BaseWebSocketPage {
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
// Layer rows print the name verbatim, so an anchored text match tells
|
||||
// "shape - text" from "shape - text - token - composite". It assumes the
|
||||
// row shows only the name: the :show-ids and :show-touched debug flags
|
||||
// append text to the same node. Matching by accessible name is not an
|
||||
// option: a selected row shows its hide and lock buttons, whose titles
|
||||
// join the name.
|
||||
layerRow(name) {
|
||||
return this.layers
|
||||
.getByTestId("layer-row")
|
||||
.filter({ hasText: new RegExp(`^${escapeRegExp(name)}$`, "i") })
|
||||
.first();
|
||||
}
|
||||
|
||||
async selectLayer(name, clickOptions = {}) {
|
||||
const row = this.layerRow(name);
|
||||
await row.click(clickOptions);
|
||||
await expect(row).toHaveAttribute("aria-checked", "true");
|
||||
}
|
||||
|
||||
async getSelectedShapeName() {
|
||||
const selectedLayer = this.layers
|
||||
.getByRole("checkbox", { checked: true })
|
||||
@ -572,11 +593,11 @@ export class WorkspacePage extends BaseWebSocketPage {
|
||||
return (await selectedLayer.innerText()).trim();
|
||||
}
|
||||
|
||||
async waitForSelectedShapeName(expectedName) {
|
||||
async waitForSelectedShapeName(expectedName, options = {}) {
|
||||
const selectedLayer = this.layers
|
||||
.getByRole("checkbox", { checked: true })
|
||||
.first();
|
||||
await expect(selectedLayer).toHaveText(expectedName);
|
||||
await expect(selectedLayer).toHaveText(expectedName, options);
|
||||
}
|
||||
|
||||
async expectHiddenToolbarOptions() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,232 +1,167 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import ShortcutsPage from "../pages/ShortcutsPage";
|
||||
|
||||
const customShortcutsFlag = "enable-custom-shortcuts";
|
||||
// The import and reset rules are unit-tested in
|
||||
// frontend/test/frontend_tests/ui/settings_shortcuts_test.cljs (77 tests):
|
||||
// validation, sanitising, the command grammar, reserved combinations, the
|
||||
// profile merge, the diff modal and the restore modal. What remains here is
|
||||
// the wiring only a browser proves: the file input, the diff modal, the RPC
|
||||
// write, the download, the alert, the reload and the reset flows.
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await ShortcutsPage.init(page);
|
||||
await ShortcutsPage.mockConfigFlags(page, [customShortcutsFlag]);
|
||||
});
|
||||
|
||||
test.describe("Shortcuts Settings Page", () => {
|
||||
test("Shortcuts page loads correctly", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
test("Import valid custom shortcuts", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await expect(shortcutsPage.shortcutsSection).toBeVisible();
|
||||
await expect(shortcutsPage.searchInput).toBeVisible();
|
||||
await shortcutsPage.importShortcuts({
|
||||
workspace: { "align-bottom": "ctrl+y" },
|
||||
});
|
||||
|
||||
test("Tabs are visible and clickable", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
await shortcutsPage.confirmImportApply();
|
||||
|
||||
await expect(shortcutsPage.allTab).toBeVisible();
|
||||
await expect(shortcutsPage.personalizedTab).toBeVisible();
|
||||
await expect(shortcutsPage.disabledTab).toBeVisible();
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
await shortcutsPage.clickTab("Custom");
|
||||
await expect(shortcutsPage.personalizedTab).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
const personalizedPlacehonder = page.getByText(/No custom shortcuts yet/i);
|
||||
await expect(personalizedPlacehonder).toBeVisible();
|
||||
|
||||
await shortcutsPage.clickTab("Disabled");
|
||||
await expect(shortcutsPage.disabledTab).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
const disabledPlaceholder = page.getByText(/No disabled shortcuts/i);
|
||||
await expect(disabledPlaceholder).toBeVisible();
|
||||
|
||||
await shortcutsPage.clickTab("All");
|
||||
await expect(shortcutsPage.allTab).toHaveAttribute("aria-selected", "true");
|
||||
});
|
||||
await shortcutsPage.clickTab("Custom");
|
||||
await shortcutsPage.searchForShortcut("Align bottom");
|
||||
await shortcutsPage.expectShortcutVisible("Align bottom");
|
||||
});
|
||||
|
||||
test.describe("Shortcut Customization", () => {
|
||||
test("User can edit a shortcut", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
test("A file with nothing to apply shows the alert", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
// Expand subsection
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
|
||||
// Start edition of the shortcut
|
||||
await shortcutsPage.clickEditShortcut("Align bottom");
|
||||
|
||||
// Press a new key combination
|
||||
await shortcutsPage.pressKey("Control+y");
|
||||
|
||||
// Save the shortcut
|
||||
await shortcutsPage.saveShortcut();
|
||||
|
||||
// Verify the shortcut is now customized
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Shortcut Import", () => {
|
||||
test("Import valid custom shortcuts", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await shortcutsPage.importShortcuts({
|
||||
workspace: { "align-bottom": "ctrl+y" },
|
||||
});
|
||||
|
||||
await shortcutsPage.confirmImportApply();
|
||||
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
await shortcutsPage.clickTab("Custom");
|
||||
await shortcutsPage.searchForShortcut("Align bottom");
|
||||
await shortcutsPage.expectShortcutVisible("Align bottom");
|
||||
});
|
||||
|
||||
test("Import invalid JSON syntax", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
const alert = page
|
||||
.getByRole("alert")
|
||||
.filter({ hasText: /not a valid shortcuts export/i });
|
||||
|
||||
await test.step("Broken JSON does not parse", async () => {
|
||||
await shortcutsPage.importShortcutsRaw("{invalid");
|
||||
await expect(alert).toBeVisible();
|
||||
|
||||
await expect(
|
||||
page
|
||||
.getByRole("alert")
|
||||
.filter({ hasText: /not a valid shortcuts export/i }),
|
||||
).toBeVisible();
|
||||
// The error toast carries no timeout: it stays until another
|
||||
// notification replaces it or the route changes, so it has to go before
|
||||
// the next import can prove anything.
|
||||
await alert.getByRole("button", { name: "Close" }).click();
|
||||
await expect(alert).toBeHidden();
|
||||
});
|
||||
|
||||
test("Import valid JSON with invalid schema", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await test.step("A parsed file with no applicable entry is rejected", async () => {
|
||||
await shortcutsPage.importShortcuts({
|
||||
workspace: { "unknown-shortcut": "ctrl+y" },
|
||||
});
|
||||
|
||||
await expect(
|
||||
page
|
||||
.getByRole("alert")
|
||||
.filter({ hasText: /not a valid shortcuts export/i }),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("Import JSON without workspace context accepted", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await shortcutsPage.importShortcuts({
|
||||
dashboard: { "toggle-theme": "alt+m" },
|
||||
});
|
||||
|
||||
await shortcutsPage.confirmImportApply();
|
||||
|
||||
await expect(
|
||||
page
|
||||
.getByRole("alert")
|
||||
.filter({ hasText: /not a valid shortcuts export/i }),
|
||||
).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("Import JSON with unsupported shortcut format", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await shortcutsPage.importShortcuts({
|
||||
workspace: { escape: 123 },
|
||||
});
|
||||
|
||||
await expect(
|
||||
page
|
||||
.getByRole("alert")
|
||||
.filter({ hasText: /not a valid shortcuts export/i }),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("Import conflicting shortcuts", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await shortcutsPage.importShortcuts({
|
||||
workspace: {
|
||||
"align-bottom": "alt+a",
|
||||
},
|
||||
});
|
||||
|
||||
await shortcutsPage.confirmImportApply();
|
||||
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
await shortcutsPage.expectShortcutDisabled("Align left");
|
||||
|
||||
const exported = await shortcutsPage.getExportedJson();
|
||||
expect(exported.workspace).toMatchObject({
|
||||
"align-bottom": "alt+a",
|
||||
"align-left": "",
|
||||
workspace: { "unknown-shortcut": "ctrl+y", "align-bottom": 123 },
|
||||
});
|
||||
await expect(alert).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Shortcut Export", () => {
|
||||
test("Export customized shortcuts", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
test("Export includes customized and disabled shortcuts and imports back", async ({
|
||||
page,
|
||||
}) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
|
||||
await shortcutsPage.importShortcuts({
|
||||
workspace: {
|
||||
"align-bottom": "ctrl+y",
|
||||
"align-left": "",
|
||||
},
|
||||
});
|
||||
|
||||
await shortcutsPage.confirmImportApply();
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
const exported = await shortcutsPage.getExportedJson();
|
||||
expect(exported.workspace).toMatchObject({
|
||||
"align-bottom": "ctrl+y",
|
||||
"align-left": "",
|
||||
});
|
||||
|
||||
// The file the page wrote must pass the importer's own validation.
|
||||
await shortcutsPage.restoreAllShortcuts();
|
||||
await shortcutsPage.expectShortcutNotCustomized("Align bottom");
|
||||
|
||||
await shortcutsPage.importShortcuts(exported);
|
||||
await shortcutsPage.confirmImportApply();
|
||||
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
await shortcutsPage.expectShortcutDisabled("Align left");
|
||||
});
|
||||
|
||||
test("Custom shortcuts persist after reload and cancelled edits do not", async ({
|
||||
page,
|
||||
}) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await test.step("A cancelled edit is not saved", async () => {
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
await shortcutsPage.clickEditShortcut("Align left");
|
||||
await shortcutsPage.pressKey("Control+i");
|
||||
await shortcutsPage.cancelEdit();
|
||||
|
||||
await shortcutsPage.expectShortcutNotCustomized("Align left");
|
||||
});
|
||||
|
||||
await test.step("A saved edit survives the reload", async () => {
|
||||
await shortcutsPage.clickEditShortcut("Align bottom");
|
||||
await shortcutsPage.pressKey("Control+y");
|
||||
await shortcutsPage.saveShortcut();
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
const exported = await shortcutsPage.getExportedJson();
|
||||
expect(exported).toHaveProperty("workspace");
|
||||
expect(exported.workspace).toMatchObject({
|
||||
"align-bottom": "ctrl+y",
|
||||
});
|
||||
});
|
||||
|
||||
test("Export includes disabled shortcuts", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await page.reload();
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await shortcutsPage.importShortcuts({
|
||||
workspace: { "align-bottom": "" },
|
||||
});
|
||||
|
||||
await shortcutsPage.confirmImportApply();
|
||||
|
||||
await shortcutsPage.searchForShortcut("Align bottom");
|
||||
await shortcutsPage.expectShortcutDisabled("Align bottom");
|
||||
|
||||
const exported = await shortcutsPage.getExportedJson();
|
||||
expect(exported.workspace).toMatchObject({
|
||||
"align-bottom": "",
|
||||
});
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
await shortcutsPage.expectShortcutNotCustomized("Align left");
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Shortcut Conflict Detection", () => {
|
||||
test("Detects conflict and disables old shortcut on save", async ({
|
||||
page,
|
||||
}) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
test("Detects conflicts on edit and on import", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
const conflictAlert = page
|
||||
.getByRole("alert")
|
||||
.filter({ hasText: /Already assigned to/i });
|
||||
|
||||
await test.step("Conflict with a default binding", async () => {
|
||||
await shortcutsPage.clickEditShortcut("Align bottom");
|
||||
await shortcutsPage.pressKey("Alt+a");
|
||||
|
||||
await expect(
|
||||
page.getByRole("alert").filter({ hasText: /Already assigned to/i }),
|
||||
).toBeVisible();
|
||||
await expect(conflictAlert).toBeVisible();
|
||||
|
||||
await shortcutsPage.saveShortcut();
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
await shortcutsPage.expectShortcutDisabled("Align left");
|
||||
});
|
||||
|
||||
// Align bottom now holds alt+a as a custom binding.
|
||||
await test.step("Conflict with a custom binding", async () => {
|
||||
await shortcutsPage.clickEditShortcut("Align left");
|
||||
await shortcutsPage.pressKey("Alt+a");
|
||||
await expect(conflictAlert).toBeVisible();
|
||||
|
||||
await shortcutsPage.saveShortcut();
|
||||
await shortcutsPage.expectShortcutCustomized("Align left");
|
||||
await shortcutsPage.expectShortcutDisabled("Align bottom");
|
||||
});
|
||||
|
||||
// The importer disables the default binding a file takes over, so this
|
||||
// runs the diff modal's apply path with a default binding in the way.
|
||||
await test.step("Import takes a key a default binding holds", async () => {
|
||||
await shortcutsPage.restoreAllShortcuts();
|
||||
await shortcutsPage.expectShortcutNotCustomized("Align bottom");
|
||||
|
||||
await shortcutsPage.importShortcuts({
|
||||
workspace: { "align-bottom": "alt+a" },
|
||||
});
|
||||
await shortcutsPage.confirmImportApply();
|
||||
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
await shortcutsPage.expectShortcutDisabled("Align left");
|
||||
|
||||
const exported = await shortcutsPage.getExportedJson();
|
||||
expect(exported.workspace).toMatchObject({
|
||||
@ -236,11 +171,13 @@ test.describe("Shortcut Conflict Detection", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Shortcut Reset", () => {
|
||||
test("Reset after import restores defaults", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
test("Reset restores defaults and empty tabs show their placeholders", async ({
|
||||
page,
|
||||
}) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await test.step("Reset all restores the defaults", async () => {
|
||||
await shortcutsPage.importShortcuts({
|
||||
workspace: { "align-bottom": "ctrl+y" },
|
||||
});
|
||||
@ -248,15 +185,30 @@ test.describe("Shortcut Reset", () => {
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
await shortcutsPage.restoreAllShortcuts();
|
||||
|
||||
await shortcutsPage.expectShortcutNotCustomized("Align bottom");
|
||||
});
|
||||
|
||||
test("Reset button shows pending message and requires save to apply", async ({
|
||||
page,
|
||||
}) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
await test.step("Empty tabs show their placeholders", async () => {
|
||||
await shortcutsPage.clickTab("Custom");
|
||||
await expect(shortcutsPage.personalizedTab).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
await expect(page.getByText(/No custom shortcuts yet/i)).toBeVisible();
|
||||
|
||||
await shortcutsPage.clickTab("Disabled");
|
||||
await expect(shortcutsPage.disabledTab).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
await expect(page.getByText(/No disabled shortcuts/i)).toBeVisible();
|
||||
|
||||
await shortcutsPage.clickTab("All");
|
||||
await expect(shortcutsPage.allTab).toHaveAttribute("aria-selected", "true");
|
||||
});
|
||||
|
||||
await test.step("A single reset waits for the save", async () => {
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
await shortcutsPage.clickEditShortcut("Align bottom");
|
||||
await shortcutsPage.pressKey("Control+y");
|
||||
@ -270,96 +222,11 @@ test.describe("Shortcut Reset", () => {
|
||||
page.getByText(/Saving will reset this shortcut/i),
|
||||
).toBeVisible();
|
||||
|
||||
// The reset is pending: it only lands with the save.
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
await shortcutsPage.saveShortcut();
|
||||
|
||||
await shortcutsPage.expectShortcutNotCustomized("Align bottom");
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Shortcut Persistence", () => {
|
||||
test("Custom shortcuts persist after reload", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
await shortcutsPage.clickEditShortcut("Align bottom");
|
||||
await shortcutsPage.pressKey("Control+y");
|
||||
await shortcutsPage.saveShortcut();
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
await page.reload();
|
||||
await shortcutsPage.goToShortcuts();
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Cancel Shortcut Editing", () => {
|
||||
test("Cancel editing does not save changes", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
await shortcutsPage.clickEditShortcut("Align bottom");
|
||||
await shortcutsPage.pressKey("Control+y");
|
||||
await shortcutsPage.cancelEdit();
|
||||
|
||||
await shortcutsPage.expectShortcutNotCustomized("Align bottom");
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Duplicate Shortcut Prevention", () => {
|
||||
test("Assigning same shortcut to two actions shows conflict and disables first", async ({
|
||||
page,
|
||||
}) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
|
||||
await shortcutsPage.clickEditShortcut("Align bottom");
|
||||
await shortcutsPage.pressKey("Control+y");
|
||||
await shortcutsPage.saveShortcut();
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
await shortcutsPage.clickEditShortcut("Align left");
|
||||
await shortcutsPage.pressKey("Control+y");
|
||||
|
||||
await expect(
|
||||
page.getByRole("alert").filter({ hasText: /Already assigned to/i }),
|
||||
).toBeVisible();
|
||||
|
||||
await shortcutsPage.saveShortcut();
|
||||
await shortcutsPage.expectShortcutCustomized("Align left");
|
||||
|
||||
const exported = await shortcutsPage.getExportedJson();
|
||||
expect(exported.workspace).toMatchObject({
|
||||
"align-left": "ctrl+y",
|
||||
"align-bottom": "",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Shortcut Round-Trip", () => {
|
||||
test("Export, reset, import restores configuration", async ({ page }) => {
|
||||
const shortcutsPage = new ShortcutsPage(page);
|
||||
await shortcutsPage.goToShortcuts();
|
||||
|
||||
await shortcutsPage.expandSubsection("Alignment");
|
||||
await shortcutsPage.clickEditShortcut("Align bottom");
|
||||
await shortcutsPage.pressKey("Control+y");
|
||||
await shortcutsPage.saveShortcut();
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
const exported = await shortcutsPage.getExportedJson();
|
||||
|
||||
await shortcutsPage.restoreAllShortcuts();
|
||||
await shortcutsPage.expectShortcutNotCustomized("Align bottom");
|
||||
|
||||
await shortcutsPage.importShortcuts(exported);
|
||||
await shortcutsPage.confirmImportApply();
|
||||
await shortcutsPage.expectShortcutCustomized("Align bottom");
|
||||
|
||||
const reExported = await shortcutsPage.getExportedJson();
|
||||
expect(reExported).toEqual(exported);
|
||||
});
|
||||
});
|
||||
|
||||
@ -198,7 +198,8 @@
|
||||
(conj (dwu/append-undo {:undo-changes undo
|
||||
:redo-changes redo
|
||||
:undo-group edit-group
|
||||
:tags #{}}
|
||||
:tags #{}
|
||||
:translation false}
|
||||
false))
|
||||
|
||||
:always
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user