-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
connect.spec.js
51 lines (42 loc) · 1.92 KB
/
connect.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// @ts-check
const {test, expect} = require("../fixtures");
test.describe("Printer connection", () => {
test.beforeEach(async ({ui, connectionApi}) => {
await ui.gotoLoggedInCore();
const response = await connectionApi.disconnect();
await expect(response.ok()).toBeTruthy();
});
test("connect & disconnect against virtual printer", async ({page}) => {
await expect(page.getByTestId("state-string")).toHaveText("Offline");
// Connect
await page.getByTestId("connection-ports").selectOption("VIRTUAL");
await page.getByTestId("connection-baudrates").selectOption("AUTO");
await page.getByTestId("connection-printer-profiles").selectOption("Default");
await expect(page.getByTestId("connection-connect")).toHaveText("Connect");
await page.getByTestId("connection-connect").click();
// State should change to Operational
await expect(page.getByTestId("state-string")).toHaveText("Operational", {
timeout: 15_000
});
// Connection panel should roll up
await page.waitForFunction(
() => {
const element = document.querySelector(
"[data-test-id=sidebar-connection-content]"
);
if (!element) {
return false;
}
const parent = element.parentElement;
return parent && parent.getBoundingClientRect().height === 0;
},
{timeout: 15_000}
);
// Disconnect
await page.getByTestId("sidebar-connection-toggle").click();
await expect(page.getByTestId("connection-connect")).toBeVisible();
await expect(page.getByTestId("connection-connect")).toHaveText("Disconnect");
await page.getByTestId("connection-connect").click();
await expect(page.getByTestId("state-string")).toHaveText("Offline");
});
});