From cafd2504e6ac863d2d5e53f2cd5b601a03681fe9 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Wed, 4 May 2022 17:06:27 +0100 Subject: [PATCH] Job Application Template Test jobApplicationTracker.spec.js - New file and test - Creates and publishes Job Application Tracker app. Also verifies View URL button works commands.js - Updated deleteApp function --- .../HR/jobApplicationTracker.spec.js | 61 +++++++++++++++++++ packages/builder/cypress/support/commands.js | 16 ++--- 2 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 packages/builder/cypress/integration/templates/HR/jobApplicationTracker.spec.js diff --git a/packages/builder/cypress/integration/templates/HR/jobApplicationTracker.spec.js b/packages/builder/cypress/integration/templates/HR/jobApplicationTracker.spec.js new file mode 100644 index 0000000000..091cf1253e --- /dev/null +++ b/packages/builder/cypress/integration/templates/HR/jobApplicationTracker.spec.js @@ -0,0 +1,61 @@ +import filterTests from "../../../support/filterTests" + +filterTests(["all"], () => { + context("Job Application Functionality", () => { + const templateName = "Job Application Tracker" + 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) + + // 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}) + } + }) + }) + + it("should create and publish app with Job Application Tracker template", () => { + // Select Job Application Tracker 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') + }) + }) + }) +}) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 969486364a..4595bb73a3 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -94,19 +94,21 @@ Cypress.Commands.add("deleteApp", name => { cy.get(actionEleId).within(() => { cy.get(".spectrum-Icon").eq(0).click() }) - cy.get(".spectrum-Menu").then($menu => { if ($menu.text().includes("Unpublish")) { cy.get(".spectrum-Menu").contains("Unpublish").click() cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click() - } else { - cy.get(".spectrum-Menu").contains("Delete").click() - cy.get(".spectrum-Dialog-grid").within(() => { - cy.get("input").type(name) - }) - cy.get(".spectrum-Button--warning").click() } }) + + cy.get(actionEleId).within(() => { + cy.get(".spectrum-Icon").eq(0).click() + }) + cy.get(".spectrum-Menu").contains("Delete").click() + cy.get(".spectrum-Dialog-grid").within(() => { + cy.get("input").type(name) + }) + cy.get(".spectrum-Button--warning").click() } else { return }