Edit User Details Test + Timeout Changes for Commands

New user test
- Edits user details (for now just adds first name and last name)

Commands updated
- Removing some waits and replacing with timeouts associated with 'get' Cypress functionality
This commit is contained in:
Mitch-Budibase 2022-06-08 18:08:45 +01:00
parent 56d3b46366
commit ccc584bdf2
2 changed files with 46 additions and 29 deletions

View File

@ -19,9 +19,8 @@ filterTests(["smoke", "all"], () => {
it("should confirm there is No Access for a New User", () => {
// Click into the user
cy.contains("bbuser").click()
cy.wait(500)
// Get No Access table - Confirm it has apps in it
cy.get(interact.SPECTRUM_TABLE).eq(1).should("not.contain", "No rows found")
cy.get(interact.SPECTRUM_TABLE, { timeout: 500 }).eq(1).should("not.contain", "No rows found")
// Get Configure Roles table - Confirm it has no apps
cy.get(interact.SPECTRUM_TABLE).eq(0).contains("No rows found")
})
@ -40,8 +39,7 @@ filterTests(["smoke", "all"], () => {
cy.createApp(name)
} else {
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(500)
cy.get(interact.CREATE_APP_BUTTON).click({ force: true })
cy.get(interact.CREATE_APP_BUTTON, { timeout: 1000 }).click({ force: true })
cy.createAppFromScratch(name)
}
}
@ -174,6 +172,29 @@ filterTests(["smoke", "all"], () => {
})
})
it("Should edit user details", () => {
// Add First name
cy.get(".field").eq(2).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).type("bb")
})
// Add Last name
cy.get(".field").eq(3).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).type("test")
})
// Navigate away and back to the user
cy.contains("Apps").click()
cy.contains("Users").click()
cy.contains("bbuser").click()
// Confirm details have been saved
cy.get(".field").eq(2).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "bb")
})
cy.get(".field").eq(3).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "test")
})
})
it("should delete a user", () => {
// Click Delete user button
cy.get(interact.SPECTRUM_BUTTON)

View File

@ -96,8 +96,7 @@ Cypress.Commands.add("createApp", (name, addDefaultTable) => {
typeof addDefaultTable != "boolean" ? true : addDefaultTable
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(1000)
cy.get(`[data-cy="create-app-btn"]`).click({ force: true })
cy.get(`[data-cy="create-app-btn"]`, { timeout: 1000 }).click({ force: true })
// If apps already exist
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
@ -286,9 +285,10 @@ Cypress.Commands.add("importApp", (exportFilePath, name) => {
.then(val => {
if (val.length > 0) {
cy.get(`[data-cy="create-app-btn"]`).click({ force: true })
cy.wait(500)
}
cy.get(`[data-cy="import-app-btn"]`).click({ force: true })
cy.get(`[data-cy="import-app-btn"]`, { timeout: 500 }).click({
force: true,
})
})
cy.get(".spectrum-Modal").within(() => {
@ -363,16 +363,14 @@ Cypress.Commands.add("createTable", (tableName, initialTable) => {
cy.navigateToDataSection()
cy.get(`[data-cy="new-table"]`).click()
}
cy.wait(5000)
cy.get(".spectrum-Dialog-grid")
cy.get(".spectrum-Dialog-grid", { timeout: 5000 })
.contains("Budibase DB")
.click({ force: true })
.then(() => {
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
})
cy.get(".spectrum-Modal").within(() => {
cy.wait(1000)
cy.get("input").first().type(tableName).blur()
cy.get("input", { timeout: 1000 }).first().type(tableName).blur()
cy.get(".spectrum-ButtonGroup").contains("Create").click()
})
cy.contains(tableName).should("be.visible")
@ -454,8 +452,7 @@ Cypress.Commands.add("addCustomSourceOptions", totalOptions => {
.contains("Add Option")
.click({ force: true })
.then(() => {
cy.wait(500)
cy.get("[placeholder='Label']").eq(i).type(i)
cy.get("[placeholder='Label']", { timeout: 500 }).eq(i).type(i)
cy.get("[placeholder='Value']").eq(i).type(i)
})
}
@ -499,15 +496,13 @@ Cypress.Commands.add("createScreen", (route, accessLevelLabel) => {
cy.get(".spectrum-Modal").within(() => {
cy.get("[data-cy='blank-screen']").click()
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
cy.wait(500)
})
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => {
cy.get(".spectrum-Form-itemField").eq(0).type(route)
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
cy.wait(1000)
})
cy.get(".spectrum-Modal").within(() => {
cy.get(".spectrum-Modal", { timeout: 1000 }).within(() => {
if (accessLevelLabel) {
cy.get(".spectrum-Picker-label").click()
cy.wait(500)
@ -525,9 +520,10 @@ Cypress.Commands.add(
cy.get(".spectrum-Modal").within(() => {
cy.get(".item").contains("Autogenerated screens").click()
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
cy.wait(500)
})
cy.get(".spectrum-Modal [data-cy='data-source-modal']").within(() => {
cy.get(".spectrum-Modal [data-cy='data-source-modal']", {
timeout: 500,
}).within(() => {
for (let i = 0; i < datasourceNames.length; i++) {
cy.get(".data-source-entry").contains(datasourceNames[i]).click()
//Ensure the check mark is visible
@ -577,7 +573,7 @@ Cypress.Commands.add(
// NAVIGATION
Cypress.Commands.add("navigateToFrontend", () => {
// Clicks on Design tab and then the Home nav item
cy.wait(1000)
cy.wait(500)
cy.contains("Design").click()
cy.get(".spectrum-Search").type("/")
cy.get(".nav-item").contains("home").click()
@ -609,8 +605,7 @@ Cypress.Commands.add("selectExternalDatasource", datasourceName => {
cy.get(".add-button").click()
})
// Clicks specified datasource & continue
cy.wait(1000)
cy.get(".item-list").contains(datasourceName).click()
cy.get(".item-list", { timeout: 1000 }).contains(datasourceName).click()
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
})
@ -621,8 +616,7 @@ Cypress.Commands.add("addDatasourceConfig", (datasource, skipFetch) => {
// Adds the config for specified datasource & fetches tables
// Currently supports MySQL, PostgreSQL, Oracle
// Host IP Address
cy.wait(500)
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => {
cy.get(".form-row")
.eq(0)
.within(() => {
@ -722,16 +716,18 @@ Cypress.Commands.add("addDatasourceConfig", (datasource, skipFetch) => {
Cypress.Commands.add("createRestQuery", (method, restUrl, queryPrettyName) => {
// addExternalDatasource should be called prior to this
// Configures REST datasource & sends query
cy.wait(1000)
cy.get(".spectrum-Button").contains("Add query").click({ force: true })
cy.get(".spectrum-Button", { timeout: 1000 })
.contains("Add query")
.click({ force: true })
// Select Method & add Rest URL
cy.get(".spectrum-Picker-label").eq(1).click()
cy.get(".spectrum-Menu").contains(method).click()
cy.get("input").clear().type(restUrl)
// Send query
cy.get(".spectrum-Button").contains("Send").click({ force: true })
cy.wait(500)
cy.get(".spectrum-Button").contains("Save").click({ force: true })
cy.get(".spectrum-Button", { timeout: 500 })
.contains("Save")
.click({ force: true })
cy.get(".hierarchy-items-container")
.should("contain", method)
.and("contain", queryPrettyName)