Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11493/cypress tests settings modal #11884

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@
"settings_modal.setup_tab_heading": "Oppsett",
"settings_modal.setup_tab_switch_autoDeleteOnProcessEnd": "Automatisk sletting etter innsending",
"settings_modal.setup_tab_switch_copyInstanceSettings_enabled": "Bruker kan kopiere instansen",
"settings_modal.setup_tab_switch_messageBoxConfig_hideSettings_hideAlways": "Skjul i arkiv hos bruker etter innsending ",
"settings_modal.setup_tab_switch_messageBoxConfig_hideSettings_hideAlways": "Skjul i arkiv hos bruker etter innsending",
"settings_modal.setup_tab_switch_onEntry_show": "Vis påstartede instanser",
"shared.header_all": "Alle",
"shared.header_button": "Altinn profilmeny",
Expand Down
90 changes: 90 additions & 0 deletions frontend/testing/cypress/src/integration/studio/settingsModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/// <reference types="cypress" />
/// <reference types="../../support" />

import * as texts from '../../../../../language/src/nb.json';
import { accessControlTab } from '../../selectors/accessControlTab';
import { administrationTab } from '../../selectors/administrationTab';
import { localChangesTab } from '../../selectors/localChangesTab';
import { policyEditorTab } from '../../selectors/policyEditorTab';
import { settingsTab } from '../../selectors/settingsTab';

const designerAppId = `${Cypress.env('autoTestUser')}/${Cypress.env('designerAppName')}`;

context('SettingsModal', () => {
before(() => {
cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken'));
cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd'));
cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName'));
});
beforeEach(() => {
cy.visit('/dashboard');
// Navigate to designerApp
cy.visit('/editor/' + designerAppId);
cy.openSettingsModal();
});
after(() => {
cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken'));
});

it('is possible to open the settings modal', () => {
cy.findByRole('heading', { name: texts['settings_modal.heading'] }).should('be.visible');
});

it('is possible to close the settings modal', () => {
cy.findByRole('button', { name: texts['modal.close_icon'] }).click();
cy.findByRole('heading', { name: texts['settings_modal.heading'] }).should('not.exist');
});

it('is possible to see and edit information on About App tab', () => {
administrationTab.getHeader().should('be.visible');
administrationTab.getAppNameField().clear().type('New app name');
administrationTab.getAppNameField().invoke('val').should('contain', 'New app name');
});

it('is possible to toggle settings on app settings tab', () => {
settingsTab.getTab().click();
settingsTab.getHeader().should('be.visible');
settingsTab.getAutoDelete().should('be.visible');
settingsTab.getEnableCopyInstance().should('be.visible');
settingsTab.getHideInInbox().should('be.visible');
settingsTab.getShowStartedInstances().should('be.visible');
});

it('is possible to load the policy editor tab', () => {
// This test only loads the tab and tests that it loads as expected.
// We should implement a separate test for the poloicy editor.
policyEditorTab.getTab().click();
policyEditorTab.getHeader().should('be.visible');
policyEditorTab.getSecurityLevelSelect().should('be.visible');
});

it('is possible to update settings on the access control tab', () => {
accessControlTab.getTab().click();
accessControlTab.getHeader().should('be.visible');
accessControlTab.getOrganisationParty().should('be.visible');
accessControlTab.getPersonParty().should('be.visible');
accessControlTab.getSubUnitParty().should('be.visible');
accessControlTab.getBankruptcyParty().should('be.visible').click();
accessControlTab.getBankruptcyPartyCheckbox().should('be.checked');

// Close modal and re-open to confirm data is set as expected
cy.findByRole('button', { name: texts['modal.close_icon'] }).click();
cy.openSettingsModal();
accessControlTab.getTab().click();
accessControlTab.getBankruptcyPartyCheckbox().should('be.checked');
});

it('is possible to delete local changes', () => {
localChangesTab.getTab().click();
localChangesTab.getHeader().should('be.visible');
localChangesTab.getDownloadChangesLink().should('be.visible');
localChangesTab.getDownloadAllLink().should('be.visible');
localChangesTab.getDeleteChangesButton().should('be.visible').click();
localChangesTab.getConfirmRepoNameField().type('test');
localChangesTab.getConfirmDeleteButton().should('be.disabled');
localChangesTab.getConfirmRepoNameField().clear();
localChangesTab.getConfirmRepoNameField().type(`${Cypress.env('designerAppName')}`);
localChangesTab.getConfirmDeleteButton().should('be.enabled').click();
cy.findByText(texts['overview.reset_repo_completed']).should('be.visible');
});
});
17 changes: 17 additions & 0 deletions frontend/testing/cypress/src/selectors/accessControlTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as texts from '@altinn-studio/language/src/nb.json';

