Skip to content

Commit

Permalink
Fix failing Cypress tests (#11853)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasEng authored Dec 13, 2023
1 parent c8303a2 commit 6505582
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
3 changes: 2 additions & 1 deletion frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
"general.date": "Dato",
"general.date_time_format": "{{date}} kl. {{time}}",
"general.delete": "Slett",
"general.delete_item": "Slett {{item}}",
"general.details": "Detaljer",
"general.disabled": "Deaktivert",
"general.edit": "Endre",
Expand Down Expand Up @@ -1585,4 +1586,4 @@
"validation_errors.pattern": "Feil format eller verdi",
"validation_errors.required": "Feltet er påkrevd",
"validation_errors.value_as_url": "Ugyldig lenke"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('PageAccordion', () => {
jest.spyOn(window, 'confirm').mockImplementation(jest.fn(() => true));
await render();

await screen.getByRole('button', { name: textMock('general.delete') }).click();
await screen.getByRole('button', { name: textMock('general.delete_item', { item: mockPageName1 }) }).click();
expect(mockDeleteFormLayout).toHaveBeenCalledTimes(1);
expect(mockDeleteFormLayout).toHaveBeenCalledWith(mockPageName1);
expect(mockSetSearchParams).toHaveBeenCalledWith({ layout: mockPageName2 });
Expand All @@ -86,7 +86,7 @@ describe('PageAccordion', () => {
it('Does not call deleteLayout when delete button is clicked, but deletion is not confirmed', async () => {
jest.spyOn(window, 'confirm').mockImplementation(jest.fn(() => false));
await render();
await screen.getByRole('button', { name: textMock('general.delete') }).click();
await screen.getByRole('button', { name: textMock('general.delete_item', { item: mockPageName1 }) }).click();
expect(mockDeleteFormLayout).not.toHaveBeenCalled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export const PageAccordion = ({
<NavigationMenu pageName={pageName} pageIsReceipt={pageIsReceipt} />
<Button
color='danger'
icon={<TrashIcon />}
icon={<TrashIcon aria-hidden />}
onClick={handleConfirmDelete}
title={t('general.delete')}
title={t('general.delete_item', { item: pageName })}
variant='tertiary'
size='small'
/>
Expand Down
16 changes: 1 addition & 15 deletions frontend/testing/cypress/src/integration/studio/designer.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ context('Designer', () => {
.findByRole('treeitem', { name: texts['ux_editor.component_title.Input'] });

// Do not need to confirm alert.confirm dialog, since Cypress default to click "Ok".
cy.findByTitle(texts['general.delete']).click({ force: true });
cy.findByTitle(texts['general.delete_item'].replace('{{item}}', 'Side1')).click({ force: true });
});

it('should add navigation buttons when adding more than one page', () => {
Expand All @@ -68,25 +68,11 @@ context('Designer', () => {
cy.wait('@postLayoutSettings').its('response.statusCode').should('eq', 200);
cy.wait('@getLayoutSettings').its('response.statusCode').should('eq', 200);

cy.findByRole('button', { name: 'Side2' }).click();

designer
.getPageAccordionByName('Side2')
.findByRole('treeitem', { name: `${texts['ux_editor.component_title.NavigationButtons']}` });

// Do not need to confirm alert.confirm dialog, since Cypress default to click "Ok".
cy.findByTitle(texts['general.delete']).click({ force: true });
});

// Disabled for now, as this generates too many copies of the same app
// it('is possible to delete local changes of an app ', () => {
// cy.searchAndOpenApp(Cypress.env('designerAppName'));
// cy.intercept('GET', '**/layout-settings').as('getLayoutSettings');
// cy.get(designer.appMenu['edit']).click();
// cy.wait('@getLayoutSettings');
// cy.get("button[aria-label='Legg til ny side']").click();
// cy.get(designer.formComponents.longAnswer).parents(designer.draggable).trigger('dragstart');
// cy.get(designer.dragToArea).trigger('drop');
// cy.deleteLocalChanges(Cypress.env('designerApp'));
// });
});
2 changes: 1 addition & 1 deletion frontend/testing/cypress/src/selectors/settings.js
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 settings = {
getAppNameField: () =>
cy.findByRole('textbox', { name: texts['settings_modal.about_tab_name_label'] }),
getCloseButton: () => cy.findByRole('button', { name: 'close modal' }),
getCloseButton: () => cy.findByRole('button', { name: texts['modal.close_icon'] }),
};

0 comments on commit 6505582

Please sign in to comment.