From 70553e9adbc06f0dd5a295e01aa559a263ae24bd Mon Sep 17 00:00:00 2001 From: Mika Vaara Date: Wed, 15 Nov 2023 10:57:12 +0200 Subject: [PATCH 1/3] Beginning, a draft of the first e2e test --- .../e2e/fp-lang-yso-search-result-vocab.sy.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/cypress/e2e/fp-lang-yso-search-result-vocab.sy.js diff --git a/tests/cypress/e2e/fp-lang-yso-search-result-vocab.sy.js b/tests/cypress/e2e/fp-lang-yso-search-result-vocab.sy.js new file mode 100644 index 000000000..3ae2faf89 --- /dev/null +++ b/tests/cypress/e2e/fp-lang-yso-search-result-vocab.sy.js @@ -0,0 +1,21 @@ +describe('Front page - lang - list - yso - search - result - vocab', () => { + it('should navigate through Finto application', () => { + cy.visit('/en/'); + + cy.contains('Change language').click(); + cy.contains('Suomeksi').click(); + + // Select "YSO - Yleinen suomalainen ontologia" from the vocabulary list + cy.get('#tähän_sopiva_id').select('YSO - Yleinen suomalainen ontologia'); + + cy.visit('/yso/fi/search?query=kissaeläimet'); + + // Select the concept 'kissaeläimet' from the list and go to the concept page + cy.contains('joku sopiva käsite').click(); + + // After transitioning from the search results page to the concept page, you should enter + // on the following page: + cy.url().should('eq', 'https://test.dev.finto.fi/yso/fi/page/p864'); + }); + }); + \ No newline at end of file From 3a3eedc03c72931559ca97cdb5c765654d9cf5c0 Mon Sep 17 00:00:00 2001 From: Mika Vaara Date: Thu, 23 Nov 2023 17:20:15 +0200 Subject: [PATCH 2/3] Added tests iterating through resource and label tables for the vocabulary front page --- tests/cypress/template/vocab-home.cy.js | 134 ++++++++++++++++++++---- 1 file changed, 113 insertions(+), 21 deletions(-) diff --git a/tests/cypress/template/vocab-home.cy.js b/tests/cypress/template/vocab-home.cy.js index 8cdb756aa..1c8bed078 100644 --- a/tests/cypress/template/vocab-home.cy.js +++ b/tests/cypress/template/vocab-home.cy.js @@ -1,42 +1,134 @@ describe('Vocabulary home page', () => { it('contains vocabulary title', () => { - cy.visit('/test/en') // go to the "Test ontology" home page + cy.visit('/yso/en') // Go to the "YSO - General Finnish ontology (archaeology)" home page - // check that the vocabulary title is correct - cy.get('#vocab-title > a').invoke('text').should('equal', 'Test ontology') + // Check that the vocabulary title is not empty + cy.get('#vocab-title > a').invoke('text').should('equal', 'YSO - General Finnish ontology (archaeology)') }) it('shows alphabetical index letters', () => { - cy.visit('/test/en') // go to the "Test ontology" home page + cy.visit('/yso/en') // Go to the "YSO - General Finnish ontology (archaeology)" home page const letters = cy.get('#tab-alphabetical .pagination').children() - // check that we have the correct number of letters - letters.should('have.length', 8) + // Check that we have the correct number of letters + letters.should('have.length', 23) - // check that the first letter is B - letters.first().invoke('text').should('equal', 'B') + // Check that the first letter is A + letters.first().invoke('text').should('equal', 'A') }) it('shows alphabetical index entries', () => { - cy.visit('/test/en') // go to the "Test ontology" home page + cy.visit('/yso/en') // Go to the "YSO - General Finnish ontology (archaeology)" home page - const entries = cy.get('#tab-alphabetical .sidebar-list').children() + const entries = cy.get('#alpha-list').children() - // check that we have the correct number of entries - entries.should('have.length', 3) + // Check that we have the correct number of entries + entries.should('have.length', 33) - // check that the first entry is Bass - entries.first().invoke('text').should('equal', 'Bass') + // Check that the first entry is "abstract objects" + entries.first().invoke('text').should('equal', 'abstract objects') }) it('alphabetical index letters are clickable', () => { - cy.visit('/test/en') // go to the "Test ontology" home page + cy.visit('/yso/en') // Go to the "YSO - General Finnish ontology (archaeology)" home page - // click on the second letter (C) - cy.get('#tab-alphabetical .pagination :nth-child(2) > .page-link').click() + // Click on the second letter (D) + cy.get('#tab-alphabetical .pagination :nth-child(4) > .page-link').click() - // check that we have the correct number of entries - cy.get('#tab-alphabetical .sidebar-list').children().should('have.length', 2) + // Check that we have the correct number of entries + cy.get('#alpha-list').children().should('have.length', 8) - // check that the first entry is Carp - cy.get('#tab-alphabetical .sidebar-list').children().first().invoke('text').should('equal', 'Carp') + // check that the first entry is "dating (age estimation)" + cy.get('#alpha-list').children().first().invoke('text').should('equal', 'dating (age estimation)') }) }) + +// The purpose of the test is to go through the table on the vocabulary's front page +// displaying the counts of resources by type +describe('Check Resource Counts', () => { + it('should check all the resource types, quantities and corresponding headers', () => { + // Go to the "YSO - General Finnish ontology (archaeology)" home page + cy.visit('/yso/en/'); + // Checks if the header "Resource counts by type" exists + cy.get('#resource-counts h3').should('contain.text', 'Resource counts by type'); + + // Setting up conditions for the 'Resource counts by type' test using an array of objects + // representing concept types and their occurrences, which will be utilized later in the test + const expectedData = [ + { type: 'Concept', count: '270' }, + { type: '* Käytöstä poistettu käsite', count: '0' }, + { type: 'Collection', count: '1' }, + ]; + + // Iterating through the array containing data objects (concept types and corresponding counts) + // to check if the values on the table are correct + expectedData.forEach(({ type, count }) => { + cy.get('#resource-stats') + .contains('tr', type) + .within(() => { + cy.get('td').eq(1).should('have.text', count); + }); + }); + + // To make the code more concise: headers as an array that can be looped later + const headerTexts = [ + 'Type', + 'Count', + 'Concept', + '* Käytöstä poistettu käsite', + 'Collection', + ]; + + // Checks that the texts of the headers are correct + headerTexts.forEach((text) => { + cy.get('#resource-stats').should('contain.text', text); + }); + }); +}); + +// The purpose of the test is to verify that the headers of the "label table" are correct and that +// the corresponding counts for each label type are accurate +describe('Check names of the labels in all used languages and corresponding quantities', () => { + it('should go through the names of labels and their corresponding counts, grouped by language', () => { + // Go to the "YSO - General Finnish ontology (archaeology)" home page + cy.visit('/yso/en/'); + + // Verifying the correctness of the term table header + cy.get('#term-counts h3').should('contain.text', 'Term counts by language'); + + // A table containing objects for later verification of the correctness of labels in + // different languages and their corresponding quantities + const expectedData = [ + { language: 'English', prefLabel: '267', altLabel: '46', hiddenLabel: '178' }, + { language: 'Finnish', prefLabel: '270', altLabel: '113', hiddenLabel: '209' }, + { language: 'Northern Sami', prefLabel: '171', altLabel: '13', hiddenLabel: '83' }, + { language: 'Swedish', prefLabel: '270', altLabel: '191', hiddenLabel: '191' }, + ]; + + // Iterating through a table that contains the names of each language, corresponding labels, and their quantities + expectedData.forEach(({ language, prefLabel, altLabel, hiddenLabel }) => { + cy.get('#term-stats') + .contains('tr', language) + .within(() => { + cy.get('td').eq(1).should('have.text', prefLabel); + cy.get('td').eq(2).should('have.text', altLabel); + cy.get('td').eq(3).should('have.text', hiddenLabel); + }); + }); + + // A table used to later iterate and check that the column headers are correct + const columnHeaders = ['Concept language', 'Preferred terms', 'Alternate terms', 'Hidden terms']; + + // Iterating over the column headers listed above + columnHeaders.forEach((header) => { + cy.get('#term-stats th').should('contain.text', header); + }); + + // A table containing the names of languages used in concepts for later iteration + const languages = ['English', 'Finnish', 'Northern Sami', 'Swedish']; + + // Looping through the array containing language names to verify the accuracy of them + languages.forEach((language) => { + cy.get('#term-stats td').should('contain.text', language); + }); + }); +}); + From 11e619c16208ff67641586447633fabc03c0c698 Mon Sep 17 00:00:00 2001 From: Mika Vaara Date: Thu, 23 Nov 2023 17:27:29 +0200 Subject: [PATCH 3/3] Unnecessary file removed --- .../e2e/fp-lang-yso-search-result-vocab.sy.js | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 tests/cypress/e2e/fp-lang-yso-search-result-vocab.sy.js diff --git a/tests/cypress/e2e/fp-lang-yso-search-result-vocab.sy.js b/tests/cypress/e2e/fp-lang-yso-search-result-vocab.sy.js deleted file mode 100644 index 3ae2faf89..000000000 --- a/tests/cypress/e2e/fp-lang-yso-search-result-vocab.sy.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('Front page - lang - list - yso - search - result - vocab', () => { - it('should navigate through Finto application', () => { - cy.visit('/en/'); - - cy.contains('Change language').click(); - cy.contains('Suomeksi').click(); - - // Select "YSO - Yleinen suomalainen ontologia" from the vocabulary list - cy.get('#tähän_sopiva_id').select('YSO - Yleinen suomalainen ontologia'); - - cy.visit('/yso/fi/search?query=kissaeläimet'); - - // Select the concept 'kissaeläimet' from the list and go to the concept page - cy.contains('joku sopiva käsite').click(); - - // After transitioning from the search results page to the concept page, you should enter - // on the following page: - cy.url().should('eq', 'https://test.dev.finto.fi/yso/fi/page/p864'); - }); - }); - \ No newline at end of file