|
| 1 | +import { expect, type LangflowPage, test } from "../fixtures"; |
| 2 | +import { adjustScreenView } from "../utils/adjust-screen-view"; |
| 3 | +import { TID } from "../utils/constants/testIds"; |
| 4 | +import { TEXTS } from "../utils/constants/texts"; |
| 5 | +import { TIMEOUTS } from "../utils/constants/timeouts"; |
| 6 | +import { addComponentFromSidebar } from "../utils/flow/add-component-from-sidebar"; |
| 7 | + |
| 8 | +async function disableAnimations(page: LangflowPage) { |
| 9 | + await page.addStyleTag({ |
| 10 | + content: ` |
| 11 | + *, |
| 12 | + *::before, |
| 13 | + *::after { |
| 14 | + animation-duration: 0s !important; |
| 15 | + animation-delay: 0s !important; |
| 16 | + transition-duration: 0s !important; |
| 17 | + transition-delay: 0s !important; |
| 18 | + scroll-behavior: auto !important; |
| 19 | + } |
| 20 | + `, |
| 21 | + }); |
| 22 | +} |
| 23 | + |
| 24 | +async function hideComponentSidebar(page: LangflowPage) { |
| 25 | + const style = await page.addStyleTag({ |
| 26 | + content: '[data-testid="shad-sidebar"] { display: none !important; }', |
| 27 | + }); |
| 28 | + await expect(page.getByTestId("shad-sidebar")).toBeHidden(); |
| 29 | + return style; |
| 30 | +} |
| 31 | + |
| 32 | +async function openBlankFlowForA11y(page: LangflowPage) { |
| 33 | + await page.goto("/"); |
| 34 | + await expect(page.getByTestId(TID.mainpageTitle)).toBeVisible({ |
| 35 | + timeout: TIMEOUTS.standard, |
| 36 | + }); |
| 37 | + |
| 38 | + const emptyPageButton = page.getByTestId(TID.newProjectBtnEmptyPage); |
| 39 | + if (await emptyPageButton.isVisible()) { |
| 40 | + await emptyPageButton.click(); |
| 41 | + } else { |
| 42 | + await page.getByTestId(TID.newProjectBtn).click(); |
| 43 | + } |
| 44 | + |
| 45 | + const welcomePanel = page.getByTestId("flow-builder-welcome-panel"); |
| 46 | + const modalTitle = page.getByTestId(TID.modalTitle); |
| 47 | + await expect(welcomePanel.or(modalTitle)).toBeVisible({ |
| 48 | + timeout: TIMEOUTS.standard, |
| 49 | + }); |
| 50 | + |
| 51 | + if (await welcomePanel.isVisible()) { |
| 52 | + await page.getByTestId("flow-builder-welcome-browse-more").click(); |
| 53 | + } |
| 54 | + |
| 55 | + await expect(page.getByTestId(TID.blankFlow)).toBeVisible({ |
| 56 | + timeout: TIMEOUTS.standard, |
| 57 | + }); |
| 58 | + await page.getByTestId(TID.blankFlow).click(); |
| 59 | +} |
| 60 | + |
| 61 | +test.describe("core application accessibility", () => { |
| 62 | + test.describe.configure({ mode: "serial" }); |
| 63 | + |
| 64 | + test( |
| 65 | + "scans flow creation and playground states", |
| 66 | + { tag: ["@a11y", "@workspace"] }, |
| 67 | + async ({ page }) => { |
| 68 | + await openBlankFlowForA11y(page); |
| 69 | + await disableAnimations(page); |
| 70 | + await expect(page.getByTestId(TID.sidebarSearchInput)).toBeVisible(); |
| 71 | + const emptyCanvasSidebarStyle = await hideComponentSidebar(page); |
| 72 | + |
| 73 | + await page.runA11yScan("flow-canvas-empty"); |
| 74 | + |
| 75 | + await emptyCanvasSidebarStyle.evaluate((style) => style.remove()); |
| 76 | + await expect(page.getByTestId(TID.sidebarSearchInput)).toBeVisible(); |
| 77 | + await addComponentFromSidebar(page, { |
| 78 | + search: TEXTS.searchChatOutput, |
| 79 | + testId: "input_outputChat Output", |
| 80 | + hoverAdd: true, |
| 81 | + }); |
| 82 | + await addComponentFromSidebar(page, { |
| 83 | + search: TEXTS.searchChatInput, |
| 84 | + testId: "input_outputChat Input", |
| 85 | + position: { x: 100, y: 100 }, |
| 86 | + }); |
| 87 | + await adjustScreenView(page); |
| 88 | + await hideComponentSidebar(page); |
| 89 | + |
| 90 | + await page |
| 91 | + .getByTestId("handle-chatinput-noshownode-chat message-source") |
| 92 | + .click(); |
| 93 | + await page |
| 94 | + .getByTestId("handle-chatoutput-noshownode-inputs-target") |
| 95 | + .click(); |
| 96 | + |
| 97 | + await page.runA11yScan("flow-canvas-populated"); |
| 98 | + |
| 99 | + await page.getByTestId("title-Chat Input").click(); |
| 100 | + await expect(page.getByTestId(TID.editFieldsButton)).toBeVisible(); |
| 101 | + await page.getByTestId(TID.editFieldsButton).click(); |
| 102 | + await expect(page.getByTestId("showinput_value")).toBeVisible(); |
| 103 | + |
| 104 | + await page.runA11yScan("component-configuration"); |
| 105 | + |
| 106 | + await page.getByTestId(TID.editFieldsButton).click(); |
| 107 | + await page |
| 108 | + .getByRole("button", { name: TEXTS.playground, exact: true }) |
| 109 | + .click(); |
| 110 | + await expect(page.getByTestId(TID.inputChatPlayground)).toBeVisible({ |
| 111 | + timeout: TIMEOUTS.componentMount, |
| 112 | + }); |
| 113 | + |
| 114 | + await page.runA11yScan("playground-empty"); |
| 115 | + |
| 116 | + await page |
| 117 | + .getByTestId(TID.inputChatPlayground) |
| 118 | + .fill("Accessibility test"); |
| 119 | + await page.getByTestId(TID.buttonSend).first().click(); |
| 120 | + await expect(page.getByTestId(TID.chatMessage)).toHaveText( |
| 121 | + "Accessibility test", |
| 122 | + { timeout: TIMEOUTS.componentMount }, |
| 123 | + ); |
| 124 | + |
| 125 | + await page.runA11yScan("playground-with-message"); |
| 126 | + }, |
| 127 | + ); |
| 128 | + |
| 129 | + test( |
| 130 | + "scans flows landing page", |
| 131 | + { tag: ["@a11y", "@workspace"] }, |
| 132 | + async ({ page }) => { |
| 133 | + await page.goto("/flows"); |
| 134 | + await disableAnimations(page); |
| 135 | + await expect(page.getByTestId(TID.mainpageTitle)).toBeVisible({ |
| 136 | + timeout: TIMEOUTS.standard, |
| 137 | + }); |
| 138 | + |
| 139 | + await page.runA11yScan("flows-landing"); |
| 140 | + }, |
| 141 | + ); |
| 142 | + |
| 143 | + test( |
| 144 | + "scans general settings", |
| 145 | + { tag: ["@a11y", "@workspace"] }, |
| 146 | + async ({ page }) => { |
| 147 | + await page.goto("/settings/general"); |
| 148 | + await disableAnimations(page); |
| 149 | + await expect(page.getByTestId(TID.settingsMenuHeader)).toBeVisible({ |
| 150 | + timeout: TIMEOUTS.standard, |
| 151 | + }); |
| 152 | + |
| 153 | + await page.runA11yScan("settings-general"); |
| 154 | + }, |
| 155 | + ); |
| 156 | + |
| 157 | + test( |
| 158 | + "scans files page", |
| 159 | + { tag: ["@a11y", "@workspace"] }, |
| 160 | + async ({ page }) => { |
| 161 | + await page.goto("/assets/files"); |
| 162 | + await disableAnimations(page); |
| 163 | + await expect(page.getByTestId(TID.mainpageTitle)).toContainText("Files", { |
| 164 | + timeout: TIMEOUTS.standard, |
| 165 | + }); |
| 166 | + await expect(page.getByTestId("upload-file-btn")).toBeVisible(); |
| 167 | + |
| 168 | + await page.runA11yScan("files-page"); |
| 169 | + }, |
| 170 | + ); |
| 171 | +}); |
0 commit comments