💄 Add code formatting for js on frontend

This commit is contained in:
Andrey Antukh 2025-11-17 23:12:49 +01:00
parent 3b52051113
commit 122d3bc41c
8 changed files with 154 additions and 105 deletions

View File

@ -42,9 +42,7 @@ test.describe("Export frames to PDF", () => {
await page.getByText("file").last().click(); await page.getByText("file").last().click();
// The "Export frames to PDF" option should NOT be visible when there are no frames // The "Export frames to PDF" option should NOT be visible when there are no frames
await expect( await expect(page.locator("#file-menu-export-frames")).not.toBeVisible();
page.locator("#file-menu-export-frames"),
).not.toBeVisible();
}); });
test("Export frames menu option is visible when there are frames (even if not selected)", async ({ test("Export frames menu option is visible when there are frames (even if not selected)", async ({
@ -58,12 +56,12 @@ test.describe("Export frames to PDF", () => {
await page.getByText("file").last().click(); await page.getByText("file").last().click();
// The "Export frames to PDF" option should be visible when there are frames on the page // The "Export frames to PDF" option should be visible when there are frames on the page
await expect( await expect(page.locator("#file-menu-export-frames")).toBeVisible();
page.locator("#file-menu-export-frames"),
).toBeVisible();
}); });
test("Export frames modal shows all frames when none are selected", async ({ page }) => { test("Export frames modal shows all frames when none are selected", async ({
page,
}) => {
const workspacePage = new WorkspacePage(page); const workspacePage = new WorkspacePage(page);
await setupWorkspaceWithFrames(workspacePage); await setupWorkspaceWithFrames(workspacePage);
@ -87,7 +85,9 @@ test.describe("Export frames to PDF", () => {
await expect(page.getByText("2 of 2 elements selected")).toBeVisible(); await expect(page.getByText("2 of 2 elements selected")).toBeVisible();
}); });
test("Export frames modal shows only the selected frames", async ({ page }) => { test("Export frames modal shows only the selected frames", async ({
page,
}) => {
const workspacePage = new WorkspacePage(page); const workspacePage = new WorkspacePage(page);
await setupWorkspaceWithFrames(workspacePage); await setupWorkspaceWithFrames(workspacePage);
@ -107,7 +107,9 @@ test.describe("Export frames to PDF", () => {
// Only Frame 1 should appear in the list // Only Frame 1 should appear in the list
// await page.getByRole("button", { name: "Board 1" }), // await page.getByRole("button", { name: "Board 1" }),
await expect(page.getByRole("button", { name: "Board 1" })).toBeVisible(); await expect(page.getByRole("button", { name: "Board 1" })).toBeVisible();
await expect(page.getByRole("button", { name: "Board 2" })).not.toBeVisible(); await expect(
page.getByRole("button", { name: "Board 2" }),
).not.toBeVisible();
// The selection counter should show "1 of 1" // The selection counter should show "1 of 1"
await expect(page.getByText("1 of 1 elements selected")).toBeVisible(); await expect(page.getByText("1 of 1 elements selected")).toBeVisible();
@ -144,7 +146,9 @@ test.describe("Export frames to PDF", () => {
await expect(exportButton).toBeEnabled(); await expect(exportButton).toBeEnabled();
}); });
test("Export button is disabled when all frames are deselected", async ({ page }) => { test("Export button is disabled when all frames are deselected", async ({
page,
}) => {
const workspacePage = new WorkspacePage(page); const workspacePage = new WorkspacePage(page);
await setupWorkspaceWithFrames(workspacePage); await setupWorkspaceWithFrames(workspacePage);
@ -163,7 +167,9 @@ test.describe("Export frames to PDF", () => {
await expect(page.getByText("0 of 1 elements selected")).toBeVisible(); await expect(page.getByText("0 of 1 elements selected")).toBeVisible();
// // The export button should be disabled // // The export button should be disabled
await expect(page.getByRole("button", { name: "Export" , exact: true})).toBeDisabled(); await expect(
page.getByRole("button", { name: "Export", exact: true }),
).toBeDisabled();
}); });
test("User can cancel the export modal", async ({ page }) => { test("User can cancel the export modal", async ({ page }) => {
@ -188,4 +194,3 @@ test.describe("Export frames to PDF", () => {
await expect(page.getByText("0 of 1 elements selected")).not.toBeVisible(); await expect(page.getByText("0 of 1 elements selected")).not.toBeVisible();
}); });
}); });

View File

@ -102,22 +102,24 @@ const setupTypographyTokensFile = async (page, options = {}) => {
}); });
}; };
const checkInputFieldWithError = async (tokenThemeUpdateCreateModal, inputLocator) => { const checkInputFieldWithError = async (
await expect(inputLocator).toHaveAttribute("aria-invalid", "true"); tokenThemeUpdateCreateModal,
inputLocator,
) => {
await expect(inputLocator).toHaveAttribute("aria-invalid", "true");
const errorMessageId = await inputLocator.getAttribute("aria-describedby"); const errorMessageId = await inputLocator.getAttribute("aria-describedby");
await expect( await expect(
tokenThemeUpdateCreateModal.locator(`#${errorMessageId}`), tokenThemeUpdateCreateModal.locator(`#${errorMessageId}`),
).toBeVisible(); ).toBeVisible();
}; };
const checkInputFieldWithoutError = async (tokenThemeUpdateCreateModal, inputLocator) => { const checkInputFieldWithoutError = async (
expect( tokenThemeUpdateCreateModal,
await inputLocator.getAttribute("aria-invalid") inputLocator,
).toBeNull(); ) => {
expect( expect(await inputLocator.getAttribute("aria-invalid")).toBeNull();
await inputLocator.getAttribute("aria-describedby") expect(await inputLocator.getAttribute("aria-describedby")).toBeNull();
).toBeNull();
}; };
test.describe("Tokens: Tokens Tab", () => { test.describe("Tokens: Tokens Tab", () => {
@ -199,7 +201,9 @@ test.describe("Tokens: Tokens Tab", () => {
).toBeEnabled(); ).toBeEnabled();
// Tokens tab panel should have two tokens with the color red / #ff0000 // Tokens tab panel should have two tokens with the color red / #ff0000
await expect(tokensTabPanel.getByRole("button", {name: "#ff0000"})).toHaveCount(2); await expect(
tokensTabPanel.getByRole("button", { name: "#ff0000" }),
).toHaveCount(2);
// Global set has been auto created and is active // Global set has been auto created and is active
await expect( await expect(
@ -828,9 +832,7 @@ test.describe("Tokens: Themes modal", () => {
.first() .first()
.click(); .click();
await expect( await expect(tokenThemeUpdateCreateModal).toBeVisible();
tokenThemeUpdateCreateModal
).toBeVisible();
const groupInput = tokenThemeUpdateCreateModal.getByLabel("Group"); const groupInput = tokenThemeUpdateCreateModal.getByLabel("Group");
const nameInput = tokenThemeUpdateCreateModal.getByLabel("Theme"); const nameInput = tokenThemeUpdateCreateModal.getByLabel("Theme");
@ -936,12 +938,8 @@ test.describe("Tokens: Themes modal", () => {
await checkInputFieldWithoutError(tokenThemeUpdateCreateModal, nameInput); await checkInputFieldWithoutError(tokenThemeUpdateCreateModal, nameInput);
await expect(saveButton).not.toBeDisabled(); await expect(saveButton).not.toBeDisabled();
expect( expect(await nameInput.getAttribute("aria-invalid")).toBeNull();
await nameInput.getAttribute("aria-invalid") expect(await nameInput.getAttribute("aria-describedby")).toBeNull();
).toBeNull();
expect(
await nameInput.getAttribute("aria-describedby")
).toBeNull();
const checkboxes = await tokenThemeUpdateCreateModal const checkboxes = await tokenThemeUpdateCreateModal
.locator('[role="checkbox"]') .locator('[role="checkbox"]')
@ -956,7 +954,7 @@ test.describe("Tokens: Themes modal", () => {
} }
const firstButton = await tokenThemeUpdateCreateModal const firstButton = await tokenThemeUpdateCreateModal
.getByTestId('tokens-set-item') .getByTestId("tokens-set-item")
.first(); .first();
await firstButton.click(); await firstButton.click();
@ -1109,12 +1107,10 @@ test.describe("Tokens: Apply token", () => {
// Fill in values for all fields and verify they persist when switching tabs // Fill in values for all fields and verify they persist when switching tabs
await fontSizeField.fill("16"); await fontSizeField.fill("16");
const fontWeightField = const fontWeightField = tokensUpdateCreateModal.getByLabel(/Font Weight/i);
tokensUpdateCreateModal.getByLabel(/Font Weight/i);
const letterSpacingField = const letterSpacingField =
tokensUpdateCreateModal.getByLabel(/Letter Spacing/i); tokensUpdateCreateModal.getByLabel(/Letter Spacing/i);
const lineHeightField = const lineHeightField = tokensUpdateCreateModal.getByLabel(/Line Height/i);
tokensUpdateCreateModal.getByLabel(/Line Height/i);
const textCaseField = tokensUpdateCreateModal.getByLabel(/Text Case/i); const textCaseField = tokensUpdateCreateModal.getByLabel(/Text Case/i);
const textDecorationField = const textDecorationField =
tokensUpdateCreateModal.getByLabel(/Text Decoration/i); tokensUpdateCreateModal.getByLabel(/Text Decoration/i);
@ -1149,9 +1145,7 @@ test.describe("Tokens: Apply token", () => {
await expect(fontSizeField).toHaveValue(originalValues.fontSize); await expect(fontSizeField).toHaveValue(originalValues.fontSize);
await expect(fontFamilyField).toHaveValue(originalValues.fontFamily); await expect(fontFamilyField).toHaveValue(originalValues.fontFamily);
await expect(fontWeightField).toHaveValue(originalValues.fontWeight); await expect(fontWeightField).toHaveValue(originalValues.fontWeight);
await expect(letterSpacingField).toHaveValue( await expect(letterSpacingField).toHaveValue(originalValues.letterSpacing);
originalValues.letterSpacing,
);
await expect(lineHeightField).toHaveValue(originalValues.lineHeight); await expect(lineHeightField).toHaveValue(originalValues.lineHeight);
await expect(textCaseField).toHaveValue(originalValues.textCase); await expect(textCaseField).toHaveValue(originalValues.textCase);
await expect(textDecorationField).toHaveValue( await expect(textDecorationField).toHaveValue(
@ -1248,9 +1242,15 @@ test.describe("Tokens: Apply token", () => {
await expect(newToken).toBeVisible(); await expect(newToken).toBeVisible();
}); });
test("User adds shadow token with multiple shadows and applies it to shape", async ({ page, }) => { test("User adds shadow token with multiple shadows and applies it to shape", async ({
const { tokensUpdateCreateModal, tokensSidebar, workspacePage, tokenContextMenuForToken } = page,
await setupTokensFile(page, { flags: ["enable-token-shadow"] }); }) => {
const {
tokensUpdateCreateModal,
tokensSidebar,
workspacePage,
tokenContextMenuForToken,
} = await setupTokensFile(page, { flags: ["enable-token-shadow"] });
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" }); const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
@ -1301,7 +1301,9 @@ test.describe("Tokens: Apply token", () => {
await expect(firstColorValue).toMatch(/^rgb(.*)$/); await expect(firstColorValue).toMatch(/^rgb(.*)$/);
// Wait for validation to complete // Wait for validation to complete
await expect(tokensUpdateCreateModal.getByText(/Resolved value:/).first()).toBeVisible(); await expect(
tokensUpdateCreateModal.getByText(/Resolved value:/).first(),
).toBeVisible();
// Save button should be enabled // Save button should be enabled
const submitButton = tokensUpdateCreateModal.getByRole("button", { const submitButton = tokensUpdateCreateModal.getByRole("button", {
@ -1349,18 +1351,32 @@ test.describe("Tokens: Apply token", () => {
await thirdColorInput.fill("#FF0000"); await thirdColorInput.fill("#FF0000");
// User removes the 2nd shadow // User removes the 2nd shadow
const removeButton2 = secondShadowFields.getByTestId("shadow-remove-button-1"); const removeButton2 = secondShadowFields.getByTestId(
"shadow-remove-button-1",
);
await removeButton2.click(); await removeButton2.click();
// Verify second shadow is removed // Verify second shadow is removed
await expect(secondShadowFields.getByTestId("shadow-add-button-3")).not.toBeVisible(); await expect(
secondShadowFields.getByTestId("shadow-add-button-3"),
).not.toBeVisible();
// Verify that the first shadow kept its values // Verify that the first shadow kept its values
const firstOffsetXValue = await firstShadowFields.getByLabel("X").inputValue(); const firstOffsetXValue = await firstShadowFields
const firstOffsetYValue = await firstShadowFields.getByLabel("Y").inputValue(); .getByLabel("X")
const firstBlurValue = await firstShadowFields.getByLabel("Blur").inputValue(); .inputValue();
const firstSpreadValue = await firstShadowFields.getByLabel("Spread").inputValue(); const firstOffsetYValue = await firstShadowFields
const firstColorValueAfter = await firstShadowFields.getByLabel("Color").inputValue(); .getByLabel("Y")
.inputValue();
const firstBlurValue = await firstShadowFields
.getByLabel("Blur")
.inputValue();
const firstSpreadValue = await firstShadowFields
.getByLabel("Spread")
.inputValue();
const firstColorValueAfter = await firstShadowFields
.getByLabel("Color")
.inputValue();
await expect(firstOffsetXValue).toBe("2"); await expect(firstOffsetXValue).toBe("2");
await expect(firstOffsetYValue).toBe("2"); await expect(firstOffsetYValue).toBe("2");
@ -1375,11 +1391,21 @@ test.describe("Tokens: Apply token", () => {
); );
await expect(newSecondShadowFields).toBeVisible(); await expect(newSecondShadowFields).toBeVisible();
const secondOffsetXValue = await newSecondShadowFields.getByLabel("X").inputValue(); const secondOffsetXValue = await newSecondShadowFields
const secondOffsetYValue = await newSecondShadowFields.getByLabel("Y").inputValue(); .getByLabel("X")
const secondBlurValue = await newSecondShadowFields.getByLabel("Blur").inputValue(); .inputValue();
const secondSpreadValue = await newSecondShadowFields.getByLabel("Spread").inputValue(); const secondOffsetYValue = await newSecondShadowFields
const secondColorValue = await newSecondShadowFields.getByLabel("Color").inputValue(); .getByLabel("Y")
.inputValue();
const secondBlurValue = await newSecondShadowFields
.getByLabel("Blur")
.inputValue();
const secondSpreadValue = await newSecondShadowFields
.getByLabel("Spread")
.inputValue();
const secondColorValue = await newSecondShadowFields
.getByLabel("Color")
.inputValue();
await expect(secondOffsetXValue).toBe("10"); await expect(secondOffsetXValue).toBe("10");
await expect(secondOffsetYValue).toBe("10"); await expect(secondOffsetYValue).toBe("10");
@ -1399,14 +1425,16 @@ test.describe("Tokens: Apply token", () => {
const firstColorValue = await colorInput.inputValue(); const firstColorValue = await colorInput.inputValue();
// Switch to reference tab // Switch to reference tab
const referenceTabButton = tokensUpdateCreateModal.getByTestId("reference-opt"); const referenceTabButton =
tokensUpdateCreateModal.getByTestId("reference-opt");
await referenceTabButton.click(); await referenceTabButton.click();
// Verify we're in reference mode - the composite fields should not be visible // Verify we're in reference mode - the composite fields should not be visible
await expect(firstShadowFields).not.toBeVisible(); await expect(firstShadowFields).not.toBeVisible();
// Switch back to composite tab // Switch back to composite tab
const compositeTabButton = tokensUpdateCreateModal.getByTestId("composite-opt"); const compositeTabButton =
tokensUpdateCreateModal.getByTestId("composite-opt");
await compositeTabButton.click(); await compositeTabButton.click();
// Verify that shadows are restored // Verify that shadows are restored
@ -1414,11 +1442,21 @@ test.describe("Tokens: Apply token", () => {
await expect(newSecondShadowFields).toBeVisible(); await expect(newSecondShadowFields).toBeVisible();
// Verify first shadow values are still there // Verify first shadow values are still there
const restoredFirstOffsetX = await firstShadowFields.getByLabel("X").inputValue(); const restoredFirstOffsetX = await firstShadowFields
const restoredFirstOffsetY = await firstShadowFields.getByLabel("Y").inputValue(); .getByLabel("X")
const restoredFirstBlur = await firstShadowFields.getByLabel("Blur").inputValue(); .inputValue();
const restoredFirstSpread = await firstShadowFields.getByLabel("Spread").inputValue(); const restoredFirstOffsetY = await firstShadowFields
const restoredFirstColor = await firstShadowFields.getByLabel("Color").inputValue(); .getByLabel("Y")
.inputValue();
const restoredFirstBlur = await firstShadowFields
.getByLabel("Blur")
.inputValue();
const restoredFirstSpread = await firstShadowFields
.getByLabel("Spread")
.inputValue();
const restoredFirstColor = await firstShadowFields
.getByLabel("Color")
.inputValue();
await expect(restoredFirstOffsetX).toBe("2"); await expect(restoredFirstOffsetX).toBe("2");
await expect(restoredFirstOffsetY).toBe("2"); await expect(restoredFirstOffsetY).toBe("2");
@ -1427,11 +1465,21 @@ test.describe("Tokens: Apply token", () => {
await expect(restoredFirstColor).toBe(firstColorValue); await expect(restoredFirstColor).toBe(firstColorValue);
// Verify second shadow values are still there // Verify second shadow values are still there
const restoredSecondOffsetX = await newSecondShadowFields.getByLabel("X").inputValue(); const restoredSecondOffsetX = await newSecondShadowFields
const restoredSecondOffsetY = await newSecondShadowFields.getByLabel("Y").inputValue(); .getByLabel("X")
const restoredSecondBlur = await newSecondShadowFields.getByLabel("Blur").inputValue(); .inputValue();
const restoredSecondSpread = await newSecondShadowFields.getByLabel("Spread").inputValue(); const restoredSecondOffsetY = await newSecondShadowFields
const restoredSecondColor = await newSecondShadowFields.getByLabel("Color").inputValue(); .getByLabel("Y")
.inputValue();
const restoredSecondBlur = await newSecondShadowFields
.getByLabel("Blur")
.inputValue();
const restoredSecondSpread = await newSecondShadowFields
.getByLabel("Spread")
.inputValue();
const restoredSecondColor = await newSecondShadowFields
.getByLabel("Color")
.inputValue();
await expect(restoredSecondOffsetX).toBe("10"); await expect(restoredSecondOffsetX).toBe("10");
await expect(restoredSecondOffsetY).toBe("10"); await expect(restoredSecondOffsetY).toBe("10");

View File

@ -44,7 +44,7 @@ export default {
property: "search", property: "search",
}, },
parameters: { parameters: {
controls: { exclude: ["tokens"] } controls: { exclude: ["tokens"] },
}, },
render: ({ ...args }) => <NumericInput {...args} />, render: ({ ...args }) => <NumericInput {...args} />,
@ -118,7 +118,7 @@ export const WithTokens = {
], ],
}, },
}, },
parameters: { parameters: {
controls: { exclude: ["tokens"] }, controls: { exclude: ["tokens"] },
docs: { docs: {
story: { story: {

View File

@ -9,10 +9,7 @@ import Components from "@target/components";
const { Select } = Components; const { Select } = Components;
const variants = [ const variants = ["default", "ghost"];
"default",
"ghost",
];
const options = [ const options = [
{ id: "option-code", label: "Code" }, { id: "option-code", label: "Code" },

View File

@ -20,17 +20,17 @@ export default {
disabled: { disabled: {
control: { type: "boolean" }, control: { type: "boolean" },
description: "Whether the switch is disabled", description: "Whether the switch is disabled",
} },
}, },
args: { args: {
disabled: false disabled: false,
}, },
parameters: { parameters: {
controls: { exclude: ["id", "class", "aria-label", "default-checked", "on-change"] }, controls: {
exclude: ["id", "class", "aria-label", "default-checked", "on-change"],
},
}, },
render: ({ ...args }) => ( render: ({ ...args }) => <Switch {...args} />,
<Switch {...args} />
),
}; };
export const Default = { export const Default = {
@ -38,23 +38,20 @@ export const Default = {
label: "Toggle something", label: "Toggle something",
disabled: false, disabled: false,
}, },
render: ({ ...args }) => ( render: ({ ...args }) => <Switch {...args} />,
<Switch {...args} />
),
}; };
export const WithoutLabel = { export const WithoutLabel = {
args: { args: {
disabled: false, disabled: false,
}, },
render: ({ ...args }) => ( render: ({ ...args }) => <Switch {...args} />,
<Switch {...args} />
),
}; };
export const WithLongLabel = { export const WithLongLabel = {
args: { args: {
label: "This is a very long label that demonstrates how the switch component handles text wrapping and layout when the label content is extensive", label:
"This is a very long label that demonstrates how the switch component handles text wrapping and layout when the label content is extensive",
disabled: false, disabled: false,
}, },
render: ({ ...args }) => ( render: ({ ...args }) => (

View File

@ -36,9 +36,11 @@ export const All = {
), ),
parameters: { parameters: {
controls: { exclude: ["id"] }, controls: { exclude: ["id"] },
backgrounds: { options: { backgrounds: {
debug: { name: "debug", value: "#ccc" } options: {
} }, debug: { name: "debug", value: "#ccc" },
},
},
}, },
}; };

View File

@ -22,7 +22,7 @@ export default {
}, },
parameters: { parameters: {
controls: { exclude: ["children", "theme", "style"] } controls: { exclude: ["children", "theme", "style"] },
}, },
args: { args: {
@ -40,9 +40,9 @@ export default {
globals: { globals: {
backgrounds: { backgrounds: {
value: "light" value: "light",
} },
} },
}; };
export const AnyHeading = { export const AnyHeading = {