diff --git a/packages/builder/cypress/integration/createAutomation.spec.js b/packages/builder/cypress/integration/createAutomation.spec.js index 69ef3f98a3..6a4b70f8dc 100644 --- a/packages/builder/cypress/integration/createAutomation.spec.js +++ b/packages/builder/cypress/integration/createAutomation.spec.js @@ -1,4 +1,5 @@ import filterTests from "../support/filterTests" +const interact = require('../support/interact') filterTests(['smoke', 'all'], () => { context("Create a automation", () => { @@ -11,51 +12,51 @@ filterTests(['smoke', 'all'], () => { cy.createTestTableWithData() cy.wait(2000) cy.contains("Automate").click() - cy.get(".add-button .spectrum-Icon").click() - cy.get(".modal-inner-wrapper").within(() => { + cy.get(interact.ADD_BUTTON_SPECTRUM).click() + cy.get(interact.MODAL_INNER_WRAPPER).within(() => { cy.get("input").type("Add Row") cy.contains("Row Created").click({ force: true }) cy.wait(500) - cy.get(".spectrum-Button--cta").click() + cy.get(interact.SPECTRUM_BUTTON_CTA).click() }) // Setup trigger - cy.get(".spectrum-Picker-label").click() + cy.get(interact.SPECTRUM_PICKER_LABEL).click() cy.wait(500) cy.contains("dog").click() cy.wait(2000) // Create action cy.get('[aria-label="AddCircle"]').eq(1).click() - cy.get(".modal-inner-wrapper").within(() => { + cy.get(interact.MODAL_INNER_WRAPPER).within(() => { cy.wait(1000) cy.contains("Create Row").trigger('mouseover').click().click() - cy.get(".spectrum-Button--cta").click() + cy.get(interact.SPECTRUM_BUTTON_CTA).click() }) - cy.get(".spectrum-Picker-label").eq(1).click() + cy.get(interact.SPECTRUM_PICKER_LABEL).eq(1).click() cy.contains("dog").click() - cy.get(".spectrum-Textfield-input") + cy.get(interact.SPECTRUM_TEXTFIELD_INPUT) .first() .type("{{ trigger.row.name }}", { parseSpecialCharSequences: false }) - cy.get(".spectrum-Textfield-input") + cy.get(interact.SPECTRUM_TEXTFIELD_INPUT) .eq(1) .type("11") cy.contains("Finish and test automation").click() - cy.get(".modal-inner-wrapper").within(() => { + cy.get(interact.MODAL_INNER_WRAPPER).within(() => { cy.wait(1000) - cy.get(".spectrum-Picker-label").click() + cy.get(interact.SPECTRUM_PICKER_LABEL).click() cy.contains("dog").click() cy.wait(1000) - cy.get(".spectrum-Textfield-input") + cy.get(interact.SPECTRUM_TEXTFIELD_INPUT) .first() .type("automationGoodboy") - cy.get(".spectrum-Textfield-input") + cy.get(interact.SPECTRUM_TEXTFIELD_INPUT) .eq(1) .type("11") - cy.get(".spectrum-Textfield-input") + cy.get(interact.SPECTRUM_TEXTFIELD_INPUT) .eq(2) .type("123456") - cy.get(".spectrum-Textfield-input") + cy.get(interact.SPECTRUM_TEXTFIELD_INPUT) .eq(3) .type("123456") cy.contains("Test").click() diff --git a/packages/builder/cypress/integration/createTable.spec.js b/packages/builder/cypress/integration/createTable.spec.js index 4600807cbc..7d55a1f03c 100644 --- a/packages/builder/cypress/integration/createTable.spec.js +++ b/packages/builder/cypress/integration/createTable.spec.js @@ -1,4 +1,5 @@ import filterTests from "../support/filterTests" +const interact = require('../support/interact') filterTests(["smoke", "all"], () => { context("Create a Table", () => { @@ -11,7 +12,7 @@ filterTests(["smoke", "all"], () => { cy.createTable("dog") cy.wait(1000) // Check if Table exists - cy.get(".table-title h1").should("have.text", "dog") + cy.get(interact.TABLE_TITLE_H1).should("have.text", "dog") }) it("adds a new column to the table", () => { @@ -25,13 +26,13 @@ filterTests(["smoke", "all"], () => { }) it("updates a column on the table", () => { - cy.get(".title").click() - cy.get(".spectrum-Table-editIcon > use").click() - cy.get(".modal-inner-wrapper").within(() => { + cy.get(interact.TABLE_TITLE).click() + cy.get(interact.SPECTRUM_TABLE_EDIT).click() + cy.get(interact.MODAL_INNER_WRAPPER).within(() => { cy.get("input").eq(0).type("updated", { force: true }) // Unset table display column - cy.get(".spectrum-Switch-input").eq(1).click() + cy.get(interact.SPECTRUM_SWITCH_INPUT).eq(1).click() cy.contains("Save Column").click() }) cy.contains("nameupdated ").should("contain", "nameupdated") @@ -40,16 +41,16 @@ filterTests(["smoke", "all"], () => { it("edits a row", () => { cy.contains("button", "Edit").click({ force: true }) cy.wait(1000) - cy.get(".spectrum-Modal input").clear() - cy.get(".spectrum-Modal input").type("Updated") + cy.get(interact.SPECTRUM_MODAL_INPUT).clear() + cy.get(interact.SPECTRUM_MODAL_INPUT).type("Updated") cy.contains("Save").click() cy.contains("Updated").should("have.text", "Updated") }) it("deletes a row", () => { - cy.get(".spectrum-Checkbox-input").check({ force: true }) + cy.get(interact.SPECTRUM_CHECKBOX_INPUT).check({ force: true }) cy.contains("Delete 1 row(s)").click() - cy.get(".spectrum-Modal").contains("Delete").click() + cy.get(interact.SPECTRUM_MODAL).contains("Delete").click() cy.contains("RoverUpdated").should("not.exist") }) @@ -63,50 +64,50 @@ filterTests(["smoke", "all"], () => { } cy.reload() cy.wait(2000) - cy.get(".spectrum-Pagination").within(() => { - cy.get(".spectrum-ActionButton").eq(1).click() + cy.get(interact.SPECTRUM_PAGINATION).within(() => { + cy.get(interact.SPECTRUM_ACTION_BUTTON).eq(1).click() }) - cy.get(".spectrum-Pagination").within(() => { - cy.get(".spectrum-Body--secondary").contains("Page 2") + cy.get(interact.SPECTRUM_PAGINATION).within(() => { + cy.get(interact.SPECTRUM_BODY_SECOND).contains("Page 2") }) }) xit("Deletes rows and checks pagination", () => { // Delete rows, removing second page from table - cy.get(".spectrum-Checkbox-input").check({ force: true }) - cy.get(".popovers").within(() => { - cy.get(".spectrum-Button").click({ force: true }) + cy.get(interact.SPECTRUM_CHECKBOX_INPUT).check({ force: true }) + cy.get(interact.POPOVERS).within(() => { + cy.get(interact.SPECTRUM_BUTTON).click({ force: true }) }) - cy.get(".spectrum-Dialog-grid").contains("Delete").click({ force: true }) + cy.get(interact.SPECTRUM_DIALOG_GRID).contains("Delete").click({ force: true }) cy.wait(1000) // Confirm table only has one page - cy.get(".spectrum-Pagination").within(() => { - cy.get(".spectrum-ActionButton").eq(1).should("not.be.enabled") + cy.get(interact.SPECTRUM_PAGINATION).within(() => { + cy.get(interact.SPECTRUM_ACTION_BUTTON).eq(1).should("not.be.enabled") }) }) } it("deletes a column", () => { const columnName = "nameupdated" - cy.get(".title").click() - cy.get(".spectrum-Table-editIcon > use").click() + cy.get(interact.TABLE_TITLE).click() + cy.get(interact.SPECTRUM_TABLE_EDIT).click() cy.contains("Delete").click() - cy.get('[data-cy="delete-column-confirm"]').type(columnName) + cy.get(interact.DELETE_COLUMN_CONFIRM).type(columnName) cy.contains("Delete Column").click() cy.contains("nameupdated").should("not.exist") }) it("deletes a table", () => { - cy.get(".nav-item") + cy.get(interact.NAV_ITEM) .contains("dog") - .parents(".nav-item") + .parents(interact.NAV_ITEM) .first() .within(() => { - cy.get(".actions .spectrum-Icon").click({ force: true }) + cy.get(interact.ACTION_SPECTRUM_ICON).click({ force: true }) }) - cy.get(".spectrum-Menu > :nth-child(2)").click() - cy.get('[data-cy="delete-table-confirm"]').type("dog") + cy.get(interact.SPECTRUM_MENU_CHILD2).click() + cy.get(interact.DELETE_TABLE_CONFIRM).type("dog") cy.contains("Delete Table").click() cy.contains("dog").should("not.exist") }) diff --git a/packages/builder/cypress/integration/createUserAndRoles.spec.js b/packages/builder/cypress/integration/createUserAndRoles.spec.js index ac7ec1b5fd..d47a96ed8d 100644 --- a/packages/builder/cypress/integration/createUserAndRoles.spec.js +++ b/packages/builder/cypress/integration/createUserAndRoles.spec.js @@ -1,4 +1,5 @@ import filterTests from "../support/filterTests" +const interact = require('../support/interact') filterTests(["smoke", "all"], () => { context("Create a User and Assign Roles", () => { @@ -12,7 +13,7 @@ filterTests(["smoke", "all"], () => { cy.visit(`${Cypress.config().baseUrl}/builder`) cy.wait(1000) cy.createUser("bbuser@test.com") - cy.get(".spectrum-Table").should("contain", "bbuser") + cy.get(interact.SPECTRUM_TABLE).should("contain", "bbuser") }) it("should confirm there is No Access for a New User", () => { @@ -20,9 +21,9 @@ filterTests(["smoke", "all"], () => { cy.contains("bbuser").click() cy.wait(500) // Get No Access table - Confirm it has apps in it - cy.get(".spectrum-Table").eq(1).should("not.contain", "No rows found") + cy.get(interact.SPECTRUM_TABLE).eq(1).should("not.contain", "No rows found") // Get Configure Roles table - Confirm it has no apps - cy.get(".spectrum-Table").eq(0).contains("No rows found") + cy.get(interact.SPECTRUM_TABLE).eq(0).contains("No rows found") }) if (Cypress.env("TEST_ENV")) { @@ -40,7 +41,7 @@ filterTests(["smoke", "all"], () => { } else { cy.visit(`${Cypress.config().baseUrl}/builder`) cy.wait(500) - cy.get(`[data-cy="create-app-btn"]`).click({ force: true }) + cy.get(interact.CREATE_APP_BUTTON).click({ force: true }) cy.createAppFromScratch(name) } } @@ -49,35 +50,35 @@ filterTests(["smoke", "all"], () => { // Navigate back to the user cy.visit(`${Cypress.config().baseUrl}/builder`) cy.wait(500) - cy.get(".spectrum-SideNav").contains("Users").click() + cy.get(interact.SPECTRUM_SIDENAV).contains("Users").click() cy.wait(500) - cy.get(".spectrum-Table").contains("bbuser").click() + cy.get(interact.SPECTRUM_TABLE).contains("bbuser").click() cy.wait(1000) for (let i = 0; i < 3; i++) { - cy.get(".spectrum-Table", { timeout: 3000}) + cy.get(interact.SPECTRUM_TABLE, { timeout: 3000}) .eq(1) - .find(".spectrum-Table-row") + .find(interact.SPECTRUM_TABLE_ROW) .eq(0) - .find(".spectrum-Table-cell") + .find(interact.SPECTRUM_TABLE_CELL) .eq(0) .click() cy.wait(500) - cy.get(".spectrum-Dialog-grid") + cy.get(interact.SPECTRUM_DIALOG_GRID) .contains("Choose an option") .click() .then(() => { cy.wait(1000) if (i == 0) { - cy.get(".spectrum-Menu").contains("Admin").click({ force: true }) + cy.get(interact.SPECTRUM_MENU).contains("Admin").click({ force: true }) } else if (i == 1) { - cy.get(".spectrum-Menu").contains("Power").click({ force: true }) + cy.get(interact.SPECTRUM_MENU).contains("Power").click({ force: true }) } else if (i == 2) { - cy.get(".spectrum-Menu").contains("Basic").click({ force: true }) + cy.get(interact.SPECTRUM_MENU).contains("Basic").click({ force: true }) } cy.wait(1000) - cy.get(".spectrum-Button") + cy.get(interact.SPECTRUM_BUTTON) .contains("Update role") .click({ force: true }) }) @@ -85,7 +86,7 @@ filterTests(["smoke", "all"], () => { } // Confirm roles exist within Configure roles table cy.wait(2000) - cy.get(".spectrum-Table") + cy.get(interact.SPECTRUM_TABLE) .eq(0) .within(assginedRoles => { expect(assginedRoles).to.contain("Admin") @@ -96,60 +97,60 @@ filterTests(["smoke", "all"], () => { it("should unassign role types", () => { // Set each app within Configure roles table to 'No Access' - cy.get(".spectrum-Table") + cy.get(interact.SPECTRUM_TABLE) .eq(0) - .find(".spectrum-Table-row") + .find(interact.SPECTRUM_TABLE_ROW) .its("length") .then(len => { for (let i = 0; i < len; i++) { - cy.get(".spectrum-Table") + cy.get(interact.SPECTRUM_TABLE) .eq(0) - .find(".spectrum-Table-row") + .find(interact.SPECTRUM_TABLE_ROW) .eq(0) - .find(".spectrum-Table-cell") + .find(interact.SPECTRUM_TABLE_CELL) .eq(0) .click() .then(() => { - cy.get(".spectrum-Picker").eq(1).click({ force: true }) + cy.get(interact.SPECTRUM_PICKER).eq(1).click({ force: true }) cy.wait(500) - cy.get(".spectrum-Popover").contains("No Access").click() + cy.get(interact.SPECTRUM_POPOVER).contains("No Access").click() }) - cy.get(".spectrum-Button") + cy.get(interact.SPECTRUM_BUTTON) .contains("Update role") .click({ force: true }) cy.wait(1000) } }) // Confirm Configure roles table no longer has any apps in it - cy.get(".spectrum-Table").eq(0).contains("No rows found") + cy.get(interact.SPECTRUM_TABLE).eq(0).contains("No rows found") }) } it("should enable Developer access", () => { // Enable Developer access - cy.get(".field") + cy.get(interact.FIELD) .eq(4) .within(() => { - cy.get(".spectrum-Switch-input").click({ force: true }) + cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true }) }) // No Access table should now be empty - cy.get(".container") + cy.get(interact.CONTAINER) .contains("No Access") .parent() .within(() => { - cy.get(".spectrum-Table").contains("No rows found") + cy.get(interact.SPECTRUM_TABLE).contains("No rows found") }) // Each app within Configure roles should have Admin access - cy.get(".spectrum-Table") + cy.get(interact.SPECTRUM_TABLE) .eq(0) - .find(".spectrum-Table-row") + .find(interact.SPECTRUM_TABLE_ROW) .its("length") .then(len => { for (let i = 0; i < len; i++) { - cy.get(".spectrum-Table") + cy.get(interact.SPECTRUM_TABLE) .eq(0) - .find(".spectrum-Table-row") + .find(interact.SPECTRUM_TABLE_ROW) .eq(i) .contains("Admin") cy.wait(500) @@ -169,26 +170,26 @@ filterTests(["smoke", "all"], () => { .contains("Configure roles") .parent() .within(() => { - cy.get(".spectrum-Table").contains("No rows found") + cy.get(interact.SPECTRUM_TABLE).contains("No rows found") }) }) it("should delete a user", () => { // Click Delete user button - cy.get(".spectrum-Button") + cy.get(interact.SPECTRUM_BUTTON) .contains("Delete user") .click({ force: true }) .then(() => { // Confirm deletion within modal cy.wait(500) - cy.get(".spectrum-Dialog-grid").within(() => { - cy.get(".spectrum-Button") + cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => { + cy.get(interact.SPECTRUM_BUTTON) .contains("Delete user") .click({ force: true }) cy.wait(4000) }) }) - cy.get(".spectrum-Table").should("not.have.text", "bbuser") + cy.get(interact.SPECTRUM_TABLE).should("not.have.text", "bbuser") }) }) }) diff --git a/packages/builder/cypress/support/interact.js b/packages/builder/cypress/support/interact.js index 43df8eec81..4a70b2fa8c 100644 --- a/packages/builder/cypress/support/interact.js +++ b/packages/builder/cypress/support/interact.js @@ -62,3 +62,45 @@ export const GLOBESTRIKE = "svg[aria-label=GlobeStrike]" export const GLOBE = "svg[aria-label=Globe]" export const UNPUBLISH_MODAL = "[data-cy=unpublish-modal]" export const CONFIRM_WRAP_BUTTON = ".confirm-wrap button" + +//changeAppiconAndColour +export const APP_ROW_ACTION = ".app-row-actions-icon" +export const SPECTRUM_MENU = ".spectrum-Menu" +export const ICON_ITEM = ".icon-item" +export const FILL = ".fill" +export const COLOURSS = ".colors" +export const AREA_LABEL = "[aria-label]" +export const TITLE = ".title" +export const GRID = ".grid" +export const COLOUR = ".color" + +//createAutomation +export const ADD_BUTTON_SPECTRUM = ".add-button .spectrum-Icon" +export const MODAL_INNER_WRAPPER = ".modal-inner-wrapper" +export const SPECTRUM_BUTTON_CTA = ".spectrum-Button--cta" +export const SPECTRUM_TEXTFIELD_INPUT = ".spectrum-Textfield-input" + +//createTable +export const TABLE_TITLE_H1 = ".table-title h1" +export const TABLE_TITLE = ".title" +export const SPECTRUM_TABLE_EDIT = ".spectrum-Table-editIcon > use" +export const SPECTRUM_SWITCH_INPUT = ".spectrum-Switch-input" +export const SPECTRUM_CHECKBOX_INPUT = ".spectrum-Checkbox-input" +export const SPECTRUM_PAGINATION = ".spectrum-Pagination" +export const SPECTRUM_ACTION_BUTTON = ".spectrum-ActionButton" +export const SPECTRUM_BODY_SECOND = ".spectrum-Body--secondary" +export const POPOVERS = ".popovers" +export const SPECTRUM_DIALOG_GRID = ".spectrum-Dialog-grid" +export const DELETE_COLUMN_CONFIRM = '[data-cy="delete-column-confirm"]' +export const NAV_ITEM = ".nav-item" +export const ACTION_SPECTRUM_ICON = ".actions .spectrum-Icon" +export const SPECTRUM_MENU_CHILD2 = ".spectrum-Menu > :nth-child(2)" +export const DELETE_TABLE_CONFIRM = '[data-cy="delete-table-confirm"]' + +//createUSerAndRoles +export const SPECTRUM_TABLE = ".spectrum-Table" +export const SPECTRUM_SIDENAV = ".spectrum-SideNav" +export const SPECTRUM_TABLE_ROW = ".spectrum-Table-row" +export const SPECTRUM_TABLE_CELL = ".spectrum-Table-cell" +export const FIELD = ".field" +export const CONTAINER = ".container"