Skip to content

Commit

Permalink
[sequencer-gallery] chore: adding CI test for Gallery + testing injec…
Browse files Browse the repository at this point in the history
…ted min & max
  • Loading branch information
LatentDream committed Apr 22, 2024
1 parent 0c4a161 commit f9ea663
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
64 changes: 64 additions & 0 deletions playwright-test/15_sequences_gallery.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { test, expect, Page, ElectronApplication } from "@playwright/test";
import { _electron as electron } from "playwright";
import {
STARTUP_TIMEOUT,
getExecutablePath,
mockDialogMessage,
standbyStatus,
} from "./utils";
import { Selectors } from "./selectors";

test.describe("Load a demo test sequence", () => {
let window: Page;
let app: ElectronApplication;
test.beforeAll(async () => {
test.setTimeout(STARTUP_TIMEOUT);
const executablePath = getExecutablePath();
app = await electron.launch({ executablePath });
await mockDialogMessage(app);
window = await app.firstWindow();
await expect(
window.locator("code", { hasText: standbyStatus }),
).toBeVisible({ timeout: STARTUP_TIMEOUT });
await window.getByTestId(Selectors.closeWelcomeModalBtn).click();
// Switch to sequencer tab
await window.getByTestId(Selectors.testSequencerTabBtn).click();
});

test.afterAll(async () => {
await app.close();
});

test("Should load and run a sequence", async () => {
await expect(window.getByTestId(Selectors.newDropdown)).toBeEnabled({
timeout: 15000,
});

// Open the sequence gallery
await window.getByTestId(Selectors.newDropdown).click();
await window.getByTestId(Selectors.openSequenceGalleryBtn).click();

// Open a sequence
await window.getByTestId("test_step_with_expected_and_exported_values").nth(1).click();

// Expect sequence and tests to be loaded
await expect(
window.locator("div", { hasText: "Export_&_Expected_Demo" }).first(),
).toBeVisible();

// Expect test steps to bey loaded
await expect(
window.locator("div", { hasText: "test_min_max" }).first(),
).toBeVisible();

// Run the sequence
await window.getByTestId(Selectors.runBtn).click();
await window.waitForTimeout(10000);

// Check the status
await expect(window.getByTestId(Selectors.globalStatusBadge)).toContainText(
"FAIL",
);
await expect(window.getByTestId("status-test_min_max")).toContainText("PASS");
});
});
1 change: 1 addition & 0 deletions playwright-test/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export enum Selectors {
pytestBtn = "pytest-btn",
newDropdown = "new-dropdown",
importTestBtn = "import-test-button",
openSequenceGalleryBtn = "seq-gallery-btn",
globalStatusBadge = "global-status-badge",
newSeqModalNameInput = "new-seq-modal-name-input",
newSeqModalDescInput = "new-seq-modal-desc-input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function DesignBar() {
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => setIsGalleryOpen(true)}
data-testid="app-gallery-btn"
data-testid="seq-gallery-btn"
>
<LayoutGrid
size={16}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export function TestTable() {
header: () => <div className="pl-4 text-center">Status</div>,
cell: ({ row }) => {
return row.original.type === "test" ? (
<div className="my-2 flex justify-center">
<div className="my-2 flex justify-center" data-testid={`status-${row.original.testName}`}>
{typeof mapStatusToDisplay[row.original.status] === "function"
? mapStatusToDisplay[row.original.status](row.original.error)
: mapStatusToDisplay[row.original.status]}
Expand Down

0 comments on commit f9ea663

Please sign in to comment.