mirror of
https://github.com/penpot/penpot.git
synced 2025-02-07 23:08:24 -05:00
♻ Extract common token setup logic, fix selector
This commit is contained in:
parent
85fa635f66
commit
e4460acfae
1 changed files with 27 additions and 26 deletions
|
@ -5,21 +5,27 @@ test.beforeEach(async ({ page }) => {
|
||||||
await WorkspacePage.init(page);
|
await WorkspacePage.init(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const setupFileWithTokens = async (page) => {
|
||||||
|
const workspacePage = new WorkspacePage(page);
|
||||||
|
await workspacePage.setupEmptyFile();
|
||||||
|
await workspacePage.mockRPC(
|
||||||
|
"get-team?id=*",
|
||||||
|
"workspace/get-team-tokens.json",
|
||||||
|
);
|
||||||
|
|
||||||
|
await workspacePage.goToWorkspace();
|
||||||
|
|
||||||
|
const tokensTabButton = page.getByRole("tab", { name: "Tokens" });
|
||||||
|
await tokensTabButton.click();
|
||||||
|
|
||||||
|
return { workspacePage };
|
||||||
|
};
|
||||||
|
|
||||||
test.describe("Tokens: Tab", () => {
|
test.describe("Tokens: Tab", () => {
|
||||||
test("Clicking tokens tab button opens tokens sidebar tab", async ({
|
test("Clicking tokens tab button opens tokens sidebar tab", async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
const workspacePage = new WorkspacePage(page);
|
const { workspacePage } = await setupFileWithTokens(page);
|
||||||
await workspacePage.setupEmptyFile();
|
|
||||||
await workspacePage.mockRPC(
|
|
||||||
"get-team?id=*",
|
|
||||||
"workspace/get-team-tokens.json",
|
|
||||||
);
|
|
||||||
|
|
||||||
await workspacePage.goToWorkspace();
|
|
||||||
|
|
||||||
const tokensTabButton = page.getByRole("tab", { name: "Tokens" });
|
|
||||||
await tokensTabButton.click();
|
|
||||||
|
|
||||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||||
|
|
||||||
|
@ -30,17 +36,7 @@ test.describe("Tokens: Tab", () => {
|
||||||
test("User creates color token and auto created set show up in the sidebar", async ({
|
test("User creates color token and auto created set show up in the sidebar", async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
const workspacePage = new WorkspacePage(page);
|
const { workspacePage } = await setupFileWithTokens(page);
|
||||||
await workspacePage.setupEmptyFile();
|
|
||||||
await workspacePage.mockRPC(
|
|
||||||
"get-team?id=*",
|
|
||||||
"workspace/get-team-tokens.json",
|
|
||||||
);
|
|
||||||
|
|
||||||
await workspacePage.goToWorkspace();
|
|
||||||
|
|
||||||
const tokensTabButton = page.getByRole("tab", { name: "Tokens" });
|
|
||||||
await tokensTabButton.click();
|
|
||||||
|
|
||||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||||
await tokensTabPanel.getByTitle("Add token: Color").click();
|
await tokensTabPanel.getByTitle("Add token: Color").click();
|
||||||
|
@ -59,9 +55,14 @@ test.describe("Tokens: Tab", () => {
|
||||||
await valueField.click();
|
await valueField.click();
|
||||||
await valueField.fill("red");
|
await valueField.fill("red");
|
||||||
|
|
||||||
const submitButtonSelector = `button[type="submit"]:enabled`;
|
const submitButton = workspacePage.tokensUpdateCreateModal.getByRole(
|
||||||
await page.waitForSelector(submitButtonSelector);
|
"button",
|
||||||
await page.locator(submitButtonSelector).click();
|
{
|
||||||
|
name: "Save",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await expect(submitButton).toBeEnabled();
|
||||||
|
await submitButton.click();
|
||||||
|
|
||||||
await expect(tokensTabPanel.getByText("color.primary")).toBeEnabled();
|
await expect(tokensTabPanel.getByText("color.primary")).toBeEnabled();
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ test.describe("Tokens: Tab", () => {
|
||||||
await valueField.click();
|
await valueField.click();
|
||||||
await valueField.fill("{color.primary}");
|
await valueField.fill("{color.primary}");
|
||||||
|
|
||||||
await page.waitForSelector(submitButtonSelector);
|
await expect(submitButton).toBeEnabled();
|
||||||
await nameField.press("Enter");
|
await nameField.press("Enter");
|
||||||
|
|
||||||
const referenceToken = tokensTabPanel.getByText("color.secondary");
|
const referenceToken = tokensTabPanel.getByText("color.secondary");
|
||||||
|
|
Loading…
Add table
Reference in a new issue