Skip to content

Commit

Permalink
local changes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nkylstad committed Dec 18, 2023
1 parent aad037a commit 75b1446
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
39 changes: 29 additions & 10 deletions frontend/testing/cypress/src/integration/studio/settingsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,37 @@
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('Designer', () => {
context('SettingsModal', () => {
before(() => {
// cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken'));
cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken'));
cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd'));
// cy.createApp(Cypress.env('autoTestUser'), Cypress.env('designerAppName'));
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');
Expand All @@ -42,23 +51,19 @@ context('Designer', () => {
});

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 load the access control tab', () => {
it('is possible to update settings on the access control tab', () => {
accessControlTab.getTab().click();
accessControlTab.getHeader().should('be.visible');
accessControlTab.getBankruptcyParty().should('be.visible');
accessControlTab.getOrganisationParty().should('be.visible');
accessControlTab.getPersonParty().should('be.visible');
accessControlTab.getSubUnitParty().should('be.visible');
});

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

Expand All @@ -68,4 +73,18 @@ context('Designer', () => {
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');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ 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['administration.administration'] }),
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'],
}),
};

0 comments on commit 75b1446

Please sign in to comment.