Add integration tests for creating sets

This commit is contained in:
Florian Schroedl 2024-11-26 10:56:52 +01:00
parent b5110c2222
commit 7bce4ab425
3 changed files with 40 additions and 0 deletions

View file

@ -22,6 +22,8 @@ const setupFileWithTokens = async (page) => {
workspacePage,
tokensUpdateCreateModal: workspacePage.tokensUpdateCreateModal,
tokenThemesSetsSidebar: workspacePage.tokenThemesSetsSidebar,
tokenSetItems: workspacePage.tokenSetItems,
tokenSetGroupItems: workspacePage.tokenSetGroupItems,
};
};
@ -102,3 +104,37 @@ test.describe("Tokens: Tokens Tab", () => {
).toHaveAttribute("aria-checked", "true");
});
});
test.describe("Tokens: Sets Tab", () => {
const createSet = async (sidebar, setName) => {
const tokensTabButton = sidebar
.getByRole("button", { name: "Add set" })
.click();
const setInput = sidebar.locator("input:focus");
await expect(setInput).toBeVisible();
await setInput.fill(setName);
await setInput.press("Enter");
};
test("User creates sets tree structure by entering a set path", async ({
page,
}) => {
const {
workspacePage,
tokenThemesSetsSidebar,
tokenSetItems,
tokenSetGroupItems,
} = await setupFileWithTokens(page);
const tokensTabButton = tokenThemesSetsSidebar
.getByRole("button", { name: "Add set" })
.click();
await createSet(tokenThemesSetsSidebar, "core/colors/light");
await createSet(tokenThemesSetsSidebar, "core/colors/dark");
await expect(tokenSetItems).toHaveCount(2);
await expect(tokenSetGroupItems).toHaveCount(2);
});
});