|
| 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