Skip to content

Commit

Permalink
Test/add missing frontend tests (#7747)
Browse files Browse the repository at this point in the history
* new tests for app frontend

* new tests for studio designer

* new tests for studio

* removed unused data

* formatted

* run with 3 machines

* updated app deploy test

* changed logic for favorites

* removed only clause

* corrected text resource test

* updated test name

* wcag test in altinn studio

* added extra wait

* updated deps

* changed to beforeeach hook

* changed inprogress selector

* added script for deleted old cypress binaries

* moved prune command one step down
  • Loading branch information
jeevananthank authored Jan 3, 2022
1 parent b37e886 commit ba79444
Show file tree
Hide file tree
Showing 24 changed files with 399 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cypress-altinn-app-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
machines: [1, 2]
machines: [1, 2, 3]

steps:
- name: Checkout
Expand Down
2 changes: 0 additions & 2 deletions src/test/cypress/e2e/config/studio/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
"baseUrl": "https://dev.altinn.studio",
"env": {
"autoTestUser": "AutoTest",
"noDeployUser": "AutoTest2",
"useCaseUser": "bruksmonsterDev",
"deployApp": "ttd/autodeploy-v3",
"designerApp": "AutoTest/auto-designer-app",
"withoutDataModelApp": "AutoTest/appwithout-dm",
"rulesApp": "AutoTest/rulesservice",
"appOwner": "Testdepartementet"
},
"defaultCommandTimeout": 20000,
Expand Down
2 changes: 0 additions & 2 deletions src/test/cypress/e2e/config/studio/local.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
"env": {
"autoTestUser": "testuser",
"autoTestUserPwd": "Studio@123",
"noDeployUser": "automatedtest@email.com",
"testEmail": "test1@test.com",
"deployApp": "ttd/deploy",
"designerApp": "ttd/designer",
"withoutDataModelApp": "ttd/appwithout-dm",
"rulesApp": "ttd/rulesservice",
"appOwner": "ttd"
},
"defaultCommandTimeout": 20000,
Expand Down
2 changes: 0 additions & 2 deletions src/test/cypress/e2e/config/studio/prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
"baseUrl": "https://altinn.studio",
"env": {
"autoTestUser": "AutoTest",
"noDeployUser": "noDeployUser",
"useCaseUser": "bruksmonster",
"deployApp": "ttd/auto-deploy-app-v2",
"designerApp": "AutoTest/auto-designer-app",
"withoutDataModelApp": "AutoTest/appwithout-dm",
"rulesApp": "AutoTest/rules-service",
"appOwner": "Testdepartementet"
},
"defaultCommandTimeout": 20000,
Expand Down
2 changes: 0 additions & 2 deletions src/test/cypress/e2e/config/studio/staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
"baseUrl": "https://staging.altinn.studio",
"env": {
"autoTestUser": "AutoTest",
"noDeployUser": "automatedtest@email.com",
"deployApp": "ttd/autodeploy-v3",
"designerApp": "AutoTest/auto-designer-app",
"withoutDataModelApp": "AutoTest/appwithout-dm",
"rulesApp": "AutoTest/rulesservice",
"appOwner": "Testdepartementet"
},
"defaultCommandTimeout": 20000,
Expand Down
3 changes: 2 additions & 1 deletion src/test/cypress/e2e/fixtures/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"alreadyStartedForm": "Du har allerede startet å fylle ut dette skjemaet.",
"continueOrStartNew": "Velg om du vil fortsette på et skjema du har begynt på, eller om du vil starte på ny.",
"welcome": "Velkommen til Altinn Studio",
"appExists": "En app med det navnet finnes allerede."
"appExists": "En app med det navnet finnes allerede.",
"noDeployAccess": "Du har ikke rettigheter til å starte en deploy til AT21-miljøet. Tilgang kan delegeres av owners"
}
5 changes: 4 additions & 1 deletion src/test/cypress/e2e/integration/app-frontend/formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ describe('Formatting', () => {
it('Number formatting', () => {
cy.navigateToChangeName();
cy.get('#form-content-newFirstName').siblings().should('have.class', 'MuiGrid-grid-md-6');
cy.get('#form-content-newFirstName').siblings().parent().should('have.css', 'border-bottom', '1px dashed rgb(148, 148, 148)');
cy.get('#form-content-newFirstName')
.siblings()
.parent()
.should('have.css', 'border-bottom', '1px dashed rgb(148, 148, 148)');
cy.get(appFrontend.changeOfName.mobilenummer)
.should('be.visible')
.type('44444444')
Expand Down
1 change: 1 addition & 0 deletions src/test/cypress/e2e/integration/app-frontend/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('Group', () => {
cy.get(appFrontend.group.currentValue).should('be.visible').type('1337').blur().tab();
// DataProcessingHandler.cs for frontend-test changes 1337 to 1338.
cy.get(appFrontend.group.currentValue).should('have.value', 'NOK 1 338');
cy.get(appFrontend.group.newValueLabel).should('contain.text', '2. Endre verdi 1338 til');
});

it('Validation on group', () => {
Expand Down
17 changes: 17 additions & 0 deletions src/test/cypress/e2e/integration/app-frontend/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,21 @@ describe('Summary', () => {
cy.get(summaryDate).contains(mui.gridContainer, texts.requiredField).should('not.exist');
});
});

it('is possible to view summary of repeating group', () => {
cy.compelteTask3Form();
cy.get(appFrontend.group.mainGroupSummary).should('be.visible').and('have.length', 1);
cy.get(appFrontend.group.mainGroupSummary)
.first()
.children(mui.gridItem)
.then((item) => {
cy.get(item).should('have.length', 4);
cy.get(item).find(mui.buttonIcon).should('have.length', 3);
cy.get(item)
.eq(1)
.children(mui.gridContainer)
.should('have.css', 'border-bottom', '1px dashed rgb(0, 143, 214)');
cy.get(item).eq(3).should('contain.text', 'automation');
});
});
});
23 changes: 17 additions & 6 deletions src/test/cypress/e2e/integration/studio/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ const common = new Common();
context('Dashboard', () => {
beforeEach(() => {
cy.visit('/');
cy.intercept('GET', '**/repos/search**').as('fetchApps');
cy.studiologin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd'));
cy.get(dashboard.searchApp).should('be.visible');
cy.wait('@fetchApps').its('response.statusCode').should('eq', 200);
});

it('is possible to view apps, add and remove favourites', () => {
Expand All @@ -23,11 +25,11 @@ context('Dashboard', () => {
.find(common.gridRow)
.then((apps) => {
cy.get(apps).should('have.length.gte', 1);
cy.get(apps).find(dashboard.apps.favourite).click({ multiple: true });
cy.wait('@addFavourite').its('response.statusCode').should('eq', 204);
cy.get(apps)
.first()
.then((app) => {
cy.get(app).find(dashboard.apps.favourite).click();
cy.wait('@addFavourite').its('response.statusCode').should('eq', 204);
cy.get(app).children(dashboard.apps.name).invoke('text').should('not.be.empty');
cy.get(app).children(dashboard.apps.createdBy).should('have.text', Cypress.env('autoTestUser'));
cy.get(app).children(dashboard.apps.updatedAt).invoke('text').should('not.be.empty');
Expand All @@ -46,23 +48,32 @@ context('Dashboard', () => {

it('is possible to change context and view all apps', () => {
if (Cypress.env('environment') == 'local') cy.intercept('GET', '**/user/repos', repos(10));
cy.intercept('**/repos/search**').as('getAllRepos');
cy.get(header.profileIcon).should('be.visible').click();
cy.get(header.menu.all).should('be.visible').click();
cy.wait('@getAllRepos');
cy.wait('@fetchApps');
cy.contains('h2', 'Alle applikasjoner').should('be.visible');
});

it('is possible to search an app by name', () => {
if (Cypress.env('environment') == 'local') cy.intercept('GET', '**/user/repos', repos(10));
cy.intercept('**/repos/search**').as('searchRepos');
cy.get(dashboard.searchApp).type('auto');
cy.wait('@searchRepos');
cy.wait('@fetchApps');
cy.contains('h2', 'Søkeresultat')
.siblings()
.then((searchResult) => {
cy.get(searchResult).find(common.gridRow).should('have.length.gte', 1);
cy.get(searchResult).find(common.gridRow).first().find(dashboard.apps.name).should('contain.text', 'auto');
});
});

it('is not possible to find an app that does not exist', () => {
cy.get(dashboard.searchApp).type('cannotfindapp');
cy.wait('@fetchApps');
cy.contains('h2', 'Søkeresultat')
.siblings()
.then((searchResult) => {
cy.get(searchResult).find(common.gridRow).should('have.length', 0);
cy.get(searchResult).find('p').should('contain.text', 'Ingen applikasjoner funnet');
});
});
});
32 changes: 20 additions & 12 deletions src/test/cypress/e2e/integration/studio/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import { designer } from '../../pageobjects/designer';
import Common from '../../pageobjects/common';
import { header } from '../../pageobjects/header';
import { dashboard } from '../../pageobjects/dashboard';
import { builds } from '../../fixtures/builds';
import { deploys } from '../../fixtures/deploys';
import * as texts from '../../fixtures/texts.json';

const common = new Common();

Expand All @@ -23,13 +23,11 @@ context('Deploy', () => {
beforeEach(() => {
cy.visit('/');
cy.studiologin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd'));
var appName = Cypress.env('deployApp').split('/')[1];
cy.get(dashboard.searchApp).type(appName);
cy.contains(dashboard.apps.name, appName).siblings(dashboard.apps.links).find(dashboard.apps.edit).click();
cy.searchAndOpenApp(Cypress.env('deployApp'));
cy.get(designer.appMenu['deploy']).click();
});

it('Inprogress build', () => {
it('is possible to view an inprogress build', () => {
cy.intercept('GET', `**/designer/api/v1/${Cypress.env('deployApp')}/releases**`, builds('inprogress')).as(
'buildstatus',
);
Expand All @@ -41,7 +39,7 @@ context('Deploy', () => {
});
});

it('Failed build', () => {
it('is possible to view the status of a failed build', () => {
cy.intercept('GET', `**/designer/api/v1/${Cypress.env('deployApp')}/releases**`, builds('failed')).as(
'buildstatus',
);
Expand All @@ -53,7 +51,7 @@ context('Deploy', () => {
});
});

it('Successful build', () => {
it('is possible to view status of a successful build', () => {
cy.intercept('GET', `**/designer/api/v1/${Cypress.env('deployApp')}/releases**`, builds('succeeded')).as(
'buildstatus',
);
Expand All @@ -65,10 +63,20 @@ context('Deploy', () => {
});
});

it('App Deploy', () => {
cy.intercept('GET', '**/designer/api/v1/*/*/Deployments**', deploys()).as('deploys');
cy.wait('@deploys').its('response.statusCode').should('eq', 200);
cy.contains('div', 'AT22').should('be.visible');
cy.get(designer.deployHistory.at22).find('tbody > tr').should('contain.text', 'testuser');
it('is possible to view history of app deploys', () => {
if (Cypress.env('environment') == 'local')
cy.intercept('GET', '**/designer/api/v1/*/*/Deployments**', deploys()).as('deploys');
if (Cypress.env('environment') != 'prod') {
cy.contains('div', 'AT22').scrollIntoView().should('be.visible');
cy.get(designer.deployHistory.at22).find('tbody > tr').should('contain.text', Cypress.env('autoTestUser'));
} else {
cy.contains('div', 'PRODUCTION').scrollIntoView().should('be.visible');
cy.get(designer.deployHistory.prod).find('tbody > tr').should('contain.text', Cypress.env('autoTestUser'));
}
});

it('is not possible to deploy without access', () => {
if (Cypress.env('environment') == 'local') cy.intercept('GET', '**/permissions', '["AT22"]');
cy.contains(common.gridContainer, texts.noDeployAccess).should('exist').and('be.visible');
});
});
79 changes: 71 additions & 8 deletions src/test/cypress/e2e/integration/studio/designer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/// <reference types="../../support" />

import { designer } from '../../pageobjects/designer';
import { dashboard } from '../../pageobjects/dashboard';
import { header } from '../../pageobjects/header';
import Common from '../../pageobjects/common';

Expand All @@ -14,34 +13,98 @@ context('Designer', () => {
cy.visit('/');
cy.studiologin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd'));
cy.createapp(Cypress.env('appOwner'), 'designer');
cy.get(header.profileIcon).click();
cy.get(header.profileIconDesigner).click();
cy.contains(header.menuItem, 'Logout').click();
}
});
beforeEach(() => {
cy.visit('/');
cy.studiologin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd'));
var appName = Cypress.env('deployApp').split('/')[1];
cy.get(dashboard.searchApp).type(appName);
cy.contains(dashboard.apps.name, appName).siblings(dashboard.apps.links).find(dashboard.apps.edit).click();
});

it('About App', () => {
it('is possible to edit information about the app', () => {
cy.searchAndOpenApp(Cypress.env('designerApp'));
cy.contains(designer.aboutApp.appHeader, 'Om appen').should('be.visible');
cy.contains(common.button, 'Endre').click();
cy.get(designer.aboutApp.appName).clear().type('New app name');
cy.get(designer.aboutApp.appDescription).clear().type('App description');
cy.get(designer.aboutApp.appDescription).click().clear().type('App description');
cy.get(designer.aboutApp.appName).invoke('val').should('contain', 'New app name');
cy.get(designer.aboutApp.appDescription).invoke('val').should('contain', 'App description');
});

it('UI Editor', () => {
it('is possible to add and delete form components', () => {
cy.searchAndOpenApp(Cypress.env('designerApp'));
cy.get(designer.appMenu['edit']).click();
cy.get(common.leftDrawer).trigger('mouseover', { force: true });
cy.get(designer.appEditorMenu['datamodel']).should('be.visible');
cy.get(common.leftDrawer).trigger('mouseout');
cy.get(designer.formComponents.shortAnswer).parents(designer.draggable).trigger('dragstart');
cy.get(designer.dragToArea).parents(designer.draggable).trigger('drop');
cy.deletecomponents();
cy.get(header.profileIconDesigner).click();
cy.get(header.menu.openRepo)
.invoke('attr', 'href')
.should('include', `/repos/${Cypress.env('designerApp')}`);
cy.get(header.menu.docs).should('be.visible');
cy.contains('li', 'Logout').should('be.visible');
});

it('is possible to add and delete text resources', () => {
cy.searchAndOpenApp(Cypress.env('designerApp'));
cy.get(designer.appMenu.texts).click();
cy.getIframeBody().find(designer.texts.root).find(designer.texts.new).should('be.visible').click();
cy.getIframeBody()
.find(designer.texts.resources)
.last()
.then((newText) => {
cy.get(newText).find(designer.texts.resourceId).should('be.visible').type('test').tab();
cy.get(newText).find(designer.texts.resourceValue).should('be.visible').type('automation').tab();
cy.get(newText).find(designer.texts.requiredError).should('be.visible');
cy.getIframeBody().find(designer.texts.save).should('be.visible').focus().click();
cy.get(newText).find(designer.texts.delete).should('be.visible').click();
cy.getIframeBody().find(designer.texts.save).should('be.visible').focus().click();
});
});

it('is possible to configure rules and dynamics ', () => {
cy.searchAndOpenApp(Cypress.env('designerApp'));
cy.get(designer.appMenu['edit']).click();
cy.contains('span', 'Rediger dynamikk').should('be.visible');
cy.get(designer.rules.add).should('be.visible').click();
cy.get(designer.rules.list).should('be.visible').select('sum');
cy.get(designer.rules.paramA).parents('.col').siblings().find(designer.rules.paramValue).click();
cy.get(designer.rules.dataModelBinding).should('have.length.above', 0);
cy.get(designer.submit).scrollIntoView().should('be.visible').click();
cy.contains(common.gridItem, 'sum').should('be.visible').click();
cy.get(designer.delete).scrollIntoView().should('be.visible').click();
cy.contains(common.gridItem, 'sum').should('not.exist');
cy.get(designer.dynamics.add).should('be.visible').click();
cy.get(designer.dynamics.list).should('be.visible').select('biggerThan10');
cy.get(designer.dynamics.action).should('be.visible');
cy.get(designer.submit).scrollIntoView().should('be.visible').click();
cy.contains(common.gridItem, 'biggerThan10').should('be.visible').click();
cy.get(designer.delete).scrollIntoView().should('be.visible').click();
cy.contains(common.gridItem, 'biggerThan10').should('not.exist');
});

it('is possible to delete local changes of an app ', () => {
cy.searchAndOpenApp(Cypress.env('designerApp'));
cy.get(designer.appMenu['edit']).click();
cy.intercept('GET', '**/status').as('getRepoStatus');
cy.get(designer.formComponents.shortAnswer).parents(designer.draggable).click().type('{enter}');
cy.wait('@getRepoStatus');
cy.get(designer.syncApp.push).scrollIntoView().isVisible();
cy.deleteLocalChanges(Cypress.env('designerApp'));
cy.get(designer.syncApp.noChanges).scrollIntoView().isVisible();
});

it('is possible details of the clone modal ', () => {
cy.searchAndOpenApp(Cypress.env('withoutDataModelApp'));
cy.get(designer.appMenu['edit']).click();
cy.contains('button', 'Clone').scrollIntoView().should('be.visible').click();
cy.get(designer.clone.docs).should('be.visible');
cy.contains('p', designer.clone.missingDatamodel).should('be.visible');
cy.get(designer.clone.datamodelLink).should('be.visible');
cy.get(designer.clone.copyRepo).should('be.visible');
});
});
24 changes: 24 additions & 0 deletions src/test/cypress/e2e/integration/studio/repos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// <reference types="cypress" />
/// <reference types="../../support" />

import { header } from '../../pageobjects/header';

context('Repository', () => {
beforeEach(() => {
cy.visit('/');
cy.studiologin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd'));
cy.searchAndOpenApp(Cypress.env('designerApp'));
});

it('is possible to open repository of an app', () => {
cy.get(header.profileIconDesigner).click();
cy.get(header.menu.openRepo)
.invoke('attr', 'href')
.then((href) => {
cy.visit(href);
});
cy.get('.repo-header').should('be.visible');
cy.get('a[href="/repos/"]').should('be.visible').click();
cy.get('img[alt="Altinn logo"]').should('be.visible');
});
});
Loading

0 comments on commit ba79444

Please sign in to comment.