1
0
Fork 0
mirror of synced 2024-08-09 15:17:57 +12:00

Refactoring tests

Tests:
1. AppiconAndColour
2. Automation
This commit is contained in:
MihailHadzhiev2022 2022-06-02 15:03:47 +03:00
parent 6d0ac317ce
commit 52d643c035
3 changed files with 44 additions and 25 deletions

View file

@ -1,4 +1,5 @@
import filterTests from "../support/filterTests" import filterTests from "../support/filterTests"
const interact = require('../support/interact')
filterTests(['all'], () => { filterTests(['all'], () => {
context("Change Application Icon and Colour", () => { context("Change Application Icon and Colour", () => {
@ -11,20 +12,20 @@ filterTests(['all'], () => {
cy.applicationInAppTable("Cypress Tests") cy.applicationInAppTable("Cypress Tests")
cy.get(".appTable") cy.get(".appTable")
.within(() => { .within(() => {
cy.get(".app-row-actions-icon").eq(0).click() cy.get(interact.APP_ROW_ACTION).eq(0).click()
}) })
cy.get(".spectrum-Menu").contains("Edit icon").click() cy.get(interact.SPECTRUM_MENU).contains("Edit icon").click()
// Select random icon // Select random icon
cy.get(".grid").within(() => { cy.get(interact.GRID).within(() => {
cy.get(".icon-item").eq(Math.floor(Math.random() * 23) + 1).click() cy.get(interact.ICON_ITEM).eq(Math.floor(Math.random() * 23) + 1).click()
}) })
// Select random colour // Select random colour
cy.get(".fill").click() cy.get(interact.FILL).click()
cy.get(".colors").within(() => { cy.get(interact.COLOURSS).within(() => {
cy.get(".color").eq(Math.floor(Math.random() * 33) + 1).click() cy.get(interact.COLOUR).eq(Math.floor(Math.random() * 33) + 1).click()
}) })
cy.intercept('**/applications/**').as('iconChange') cy.intercept('**/applications/**').as('iconChange')
cy.get(".spectrum-Button").contains("Save").click({ force: true }) cy.get(interact.SPECTRUM_BUTTON).contains("Save").click({ force: true })
cy.wait("@iconChange") cy.wait("@iconChange")
cy.get("@iconChange").its('response.statusCode') cy.get("@iconChange").its('response.statusCode')
.should('eq', 200) .should('eq', 200)
@ -33,9 +34,9 @@ filterTests(['all'], () => {
// Confirm colour has been applied - There is no default colour // Confirm colour has been applied - There is no default colour
cy.get(".appTable") cy.get(".appTable")
.within(() => { .within(() => {
cy.get('[aria-label]').eq(0).children() cy.get(interact.AREA_LABEL).eq(0).children()
.should('have.attr', 'xlink:href').and('not.contain', '#spectrum-icon-18-Apps') .should('have.attr', 'xlink:href').and('not.contain', '#spectrum-icon-18-Apps')
cy.get(".title").children().children() cy.get(interact.TITLE).children().children()
.should('have.attr', 'style').and('contains', 'color') .should('have.attr', 'style').and('contains', 'color')
}) })
cy.deleteAllApps() cy.deleteAllApps()

View file

@ -1,4 +1,5 @@
import filterTests from "../support/filterTests" import filterTests from "../support/filterTests"
const interact = require('../support/interact')
filterTests(['smoke', 'all'], () => { filterTests(['smoke', 'all'], () => {
context("Create a automation", () => { context("Create a automation", () => {
@ -11,51 +12,51 @@ filterTests(['smoke', 'all'], () => {
cy.createTestTableWithData() cy.createTestTableWithData()
cy.wait(2000) cy.wait(2000)
cy.contains("Automate").click() cy.contains("Automate").click()
cy.get(".add-button .spectrum-Icon").click() cy.get(interact.ADD_BUTTON_SPECTRUM).click()
cy.get(".modal-inner-wrapper").within(() => { cy.get(interact.MODAL_INNER_WRAPPER).within(() => {
cy.get("input").type("Add Row") cy.get("input").type("Add Row")
cy.contains("Row Created").click({ force: true }) cy.contains("Row Created").click({ force: true })
cy.wait(500) cy.wait(500)
cy.get(".spectrum-Button--cta").click() cy.get(interact.SPECTRUM_BUTTON_CTA).click()
}) })
// Setup trigger // Setup trigger
cy.get(".spectrum-Picker-label").click() cy.get(interact.SPECTRUM_PICKER_LABEL).click()
cy.wait(500) cy.wait(500)
cy.contains("dog").click() cy.contains("dog").click()
cy.wait(2000) cy.wait(2000)
// Create action // Create action
cy.get('[aria-label="AddCircle"]').eq(1).click() 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.wait(1000)
cy.contains("Create Row").trigger('mouseover').click().click() 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.contains("dog").click()
cy.get(".spectrum-Textfield-input") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT)
.first() .first()
.type("{{ trigger.row.name }}", { parseSpecialCharSequences: false }) .type("{{ trigger.row.name }}", { parseSpecialCharSequences: false })
cy.get(".spectrum-Textfield-input") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT)
.eq(1) .eq(1)
.type("11") .type("11")
cy.contains("Finish and test automation").click() cy.contains("Finish and test automation").click()
cy.get(".modal-inner-wrapper").within(() => { cy.get(interact.MODAL_INNER_WRAPPER).within(() => {
cy.wait(1000) cy.wait(1000)
cy.get(".spectrum-Picker-label").click() cy.get(interact.SPECTRUM_PICKER_LABEL).click()
cy.contains("dog").click() cy.contains("dog").click()
cy.wait(1000) cy.wait(1000)
cy.get(".spectrum-Textfield-input") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT)
.first() .first()
.type("automationGoodboy") .type("automationGoodboy")
cy.get(".spectrum-Textfield-input") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT)
.eq(1) .eq(1)
.type("11") .type("11")
cy.get(".spectrum-Textfield-input") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT)
.eq(2) .eq(2)
.type("123456") .type("123456")
cy.get(".spectrum-Textfield-input") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT)
.eq(3) .eq(3)
.type("123456") .type("123456")
cy.contains("Test").click() cy.contains("Test").click()

View file

@ -58,3 +58,20 @@ export const GLOBESTRIKE = "svg[aria-label=GlobeStrike]"
export const GLOBE = "svg[aria-label=Globe]" export const GLOBE = "svg[aria-label=Globe]"
export const UNPUBLISH_MODAL = "[data-cy=unpublish-modal]" export const UNPUBLISH_MODAL = "[data-cy=unpublish-modal]"
export const CONFIRM_WRAP_BUTTON = ".confirm-wrap button" 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"