Skip to content

Commit

Permalink
Delete apps after instead of before for test specs (#11284)
Browse files Browse the repository at this point in the history
  • Loading branch information
standeren authored Oct 4, 2023
1 parent add366e commit e1c4dc3
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 23 deletions.
10 changes: 6 additions & 4 deletions frontend/testing/cypress/src/integration/studio/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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'))
Expand Down
6 changes: 2 additions & 4 deletions frontend/testing/cypress/src/integration/studio/datamodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
8 changes: 5 additions & 3 deletions frontend/testing/cypress/src/integration/studio/designer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions frontend/testing/cypress/src/integration/studio/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {gitea} from "../../selectors/gitea";

context('Login', () => {
beforeEach(() => {
Cypress.session.clearAllSavedSessions();
cy.clearCookies();
cy.visit('/');
});
Expand Down
1 change: 0 additions & 1 deletion frontend/testing/cypress/src/integration/studio/new-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
9 changes: 5 additions & 4 deletions frontend/testing/cypress/src/integration/studio/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions frontend/testing/cypress/src/integration/studio/sync-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions frontend/testing/cypress/src/integration/studio/wcag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -23,6 +21,10 @@ context('WCAG', () => {
});
});

after(() => {
cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken'));
});

it('accessibility test for dashboard', () => {
cy.testWcag();
});
Expand Down

0 comments on commit e1c4dc3

Please sign in to comment.