Skip to content

Commit 3ff8a5f

Browse files
authored
refactor: cypress e2e/devices tests to use Cucumber MAASENG-5893 (#5934)
1 parent 8a49667 commit 3ff8a5f

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Feature: Device listing
2+
3+
Background
4+
Given the user is logged in
5+
And the user is on the devices page
6+
7+
Scenario: The correct heading is rendered
8+
Then the section header title should be "Devices"
9+
10+
Scenario: The user can add a tag to a device
11+
Given the user adds a new device
12+
When the user opens the device configuration
13+
And the user adds a tag to the device
14+
Then the tag should be visible in the device summary
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor";
2+
import { generateMAASURL, generateMac } from "../../../e2e/utils";
3+
4+
Given("the user is on the devices page", () => {
5+
cy.visit(generateMAASURL("/devices"));
6+
});
7+
8+
Given("the user adds a new device", () => {
9+
cy.findByRole("button", { name: /Add device/ }).click();
10+
const mac = generateMac();
11+
cy.findByLabelText(/Device name/).type("cypress-device");
12+
cy.get("input[placeholder='00:00:00:00:00:00']").type(mac);
13+
cy.findByRole("button", { name: /Save device/ }).click();
14+
});
15+
16+
When("the user opens the device configuration", () => {
17+
cy.findByRole("link", { name: /cypress-device/ }).click();
18+
19+
cy.findByRole("link", {
20+
name: /Configuration/,
21+
}).click();
22+
});
23+
24+
When("the user adds a tag to the device", () => {
25+
cy.findByRole("button", {
26+
name: /Edit/,
27+
}).click();
28+
cy.get("input[placeholder='Create or remove tags']").type("device-tag");
29+
30+
cy.findByRole("button", {
31+
name: /Create tag "device-tag"/,
32+
}).click();
33+
34+
cy.findByRole("button", {
35+
name: /Create and add to tag changes/,
36+
}).click();
37+
38+
cy.findByRole("button", { name: /Save changes/ }).click();
39+
});
40+
41+
Then("the section header title should be {string}", (expectedTitle: string) => {
42+
cy.get("[data-testid='section-header-title']").should(
43+
"contain",
44+
expectedTitle
45+
);
46+
});
47+
48+
Then("the tag should be visible in the device summary", () => {
49+
cy.findByRole("link", { name: /Summary/ }).click();
50+
cy.findByText(/device-tag/).should("exist");
51+
});

0 commit comments

Comments
 (0)