Skip to content

Commit

Permalink
Merge branch 'development' into DES/enhancement/#732-vlc-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
brenner-company committed Apr 30, 2021
2 parents 4f9312a + 4c71ff0 commit b7aaf5b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
2 changes: 2 additions & 0 deletions cypress/integration/unit/click-table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ context('Table Row Click tests', () => {
cy.logout();
});

// TODO add publication table row click test, make sure to have at least 1 publication in default set

it('should open an agenda after clicking a row', () => {
cy.route('GET', '/agendas/**/agendaitems').as('getAgendas');

Expand Down
30 changes: 18 additions & 12 deletions cypress/integration/unit/publication.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ context('Publications tests', () => {
const publicationOverviewUrl = '/publicaties';
const someText = 'Some text';
const shortTitle = 'Korte titel cypress test';
const shortTitle2 = 'Korte titel cypress test gewijzigd';
const shortTitle2 = 'Korte titel cypress test gewijzigd'; // only used in 1 test, `${shortTitle} gewijzigd`
const longTitle = 'Lange titel voor de cypress test die we in de publicatieflow gaan testen.';
const numberToCheck = 200; // used for multiple tests


it('should render error when required fields are not filled in to create new publication', () => {
Expand Down Expand Up @@ -55,6 +56,7 @@ context('Publications tests', () => {
timeout: 5000,
}).should('not.exist');
// both number and shortTitle should show error when empty
// TODO this does not indicate where the errors should be, make selectors for both errors and get those
cy.get(auComponentSelectors.auLabelError).should('have.length', 2);
// Create publication with number and title
// TODO with automatic number suggestion, this test could fail if testdata already contains a publication with number 1
Expand All @@ -76,36 +78,41 @@ context('Publications tests', () => {
cy.wait('@createNewPublicationFlow', {
timeout: 20000,
});
// TODO new way of creating publication-number with structured identifier can be checked with routes
// post case
// post structured identifier
// post identifier
// post publication-flows
});

it('should clear input data when closing and reopening modal to create new publication', () => {
// TODO also test if errors are correctly reset after cancel / new creation
cy.visit(publicationOverviewUrl);
const numberToCheck = 999;
const number = 999;
cy.get(publicationSelectors.newPublicationButton).click();
cy.get(modalSelectors.auModal.container).as('publicationModal');
cy.get('@publicationModal').within(() => {
// TODO check if suffix and long title are cleared
cy.get(modalSelectors.publication.publicationNumberInput)
.click()
.clear()
.type(numberToCheck);
.type(number);
cy.get(modalSelectors.publication.publicationShortTitleTextarea)
.click()
.type(someText);
// Why don't we check the long title text area ?
});
// TODO also test close button
cy.get(modalSelectors.publication.cancelButton).click();
cy.get(publicationSelectors.newPublicationButton).click();
cy.get('@publicationModal').within(() => {
// TODO check the other fields
cy.get(modalSelectors.publication.publicationNumberInput).should('not.contain', numberToCheck);
cy.get(modalSelectors.publication.publicationNumberInput).should('not.contain', number);
cy.contains(someText).should('not.exist');
});
});

it('should create a publication and redirect to its detail page', () => {
cy.visit(publicationOverviewUrl);
const numberToCheck = 200;
cy.get(publicationSelectors.newPublicationButton).click();
cy.get(modalSelectors.auModal.container).as('publicationModal');
cy.get('@publicationModal').within(() => {
Expand All @@ -132,30 +139,28 @@ context('Publications tests', () => {

it('should have an overview of publication-flows and be able to click on it to go to the detail page', () => {
cy.visit(publicationOverviewUrl);

cy.route('/publication-flows/**').as('getNewPublicationDetail');
cy.contains('200').parents('tr')
cy.contains(`${numberToCheck}`).parents('tr')
.within(() => {
cy.get(publicationSelectors.goToPublication)
.click();
});
cy.wait('@getNewPublicationDetail');
// TODO This test is VERY dependent on existing data from previous test, fixing this for now but this will break at some point
cy.get(publicationSelectors.publicationDetailHeaderShortTitle).should('contain', shortTitle);
cy.get(publicationSelectors.publicationDetailHeaderPublicationNumber).should('contain', 'PUBLICATIE - NIET VIA MINISTERRAAD - 200');
cy.get(publicationSelectors.publicationDetailHeaderPublicationNumber).should('contain', `PUBLICATIE - NIET VIA MINISTERRAAD - ${numberToCheck}`);
});

it('should edit inscription and this data must be visible in the overview', () => {
cy.visit(publicationOverviewUrl);

cy.route('/publication-flows/**').as('getNewPublicationDetail');
cy.contains('200').parents('tr')
cy.contains(`${numberToCheck}`).parents('tr')
.within(() => {
cy.get(publicationSelectors.goToPublication)
.click();
});
cy.wait('@getNewPublicationDetail');

// TODO test long title
cy.get(publicationSelectors.editInscriptionButton).click();
cy.get(publicationSelectors.inscriptionShortTitleTextarea).click()
.clear()
Expand Down Expand Up @@ -192,6 +197,7 @@ context('Publications tests', () => {
cy.wait('@getNewPublicationDetail');

// Assert empty.
// TODO get auComponents.auEmptyState met selector
cy.contains('Er zijn nog geen contactpersonen toegevoegd').should('exist');

// Add contactperson.
Expand Down
20 changes: 19 additions & 1 deletion cypress/integration/unit/search.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ context('Search tests', () => {
});
};

// TODO cy.server is used alot throughout these tests, but the one in before should be enough.

it('Should change the amount of elements to every value in selectbox in agendapunten search view', () => {
cy.visit('zoeken/agendapunten');
searchFunction(options);
Expand All @@ -58,10 +60,12 @@ context('Search tests', () => {
const PLACE = 'Lāna Hawaï eiland';
const KIND = 'Ministerraad';
cy.createAgenda(KIND, dateToCreateAgenda, PLACE);
// TODO opening agenda not needed yet
cy.openAgendaForDate(dateToCreateAgenda);

const case1TitleShort = `${testId}Cypress search dossier 1`;
const type1 = 'Nota';
// TODO new lines will be stripped during saving, why have them here ?
const newSubcase1TitleShort = 'dit is de korte titel for search 🔍 Lāna Hawaï eiland\n\n';
const subcase1TitleLong = 'dit is de lange titel for search and searching 🔎 Principiële accénten\n\n';
const subcase1Type = 'In voorbereiding';
Expand All @@ -87,6 +91,8 @@ context('Search tests', () => {
cy.openAgendaForDate(dateToCreateAgenda);
// cy.contains('dit is de korte titel for search 🔍').click();
// UTF8 extende set does not seem to work on database on test server.
// TODO use opendetailofagendaitem and newSubcase1TitleShort to open detail
// TODO, is also not needed because addDocumentsToAgendaitem already does opendetailofagendaitem
cy.contains('dit is de korte titel for search').click();

const file = {
Expand All @@ -97,11 +103,13 @@ context('Search tests', () => {
cy.addDocumentToTreatment(file); // TODO is this saved? Command does not include saving

cy.openAgendaForDate(dateToCreateAgenda);
// TODO use opendetailofagendaitem and newSubcase1TitleShort to open detail
cy.contains('dit is de korte titel for search').click();
cy.get(agenda.agendaitemTitlesEdit).should('exist')
.should('be.visible')
.click();

// TODO confidential toggle, use better selector ?
cy.get(form.formVlToggle).should('exist')
.click();

Expand All @@ -117,23 +125,27 @@ context('Search tests', () => {
cy.get(agenda.agendaitemTitlesEditSave).should('exist')
.should('be.visible')
.click();
// TODO we don't await patch calls, is data saved properly ?
});

it('Search for non existing searchterm in agendaitems', () => {
cy.visit('/zoeken/agendapunten');
cy.get('[data-test-searchfield]').clear();
cy.get('[data-test-searchfield]').type('nietstezienhier');

cy.server();
cy.server(); // TODO server here not needed ?
cy.route('GET', '/agendaitems/search?**').as('searchCall');
cy.get('button[data-test-trigger-search]').click();
cy.wait('@searchCall');

cy.get('[data-table]').should('not.exist');
// TODO not existing of data table could have multiple reasons (still loading, error)
// TODO check auEmptyState and text instead "Er werden geen resultaten gevonden. Pas je trefwoord en filters aan."
});

it('Search for funky searchterms in agendaitems', () => {
cy.visit('/zoeken/agendapunten');
// TODO reenable to check if autocomplete works better now ? (+7 months later)
const wordsToCheck1 = [
'peerd',
/* 'peer', // TODO autocomplete search does not yet work here.*/
Expand All @@ -149,12 +161,14 @@ context('Search tests', () => {
cy.get('button[data-test-trigger-search]').click();
cy.wait('@searchCall');

// TODO use newSubcase2TitleShort instead of fixed data
cy.get('[data-table]').contains('korte titel for batterij');
});

cy.get('[data-test-m-header-settings]').click();
cy.wait(1000);
cy.get('[data-test-m-header-search]').click();
// TODO reenable reset test ?
// https://github.com/kanselarij-vlaanderen/kaleidos-frontend/blob/a30ff5fa756691b824031c5c069d906b70d67b09/app/pods/search/index/route.js#L10
// cy.wait(1000);
// cy.get('[data-test-searchfield]').should('have.value', '');
Expand Down Expand Up @@ -199,7 +213,9 @@ context('Search tests', () => {
cy.get('button[data-test-trigger-search]').click();
cy.wait('@casesSearchCall');

// TODO case1TitleShort instead of hardcoded text
cy.get('[data-table]').contains('Cypress search dossier 1');
// TODO assert some of the words will aso yield dosser 2 as result, some don't. Assert we dont always show all cases
});
});

Expand Down Expand Up @@ -227,6 +243,7 @@ context('Search tests', () => {
it('Search for funky searchterms in agenda overview', () => {
cy.openAgendaForDate(dateToCreateAgenda);

// TODO use const data instead of harcoded text, better selectors
cy.get('.vlc-agenda-items').contains('titel for batterij');
cy.get('.vlc-agenda-items').contains('titel for search');

Expand All @@ -239,6 +256,7 @@ context('Search tests', () => {
cy.wait('@searchCallOverview-IKBESTANIET');

// Should find nothing.
// TODO why twice ?
cy.get('.vlc-agenda-items').contains('Er zijn nog geen agendapunten in deze agenda.');
cy.get('.vlc-agenda-items').contains('Er zijn nog geen mededelingen in deze agenda.');

Expand Down
4 changes: 4 additions & 0 deletions cypress/integration/unit/session-kind.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ context('Different session kinds should show different titles', () => {
cy.logout();
});

// TODO PVV agenda

it('should show the correct translations for normal session in decision print overview', () => {
const textToDisplay = 'Beslissingen van de Vlaamse Regering - Ministerraad van';
cy.visit(regular);
Expand Down Expand Up @@ -68,7 +70,9 @@ context('Different session kinds should show different titles', () => {
cy.visit(regular);
cy.get(actionModal.showActionOptions).click();
cy.get(actionModal.navigatetonewsletter).click();
// TODO testselector could include "header"
cy.get(newsletter.overviewTitle).contains(textToDisplay);
// TODO verify klad & definitief ?
});

it('should show the correct translations for special session in newsletter-info print overview', () => {
Expand Down

0 comments on commit b7aaf5b

Please sign in to comment.