1
0
Fork 0
mirror of synced 2024-07-15 11:15:59 +12:00

Merge pull request #5928 from Budibase/cypress-testing

IT Ticketing System Template + Smoke build test changes
This commit is contained in:
Mitch-Budibase 2022-05-17 15:56:34 +01:00 committed by GitHub
commit 24db941693
5 changed files with 109 additions and 13 deletions

View file

@ -123,6 +123,7 @@ filterTests(['smoke', 'all'], () => {
cy.applicationInAppTable("Teds app")
cy.deleteApp("Teds app")
cy.wait(2000)
//Accomodate names that end in 'S'
cy.updateUserInformation("Chris", "Userman")
@ -134,6 +135,7 @@ filterTests(['smoke', 'all'], () => {
cy.applicationInAppTable("Chris app")
cy.deleteApp("Chris app")
cy.wait(2000)
cy.updateUserInformation("", "")
})

View file

@ -4,6 +4,8 @@ filterTests(["smoke", "all"], () => {
context("Create a User and Assign Roles", () => {
before(() => {
cy.login()
cy.deleteApp("Cypress Tests")
cy.createApp("Cypress Tests")
})
it("should create a user", () => {
@ -52,7 +54,7 @@ filterTests(["smoke", "all"], () => {
cy.get(".spectrum-Table").contains("bbuser").click()
cy.wait(1000)
for (let i = 0; i < 3; i++) {
cy.get(".spectrum-Table")
cy.get(".spectrum-Table", { timeout: 3000})
.eq(1)
.find(".spectrum-Table-row")
.eq(0)
@ -79,6 +81,7 @@ filterTests(["smoke", "all"], () => {
.contains("Update role")
.click({ force: true })
})
cy.reload()
}
// Confirm roles exist within Configure roles table
cy.wait(2000)

View file

@ -1,7 +1,7 @@
import filterTests from "../../../support/filterTests"
filterTests(["all"], () => {
context("Job Application Functionality", () => {
context("Job Application Tracker Template Functionality", () => {
const templateName = "Job Application Tracker"
const templateNameParsed = templateName.toLowerCase().replace(/\s+/g, '-')
@ -14,15 +14,7 @@ filterTests(["all"], () => {
}
})
cy.wait(2000)
// Template navigation
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
.its("body")
.then(val => {
if (val.length > 0) {
cy.get(".spectrum-Button").contains("Templates").click({force: true})
}
})
cy.templateNavigation()
})
it("should create and publish app with Job Application Tracker template", () => {

View file

@ -0,0 +1,81 @@
import filterTests from "../../../support/filterTests"
filterTests(["all"], () => {
context("IT Ticketing System Template Functionality", () => {
const templateName = "IT Ticketing System"
const templateNameParsed = templateName.toLowerCase().replace(/\s+/g, '-')
before(() => {
cy.login()
cy.deleteApp(templateName)
cy.visit(`${Cypress.config().baseUrl}/builder`, {
onBeforeLoad(win) {
cy.stub(win, 'open')
}
})
cy.wait(2000)
cy.templateNavigation()
})
it("should create and publish app with IT Ticketing System template", () => {
// Select IT Ticketing System template
cy.get(".template-thumbnail-text")
.contains(templateName).parentsUntil(".template-grid").within(() => {
cy.get(".spectrum-Button").contains("Use template").click({ force: true })
})
// Confirm URL matches template name
const appUrl = cy.get(".app-server")
appUrl.invoke('text').then(appUrlText => {
expect(appUrlText).to.equal(`${Cypress.config().baseUrl}/app/` + templateNameParsed)
})
// Create App
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Button").contains("Create app").click({ force: true })
})
// Publish App
cy.wait(2000) // Wait for app to generate
cy.get(".toprightnav").contains("Publish").click({ force: true })
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Button").contains("Publish").click({ force: true })
})
// Verify Published app
cy.wait(2000) // Wait for App to publish and modal to appear
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Button").contains("View App").click({ force: true })
cy.window().its('open').should('be.calledOnce')
})
})
xit("should filter tickets by status", () => {
// Visit published app
cy.visit(`${Cypress.config().baseUrl}/app/` + templateNameParsed)
cy.wait(1000)
// Tickets section
cy.get(".links").contains("Tickets").click({ force: true })
cy.wait(1000)
// Filter by stage - Confirm table updates
cy.get(".spectrum-Picker").contains("Filter by status").click({ force: true })
cy.get(".spectrum-Menu").find('li').its('length').then(len => {
for (let i = 1; i < len; i++) {
cy.get(".spectrum-Menu-item").eq(i).click()
const stage = cy.get(".spectrum-Picker-label")
stage.invoke('text').then(stageText => {
if (stageText == "In progress" || stageText == "On hold" || stageText == "Triaged") {
cy.get(".placeholder").should('contain', 'No rows found')
}
else {
cy.get(".spectrum-Table-row").should('contain', stageText)
}
cy.get(".spectrum-Picker").contains(stageText).click({ force: true })
})
}
})
})
})
})

View file

@ -524,7 +524,12 @@ Cypress.Commands.add("createAppFromScratch", appName => {
.contains("Start from scratch")
.click({ force: true })
cy.get(".spectrum-Modal").within(() => {
cy.get("input").eq(0).type(appName).should("have.value", appName).blur()
cy.get("input")
.eq(0)
.clear()
.type(appName)
.should("have.value", appName)
.blur()
cy.get(".spectrum-ButtonGroup").contains("Create app").click()
cy.wait(10000)
})
@ -642,7 +647,8 @@ Cypress.Commands.add("addDatasourceConfig", (datasource, skipFetch) => {
cy.get(".spectrum-Button")
.contains("Save and fetch tables")
.click({ force: true })
cy.wait(3000)
// Check modal closes after datasource config & fetch
cy.get(".spectrum-Dialog-grid", { timeout: 7000 }).should("not.exist")
})
}
})
@ -664,3 +670,15 @@ Cypress.Commands.add("createRestQuery", (method, restUrl, queryPrettyName) => {
.should("contain", method)
.and("contain", queryPrettyName)
})
Cypress.Commands.add("templateNavigation", () => {
// Navigates to templates section
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
.its("body")
.then(val => {
// Templates button needs clicked if apps already exist
if (val.length > 0) {
cy.get(".spectrum-Button").contains("Templates").click({ force: true })
}
})
})