export const accessControlTab = {
getHeader: () =>
cy.findByRole('heading', { name: texts['settings_modal.access_control_tab_heading'] }),
getTab: () => cy.findByText(texts['settings_modal.access_control_tab_heading']),
getBankruptcyParty: () =>
cy.findByText(texts['settings_modal.access_control_tab_option_bankruptcy_estate']),
getBankruptcyPartyCheckbox: () =>
cy.findByRole('checkbox', {
name: texts['settings_modal.access_control_tab_option_bankruptcy_estate'],
}),
getOrganisationParty: () =>
cy.findByText(texts['settings_modal.access_control_tab_option_organisation']),
getPersonParty: () => cy.findByText(texts['settings_modal.access_control_tab_option_person']),
getSubUnitParty: () => cy.findByText(texts['settings_modal.access_control_tab_option_sub_unit']),
};
7 changes: 7 additions & 0 deletions frontend/testing/cypress/src/selectors/administrationTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as texts from '@altinn-studio/language/src/nb.json';

export const administrationTab = {
getAppNameField: () =>
cy.findByRole('textbox', { name: texts['settings_modal.about_tab_name_label'] }),
getHeader: () => cy.findByRole('heading', { name: texts['settings_modal.about_tab_heading'] }),
};
23 changes: 23 additions & 0 deletions frontend/testing/cypress/src/selectors/localChangesTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as texts from '@altinn-studio/language/src/nb.json';

export const localChangesTab = {
getHeader: () =>
cy.findByRole('heading', { name: texts['settings_modal.local_changes_tab_heading'] }),
getTab: () => cy.findByText(texts['settings_modal.local_changes_tab_heading']),
getDownloadChangesLink: () =>
cy.findByRole('link', {
name: texts['settings_modal.local_changes_tab_download_only_changed_button'],
}),
getDownloadAllLink: () =>
cy.findByRole('link', { name: texts['settings_modal.local_changes_tab_download_all_button'] }),
getDeleteChangesButton: () =>
cy.findByRole('button', { name: texts['settings_modal.local_changes_tab_delete_button'] }),
getConfirmRepoNameField: () =>
cy.findByRole('textbox', {
name: texts['settings_modal.local_changes_tab_delete_modal_textfield_label'],
}),
getConfirmDeleteButton: () =>
cy.findByRole('button', {
name: texts['settings_modal.local_changes_tab_delete_modal_delete_button'],
}),
};
8 changes: 8 additions & 0 deletions frontend/testing/cypress/src/selectors/policyEditorTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as texts from '@altinn-studio/language/src/nb.json';

export const policyEditorTab = {
getHeader: () => cy.findByRole('heading', { name: texts['settings_modal.policy_tab_heading'] }),
getTab: () => cy.findByText(texts['settings_modal.policy_tab_heading']),
getSecurityLevelSelect: () =>
cy.findByRole('combobox', { name: texts['policy_editor.select_auth_level_label'] }),
};
16 changes: 16 additions & 0 deletions frontend/testing/cypress/src/selectors/settingsTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as texts from '@altinn-studio/language/src/nb.json';

export const settingsTab = {
getHeader: () => cy.findByRole('heading', { name: texts['settings_modal.setup_tab_heading'] }),
getTab: () => cy.findByText(texts['settings_modal.setup_tab_heading']),
getAutoDelete: () =>
cy.findByText(texts['settings_modal.setup_tab_switch_autoDeleteOnProcessEnd']),
getHideInInbox: () =>
cy.findByText(
texts['settings_modal.setup_tab_switch_messageBoxConfig_hideSettings_hideAlways'],
),
getEnableCopyInstance: () =>
cy.findByText(texts['settings_modal.setup_tab_switch_copyInstanceSettings_enabled']),
getShowStartedInstances: () =>
cy.findByText(texts['settings_modal.setup_tab_switch_onEntry_show']),
};
4 changes: 4 additions & 0 deletions frontend/testing/cypress/src/support/studio.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,7 @@ Cypress.Commands.add('ensureCreatePageIsLoaded', () => {
cy.wait('@getLayoutSettings').its('response.statusCode').should('eq', 200);
cy.findByRole('button', { name: `${texts['ux_editor.pages_add']}` }).should('be.visible');
});

Cypress.Commands.add('openSettingsModal', () => {
cy.findByRole('button', { name: texts['settings_modal.heading'] }).click();
});