-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix navigation from overview page (#11602)
* fix navigation from overview page * cypress tests for overview page * small cleanup * re-usable function for visiting url with feature flag
- Loading branch information
Showing
3 changed files
with
114 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
frontend/testing/cypress/src/integration/studio/overview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/// <reference types="cypress" /> | ||
/// <reference types="../../support" /> | ||
|
||
import * as texts from '../../../../../language/src/nb.json'; | ||
|
||
const designerAppId = `${Cypress.env('autoTestUser')}/${Cypress.env('designerAppName')}`; | ||
const orgAppId = `${Cypress.env('orgUserName')}/${Cypress.env('designerAppName')}`; | ||
const NEW_ADM_FEATURE_FLAG = 'newAdministration'; | ||
|
||
context('Designer', () => { | ||
before(() => { | ||
cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')); | ||
cy.deleteApp( | ||
Cypress.env('orgUserName'), | ||
Cypress.env('designerAppName'), | ||
Cypress.env('accessToken'), | ||
); | ||
cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd')); | ||
cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName')); | ||
cy.createApp(Cypress.env('orgFullName'), Cypress.env('designerAppName')); | ||
}); | ||
beforeEach(() => { | ||
cy.visit('/dashboard'); | ||
}); | ||
|
||
it('loads the overview page when navigating to app for user with no environments', () => { | ||
// Ensure feature flag is toggled | ||
// TODO: remove this once feature flag is removed (https://github.com/Altinn/altinn-studio/issues/11495) | ||
cy.visitWithFeatureFlag('/editor/' + designerAppId, NEW_ADM_FEATURE_FLAG); | ||
cy.findByText(Cypress.env('designerAppName')).should('be.visible'); | ||
cy.findByText(texts['app_publish.no_env_title']).should('be.visible'); | ||
cy.findByText(texts['administration.navigation_title']).should('be.visible'); | ||
cy.findByText(texts['administration.documentation.title']).should('be.visible'); | ||
cy.findByText(texts['administration.news_title']).should('be.visible'); | ||
}); | ||
|
||
it('loads the overview page when navigating to app for org with environments', () => { | ||
// Ensure feature flag is toggled | ||
// TODO: remove this once feature flag is removed (https://github.com/Altinn/altinn-studio/issues/11495) | ||
cy.visitWithFeatureFlag('/editor/' + orgAppId, NEW_ADM_FEATURE_FLAG); | ||
cy.findByText(Cypress.env('designerAppName')).should('be.visible'); | ||
cy.findByRole('heading', { name: 'tt02' }).should('be.visible'); | ||
cy.findByText(texts['administration.activity']).should('be.visible'); | ||
cy.findByText(texts['administration.navigation_title']).should('be.visible'); | ||
cy.findByText(texts['administration.documentation.title']).should('be.visible'); | ||
cy.findByText(texts['administration.news_title']).should('be.visible'); | ||
}); | ||
|
||
it('should be possible to navigate to the forms builder from overview page', () => { | ||
// Ensure feature flag is toggled | ||
// TODO: remove this once feature flag is removed (https://github.com/Altinn/altinn-studio/issues/11495) | ||
cy.visitWithFeatureFlag('/editor/' + designerAppId, NEW_ADM_FEATURE_FLAG); | ||
const navigationContainer = cy.findByText(texts['administration.navigation_title']).parent(); | ||
navigationContainer | ||
.findByRole('link', { name: texts['top_menu.create'] }) | ||
.should('be.visible') | ||
.click(); | ||
cy.findByText(texts['left_menu.components']).should('be.visible'); | ||
cy.findByText(texts['ux_editor.no_components_selected']).should('be.visible'); | ||
}); | ||
|
||
it('should be possible to navigate to the data model editor from overview page', () => { | ||
// Ensure feature flag is toggled | ||
// TODO: remove this once feature flag is removed (https://github.com/Altinn/altinn-studio/issues/11495) | ||
cy.visitWithFeatureFlag('/editor/' + designerAppId, NEW_ADM_FEATURE_FLAG); | ||
const navigationContainer = cy.findByText(texts['administration.navigation_title']).parent(); | ||
navigationContainer | ||
.findByRole('link', { name: texts['top_menu.datamodel'] }) | ||
.should('be.visible') | ||
.click(); | ||
cy.findByText(texts['app_data_modelling.landing_dialog_header']).should('be.visible'); | ||
}); | ||
|
||
it('should be possible to navigate to the text editor from overview page', () => { | ||
// Ensure feature flag is toggled | ||
// TODO: remove this once feature flag is removed (https://github.com/Altinn/altinn-studio/issues/11495) | ||
cy.visitWithFeatureFlag('/editor/' + designerAppId, NEW_ADM_FEATURE_FLAG); | ||
const navigationContainer = cy.findByText(texts['administration.navigation_title']).parent(); | ||
navigationContainer | ||
.findByRole('link', { name: texts['top_menu.texts'] }) | ||
.should('be.visible') | ||
.click(); | ||
cy.findByText(texts['text_editor.new_text']).should('be.visible'); | ||
cy.findByText(texts['text_editor.search_for_text']).should('be.visible'); | ||
}); | ||
|
||
it('should be possible to navigate to the process editor from overview page', () => { | ||
// Ensure feature flag is toggled | ||
// TODO: remove this once feature flag is removed (https://github.com/Altinn/altinn-studio/issues/11495) | ||
cy.visitWithFeatureFlag('/editor/' + designerAppId, NEW_ADM_FEATURE_FLAG); | ||
const navigationContainer = cy.findByText(texts['administration.navigation_title']).parent(); | ||
navigationContainer | ||
.findByRole('link', { name: texts['top_menu.process-editor'] }) | ||
.should('be.visible') | ||
.click(); | ||
cy.findByText(texts['process_editor.edit_mode']).should('be.visible'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
Cypress.Commands.add( | ||
'isVisible', | ||
{ | ||
prevSubject: true, | ||
}, | ||
(subject) => { | ||
const isVisible = (elem) => !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); | ||
expect(isVisible(subject[0])).to.be.true; | ||
}, | ||
); | ||
Cypress.Commands.add('isVisible', { prevSubject: true }, (subject) => { | ||
const isVisible = (elem) => | ||
!!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); | ||
expect(isVisible(subject[0])).to.be.true; | ||
}); | ||
|
||
/** | ||
* Visit a location in Studio with given feature flag toggled on. | ||
* @param path The base path to visit | ||
* @param featureFlag The feature flag to toggle on | ||
* @param persistFeatureFlag Specifies if the feature flag should be persisted on navigation. Defaults to true. | ||
*/ | ||
Cypress.Commands.add('visitWithFeatureFlag', (path, featureFlag, persistFeatureFlag = true) => { | ||
cy.visit(`${path}?featureFlags=${featureFlag}&persistFeatureFlag=${persistFeatureFlag}`); | ||
}); |