From 91f934b4069f232f22eeecc0e6e5ae446da426d4 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 17 May 2022 10:34:10 +0100 Subject: [PATCH] IT Ticketing System Template Tests Two tests for IT Ticketing System template - Create and publish app - Filter tickets by status (Skipped for now as functionality seems broken specifically for the CI run, looking into it...) Commands - Added new template navigation function - Added this to appropriate template test files --- .../HR/jobApplicationTracker.spec.js | 12 +-- .../templates/IT/ITTicketingSystem.spec.js | 81 +++++++++++++++++++ packages/builder/cypress/support/commands.js | 12 +++ 3 files changed, 95 insertions(+), 10 deletions(-) create mode 100644 packages/builder/cypress/integration/templates/IT/ITTicketingSystem.spec.js diff --git a/packages/builder/cypress/integration/templates/HR/jobApplicationTracker.spec.js b/packages/builder/cypress/integration/templates/HR/jobApplicationTracker.spec.js index efb9e58c75..ff6cb91bad 100644 --- a/packages/builder/cypress/integration/templates/HR/jobApplicationTracker.spec.js +++ b/packages/builder/cypress/integration/templates/HR/jobApplicationTracker.spec.js @@ -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", () => { diff --git a/packages/builder/cypress/integration/templates/IT/ITTicketingSystem.spec.js b/packages/builder/cypress/integration/templates/IT/ITTicketingSystem.spec.js new file mode 100644 index 0000000000..118625ac65 --- /dev/null +++ b/packages/builder/cypress/integration/templates/IT/ITTicketingSystem.spec.js @@ -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 }) + }) + } + }) + }) + }) +}) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index e2e3850259..5d60e7dadb 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -595,3 +595,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 }) + } + }) +})