Merge pull request #9392 from Budibase/cypress

Cypress - New Portal Test Updates
This commit is contained in:
Mitch-Budibase 2023-01-19 19:57:06 +00:00 committed by GitHub
commit 7605d8ba1a
6 changed files with 146 additions and 128 deletions

View File

@ -11,9 +11,5 @@
"WORKER_PORT": "4200",
"JWT_SECRET": "test",
"HOST_IP": ""
},
"retries": {
"runMode": 1,
"openMode": 0
}
}

View File

@ -2,7 +2,7 @@ import filterTests from "../../support/filterTests"
// const interact = require("../support/interact")
filterTests(["smoke", "all"], () => {
context("Auth Configuration", () => {
xcontext("Auth Configuration", () => {
before(() => {
cy.login()
})
@ -21,7 +21,7 @@ filterTests(["smoke", "all"], () => {
cy.get("[data-cy=oidc-active]").should('not.be.checked')
cy.intercept("POST", "/api/global/configs").as("updateAuth")
cy.get("button[data-cy=oidc-save]").contains("Save").click({force: true})
cy.get("button[data-cy=oidc-save]").contains("Save").click({ force: true })
cy.wait("@updateAuth")
cy.get("@updateAuth").its("response.statusCode").should("eq", 200)
@ -45,7 +45,7 @@ filterTests(["smoke", "all"], () => {
cy.get("button[data-cy=oidc-save]").should("not.be.disabled");
cy.intercept("POST", "/api/global/configs").as("updateAuth")
cy.get("button[data-cy=oidc-save]").contains("Save").click({force: true})
cy.get("button[data-cy=oidc-save]").contains("Save").click({ force: true })
cy.wait("@updateAuth")
cy.get("@updateAuth").its("response.statusCode").should("eq", 200)
@ -85,11 +85,11 @@ filterTests(["smoke", "all"], () => {
cy.get(".auth-form input.spectrum-Textfield-input").type("Another ")
cy.get(".spectrum-Tags").find(".spectrum-Tags-item").its("length").should("eq", 6)
cy.get(".spectrum-Tags-item").contains("Another")
cy.get("button[data-cy=oidc-save]").should("not.be.disabled");
cy.intercept("POST", "/api/global/configs").as("updateAuth")
cy.get("button[data-cy=oidc-save]").contains("Save").click({force: true})
cy.get("button[data-cy=oidc-save]").contains("Save").click({ force: true })
cy.wait("@updateAuth")
cy.get("@updateAuth").its("response.statusCode").should("eq", 200)
@ -123,7 +123,7 @@ filterTests(["smoke", "all"], () => {
cy.get("button[data-cy=oidc-save]").should("not.be.disabled");
cy.intercept("POST", "/api/global/configs").as("updateAuth")
cy.get("button[data-cy=oidc-save]").contains("Save").click({force: true})
cy.get("button[data-cy=oidc-save]").contains("Save").click({ force: true })
cy.wait("@updateAuth")
cy.get("@updateAuth").its("response.statusCode").should("eq", 200)
@ -144,7 +144,7 @@ filterTests(["smoke", "all"], () => {
cy.get("div.content").scrollTo("bottom")
cy.get("[data-cy=restore-oidc-default-scopes]").click({force: true})
cy.get("[data-cy=restore-oidc-default-scopes]").click({ force: true })
cy.get(".spectrum-Tags").find(".spectrum-Tags-item").its("length").should("eq", 4)

View File

@ -3,107 +3,112 @@ const interact = require('../../support/interact')
filterTests(["smoke", "all"], () => {
context("User Settings Menu", () => {
before(() => {
cy.login()
})
it("should update user information via user settings menu", () => {
const fname = "test"
const lname = "user"
const fname = "test"
const lname = "user"
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.updateUserInformation(fname, lname)
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.updateUserInformation(fname, lname)
// Go to user info and confirm name update
cy.contains("Users").click()
cy.contains("test@test.com").click()
// Go to user info and confirm name update
cy.contains("Users").click()
cy.contains("test@test.com").click()
cy.get(interact.FIELD, { timeout: 1000 }).eq(1).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', fname)
})
cy.get(interact.FIELD).eq(2).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', lname)
})
cy.get(interact.FIELD, { timeout: 1000 }).eq(1).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', fname)
})
cy.get(interact.FIELD).eq(2).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', lname)
})
})
it("should allow copying of the users API key", () => {
cy.get(".user-dropdown .avatar > .icon", { timeout: 2000 }).click({ force: true })
cy.get(interact.SPECTRUM_MENU_ITEM).contains("View API key").click({ force: true })
cy.get(interact.SPECTRUM_DIALOG_CONTENT).within(() => {
cy.get(interact.SPECTRUM_ICON).click({force: true})
})
// There may be timing issues with this on the smoke build
cy.wait(500)
cy.get(".spectrum-Toast-content")
xit("should allow copying of the users API key", () => {
cy.get(".user-dropdown .avatar > .icon", { timeout: 2000 }).click({ force: true })
cy.get(interact.SPECTRUM_MENU_ITEM).contains("View API key").click({ force: true })
cy.get(interact.SPECTRUM_DIALOG_CONTENT).within(() => {
cy.get(interact.SPECTRUM_ICON).click({ force: true })
})
// There may be timing issues with this on the smoke build
cy.wait(500)
cy.get(".spectrum-Toast-content")
.contains("URL copied to clipboard")
.should("be.visible")
})
it("should allow API key regeneration", () => {
// Get initial API key value
cy.get(interact.SPECTRUM_DIALOG_CONTENT)
cy.get(".user-dropdown .icon", { timeout: 2000 }).click({ force: true })
cy.get(interact.SPECTRUM_MENU_ITEM).contains("View API key").click({ force: true })
cy.get(interact.SPECTRUM_DIALOG_CONTENT).within(() => {
cy.get(interact.SPECTRUM_ICON).click({ force: true })
})
// Get initial API key value
cy.get(interact.SPECTRUM_DIALOG_CONTENT)
.find(interact.SPECTRUM_TEXTFIELD_INPUT).invoke('val').as('keyOne')
// Click re-generate key button
cy.get("button").contains("Re-generate key").click({ force: true })
// Click re-generate key button
cy.get("button").contains("Regenerate key").click({ force: true })
// Verify API key was changed
cy.get(interact.SPECTRUM_DIALOG_CONTENT).within(() => {
cy.get('@keyOne').then((keyOne) => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).invoke('val').should('not.eq', keyOne)
})
// Verify API key was changed
cy.get(interact.SPECTRUM_DIALOG_CONTENT).within(() => {
cy.get('@keyOne').then((keyOne) => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).invoke('val').should('not.eq', keyOne)
})
cy.closeModal()
})
cy.closeModal()
})
it("should update password", () => {
// Access Update password modal
cy.get(".user-dropdown .avatar > .icon", { timeout: 2000 }).click({ force: true })
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Update password").click({ force: true })
// Access Update password modal
cy.get(".user-dropdown .icon", { timeout: 2000 }).click({ force: true })
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Update password").click({ force: true })
// Enter new password and update
cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => {
for (let i = 0; i < 2; i++) {
// password set to 'newpwd'
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).eq(i).type("newpwd")
}
cy.get("button").contains("Update password").click({ force: true })
})
// Enter new password and update
cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => {
for (let i = 0; i < 2; i++) {
// password set to 'newpwd'
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).eq(i).type("newpwd")
}
cy.get("button").contains("Update password").click({ force: true })
})
// Logout & in with new password
//cy.logOut()
cy.login("test@test.com", "newpwd")
// Logout & in with new password
//cy.logOut()
cy.login("test@test.com", "newpwd")
})
it("should open and close developer mode", () => {
cy.get(".user-dropdown .avatar > .icon", { timeout: 2000 }).click({ force: true })
// Close developer mode & verify
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Close developer mode").click({ force: true })
cy.get(interact.SPECTRUM_SIDENAV).should('not.exist') // No config sections
cy.get(interact.CREATE_APP_BUTTON).should('not.exist') // No create app button
cy.get(".app").should('not.exist') // At least one app should be available
xit("should open and close developer mode", () => {
cy.get(".user-dropdown .icon", { timeout: 2000 }).click({ force: true })
// Open developer mode & verify
cy.get(".avatar > .icon").click({ force: true })
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Open developer mode").click({ force: true })
cy.get(interact.SPECTRUM_SIDENAV).should('exist') // config sections available
cy.get(interact.CREATE_APP_BUTTON).should('exist') // create app button available
// Close developer mode & verify
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Close developer mode").click({ force: true })
cy.get(interact.SPECTRUM_SIDENAV).should('not.exist') // No config sections
cy.get(interact.CREATE_APP_BUTTON).should('not.exist') // No create app button
cy.get(".app").should('not.exist') // At least one app should be available
// Open developer mode & verify
cy.get(".avatar > .icon").click({ force: true })
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Open developer mode").click({ force: true })
cy.get(".app-table").should('exist') // config sections available
cy.get(interact.CREATE_APP_BUTTON).should('exist') // create app button available
})
after(() => {
// Change password back to original value
cy.get(".user-dropdown .avatar > .icon", { timeout: 2000 }).click({ force: true })
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Update password").click({ force: true })
cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => {
for (let i = 0; i < 2; i++) {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).eq(i).type("test")
}
cy.get("button").contains("Update password").click({ force: true })
})
// Remove users name
cy.updateUserInformation()
// Change password back to original value
cy.get(".user-dropdown .icon", { timeout: 2000 }).click({ force: true })
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Update password").click({ force: true })
cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => {
for (let i = 0; i < 2; i++) {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).eq(i).type("test")
}
cy.get("button").contains("Update password").click({ force: true })
})
// Remove users name
cy.updateUserInformation()
})
})
})

View File

@ -2,7 +2,7 @@ import filterTests from "../support/filterTests"
import clientPackage from "@budibase/client/package.json"
filterTests(["all"], () => {
context("Application Overview screen", () => {
xcontext("Application Overview screen", () => {
before(() => {
cy.login()
cy.deleteAllApps()

View File

@ -14,15 +14,15 @@ filterTests(['smoke', 'all'], () => {
cy.visit(`${Cypress.config().baseUrl}/builder/portal/apps/create`, { timeout: 5000 }) //added /portal/apps/create
cy.wait(1000)
cy.get(interact.CREATE_APP_BUTTON, { timeout: 10000 }).contains('Start from scratch').should("exist")
cy.get(interact.TEMPLATE_CATEGORY_FILTER).should("exist")
cy.get(interact.TEMPLATE_CATEGORY).should("exist")
cy.get(interact.APP_TABLE).should("not.exist")
})
}
it("should provide filterable templates", () => {
xit("should provide filterable templates", () => {
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 5000 })
cy.wait(500)
@ -30,16 +30,16 @@ filterTests(['smoke', 'all'], () => {
.its("body")
.then(val => {
if (val.length > 0) {
cy.get(interact.SPECTRUM_BUTTON).contains("Templates").click({force: true})
cy.get(interact.SPECTRUM_BUTTON).contains("View Templates").click({ force: true })
}
})
cy.get(interact.TEMPLATE_CATEGORY_FILTER).should("exist")
cy.get(interact.TEMPLATE_CATEGORY).should("exist")
cy.get(interact.TEMPLATE_CATEGORY_ACTIONGROUP).its('length').should('be.gt', 1)
cy.get(interact.TEMPLATE_CATEGORY_FILTER_ACTIONBUTTON).its('length').should('be.gt', 2)
cy.get(interact.TEMPLATE_CATEGORY_FILTER_ACTIONBUTTON).eq(1).click()
cy.get(interact.TEMPLATE_CATEGORY_ACTIONGROUP).should('have.length', 1)
@ -104,14 +104,14 @@ filterTests(['smoke', 'all'], () => {
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 5000 })
cy.updateUserInformation("Ted", "Userman")
cy.createApp("", false)
cy.applicationInAppTable("Teds app")
cy.deleteApp("Teds app")
// Accomodate names that end in 'S'
cy.updateUserInformation("Chris", "Userman")
cy.createApp("", false)
cy.applicationInAppTable("Chris app")
cy.deleteApp("Chris app")
@ -123,35 +123,49 @@ filterTests(['smoke', 'all'], () => {
const exportedApp = 'cypress/fixtures/exported-app.txt'
cy.importApp(exportedApp, "")
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 2000 })
cy.applicationInAppTable("My app")
cy.get(".appTable .name").eq(0).click()
cy.deleteApp("My app")
cy.get(".app-table .name").eq(0).click()
cy.closeModal()
cy.get(`[aria-label="ShowMenu"]`).click()
cy.get(".spectrum-Menu").within(() => {
cy.contains("Overview").click()
})
cy.get(".app-overview-actions-icon").within(() => {
cy.get(".spectrum-Icon").click({ force: true })
})
cy.get(".spectrum-Menu").contains("Delete").click({ force: true })
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get("input").type("My app")
})
cy.get(".spectrum-Button--warning").click()
})
it("should create an application from an export, using the users first name as the default app name", () => {
const exportedApp = 'cypress/fixtures/exported-app.txt'
cy.updateUserInformation("Ted", "Userman")
cy.importApp(exportedApp, "")
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.applicationInAppTable("Teds app")
cy.get(".appTable .name").eq(0).click()
cy.deleteApp("Teds app")
cy.get(".app-table .name").eq(0).click()
cy.closeModal()
cy.get(`[aria-label="ShowMenu"]`).click()
cy.get(".spectrum-Menu").within(() => {
cy.contains("Overview").click()
})
cy.get(".app-overview-actions-icon").within(() => {
cy.get(".spectrum-Icon").click({ force: true })
})
cy.get(".spectrum-Menu").contains("Delete").click({ force: true })
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get("input").type("Teds app")
})
cy.get(".spectrum-Button--warning").click()
cy.updateUserInformation("", "")
})
it("should generate the first application from a template", () => {
xit("should generate the first application from a template", () => {
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(500)
@ -172,28 +186,28 @@ filterTests(['smoke', 'all'], () => {
const card = cy.get('.template-card').eq(0).should("exist");
const cardOverlay = card.get('.template-thumbnail-action-overlay').should("exist")
cardOverlay.invoke("show")
cardOverlay.get("button").contains("Use template").should("exist").click({force: true})
cardOverlay.get("button").contains("Use template").should("exist").click({ force: true })
})
// CMD Create app from theme card
cy.get(".spectrum-Modal").should('be.visible')
const templateName = cy.get(".spectrum-Modal .template-thumbnail-text")
templateName.invoke('text')
.then(templateNameText => {
const templateNameParsed = "/"+templateNameText.toLowerCase().replace(/\s+/g, "-")
cy.get(interact.SPECTRUM_MODAL_INPUT).eq(0).should("have.value", templateNameText)
cy.get(interact.SPECTRUM_MODAL_INPUT).eq(1).should("have.value", templateNameParsed)
.then(templateNameText => {
const templateNameParsed = "/" + templateNameText.toLowerCase().replace(/\s+/g, "-")
cy.get(interact.SPECTRUM_MODAL_INPUT).eq(0).should("have.value", templateNameText)
cy.get(interact.SPECTRUM_MODAL_INPUT).eq(1).should("have.value", templateNameParsed)
cy.get(".spectrum-Modal .spectrum-ButtonGroup").contains("Create app").click()
cy.wait(5000)
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(2000)
cy.get(".spectrum-Modal .spectrum-ButtonGroup").contains("Create app").click()
cy.wait(5000)
cy.applicationInAppTable(templateNameText)
cy.deleteApp(templateNameText)
});
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(2000)
cy.applicationInAppTable(templateNameText)
cy.deleteApp(templateNameText)
});
})
@ -217,5 +231,5 @@ filterTests(['smoke', 'all'], () => {
cy.deleteApp(secondAppName)
})
})
})
})

View File

@ -101,7 +101,7 @@ Cypress.Commands.add("deleteUser", email => {
})
Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
cy.get(".user-dropdown .avatar > .icon", { timeout: 2000 }).click({
cy.get(".user-dropdown .icon", { timeout: 2000 }).click({
force: true,
})
@ -132,7 +132,7 @@ Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
.blur()
}
cy.get(".confirm-wrap").within(() => {
cy.get("button").contains("Update information").click({ force: true })
cy.get("button").contains("Save").click({ force: true })
})
cy.get(".spectrum-Dialog-grid").should("not.exist")
})
@ -222,9 +222,12 @@ Cypress.Commands.add("deleteApp", name => {
// Go to app overview
const appIdParsed = appId.split("_").pop()
const actionEleId = `[data-cy=row_actions_${appIdParsed}]`
cy.get(actionEleId).within(() => {
cy.contains("Manage").click({ force: true })
cy.get(actionEleId).click()
cy.get(`[aria-label="ShowMenu"]`).click()
cy.get(".spectrum-Menu").within(() => {
cy.contains("Overview").click()
})
cy.wait(500)
// Unpublish first if needed
@ -400,7 +403,7 @@ Cypress.Commands.add("searchForApplication", appName => {
return
} else {
// Searches for the app
cy.get(".filter").then(() => {
cy.get(".spectrum-Search").then(() => {
cy.get(".spectrum-Textfield").within(() => {
cy.get("input").eq(0).clear({ force: true })
cy.get("input").eq(0).type(appName, { force: true })
@ -413,7 +416,7 @@ Cypress.Commands.add("searchForApplication", appName => {
// Assumes there are no others
Cypress.Commands.add("applicationInAppTable", appName => {
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 30000 })
cy.get(".appTable", { timeout: 30000 }).within(() => {
cy.get(".app-table", { timeout: 30000 }).within(() => {
cy.get(".title").contains(appName).should("exist")
})
})