From e1c4dc3981ebe2428be5cfff44a546d83c89237f Mon Sep 17 00:00:00 2001 From: andreastanderen <71079896+standeren@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:14:36 +0200 Subject: [PATCH] Delete apps after instead of before for test specs (#11284) --- .../cypress/src/integration/studio/dashboard.js | 10 ++++++---- .../cypress/src/integration/studio/datamodel.js | 6 ++---- .../testing/cypress/src/integration/studio/designer.js | 8 +++++--- .../testing/cypress/src/integration/studio/login.js | 1 + .../testing/cypress/src/integration/studio/new-app.js | 1 - .../testing/cypress/src/integration/studio/repos.js | 9 +++++---- .../testing/cypress/src/integration/studio/sync-app.js | 8 +++++--- .../testing/cypress/src/integration/studio/wcag.js | 10 ++++++---- 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/frontend/testing/cypress/src/integration/studio/dashboard.js b/frontend/testing/cypress/src/integration/studio/dashboard.js index ac3e0a7885c..1609376bc76 100644 --- a/frontend/testing/cypress/src/integration/studio/dashboard.js +++ b/frontend/testing/cypress/src/integration/studio/dashboard.js @@ -9,10 +9,8 @@ import { common } from '../../selectors/common'; context('Dashboard', () => { before(() => { cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); - cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')).then(() => { - cy.createApp(Cypress.env('autoTestUser'), 'auto-app'); - cy.createApp(Cypress.env('autoTestUser'), 'test-app'); - }); + cy.createApp(Cypress.env('autoTestUser'), 'auto-app'); + cy.createApp(Cypress.env('autoTestUser'), 'test-app'); }); beforeEach(() => { @@ -23,6 +21,10 @@ context('Dashboard', () => { cy.wait('@fetchApps').its('response.statusCode').should('eq', 200); }); + after(() => { + cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')); + }); + it('does not have broken links', () => { cy.findAllByRole('link').each(link => { if (link.prop('href')) diff --git a/frontend/testing/cypress/src/integration/studio/datamodel.js b/frontend/testing/cypress/src/integration/studio/datamodel.js index ade00df415a..848e9696e1e 100644 --- a/frontend/testing/cypress/src/integration/studio/datamodel.js +++ b/frontend/testing/cypress/src/integration/studio/datamodel.js @@ -7,10 +7,8 @@ import * as texts from '../../../../../language/src/nb.json'; context('datamodel', () => { before(() => { - cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')).then(() => { - cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); - cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); - }); + cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); + cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); }); beforeEach(() => { diff --git a/frontend/testing/cypress/src/integration/studio/designer.js b/frontend/testing/cypress/src/integration/studio/designer.js index 5088e8d0385..7eb365c68a4 100644 --- a/frontend/testing/cypress/src/integration/studio/designer.js +++ b/frontend/testing/cypress/src/integration/studio/designer.js @@ -11,14 +11,16 @@ const designerAppId = `${Cypress.env('autoTestUser')}/${Cypress.env('designerApp context('Designer', () => { before(() => { cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); - cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')).then(() => { - cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); - }); + cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); }); beforeEach(() => { cy.visit('/dashboard'); }); + after(() => { + cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')); + }); + it('is possible to edit information about the app', () => { // Navigate to designerApp cy.visit('/editor/' + designerAppId); diff --git a/frontend/testing/cypress/src/integration/studio/login.js b/frontend/testing/cypress/src/integration/studio/login.js index 356e500ebcf..46162e99037 100644 --- a/frontend/testing/cypress/src/integration/studio/login.js +++ b/frontend/testing/cypress/src/integration/studio/login.js @@ -8,6 +8,7 @@ import {gitea} from "../../selectors/gitea"; context('Login', () => { beforeEach(() => { + Cypress.session.clearAllSavedSessions(); cy.clearCookies(); cy.visit('/'); }); diff --git a/frontend/testing/cypress/src/integration/studio/new-app.js b/frontend/testing/cypress/src/integration/studio/new-app.js index 04d025c2b96..3d602d333e3 100644 --- a/frontend/testing/cypress/src/integration/studio/new-app.js +++ b/frontend/testing/cypress/src/integration/studio/new-app.js @@ -9,7 +9,6 @@ import { gitea } from "../../selectors/gitea"; context('New App', () => { before(() => { cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); - cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')); }); beforeEach(() => { cy.visit('/dashboard'); diff --git a/frontend/testing/cypress/src/integration/studio/repos.js b/frontend/testing/cypress/src/integration/studio/repos.js index 16bd888f1fd..6bb96f59800 100644 --- a/frontend/testing/cypress/src/integration/studio/repos.js +++ b/frontend/testing/cypress/src/integration/studio/repos.js @@ -7,17 +7,18 @@ import { header } from '../../selectors/header'; context('Repository', () => { before(() => { cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); - cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')).then(() => { - cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); - }); + cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); }); beforeEach(() => { cy.visit('/'); - cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); cy.searchAndOpenApp(Cypress.env('designerAppName')); }); + after(() => { + cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')); + }); + it('is possible to open repository of an app from app development page', () => { header.getProfileIcon().click(); header diff --git a/frontend/testing/cypress/src/integration/studio/sync-app.js b/frontend/testing/cypress/src/integration/studio/sync-app.js index f173141d33a..a4d50b62ea2 100644 --- a/frontend/testing/cypress/src/integration/studio/sync-app.js +++ b/frontend/testing/cypress/src/integration/studio/sync-app.js @@ -8,9 +8,7 @@ import { header } from "../../selectors/header"; context('Sync app and deploy', () => { before(() => { cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); - cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')).then(() => { - cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); - }); + cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); }); beforeEach(() => { @@ -25,6 +23,10 @@ context('Sync app and deploy', () => { cy.visit('/dashboard'); }); + after(() => { + cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')); + }); + it('is possible to sync changes', () => { cy.searchAndOpenApp(Cypress.env('designerAppName')); // Make some changes diff --git a/frontend/testing/cypress/src/integration/studio/wcag.js b/frontend/testing/cypress/src/integration/studio/wcag.js index 384675cd557..6f86dbc9a52 100644 --- a/frontend/testing/cypress/src/integration/studio/wcag.js +++ b/frontend/testing/cypress/src/integration/studio/wcag.js @@ -7,14 +7,12 @@ import { header } from "../../selectors/header"; context('WCAG', () => { before(() => { cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); - cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')).then(() => { - cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); - }); + cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); }); beforeEach(() => { cy.visit('/'); - cy.intercept('GET', 'designer/api/repos/search?**').as('fetchApps'); + cy.intercept('GET', '**/repos/search**').as('fetchApps'); dashboard.getSearchReposField().should('be.visible'); cy.wait('@fetchApps') .its('response.statusCode') @@ -23,6 +21,10 @@ context('WCAG', () => { }); }); + after(() => { + cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')); + }); + it('accessibility test for dashboard', () => { cy.testWcag(); });