-
Notifications
You must be signed in to change notification settings - Fork 95
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
Issue1476: cypress tests for vocab home page tempate statistics #1564
Open
miguelvaara
wants to merge
6
commits into
main
Choose a base branch
from
issue1476-cypress-tests-for-vocab-home-page-tempate-statistics-updated
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
70553e9
Beginning, a draft of the first e2e test
miguelvaara 2f38c45
Merge branch 'skosmos-3' of https://github.com/NatLibFi/Skosmos into …
miguelvaara b9c22ad
Merge branch 'skosmos-3' of https://github.com/NatLibFi/Skosmos into …
miguelvaara 97ed2fc
Merge branch 'skosmos-3' of https://github.com/NatLibFi/Skosmos into …
miguelvaara 3a3eedc
Added tests iterating through resource and label tables for the vocab…
miguelvaara 11e619c
Unnecessary file removed
miguelvaara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same URL issue here, and below a few more times |
||
|
||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be "fourth letter"? |
||
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); | ||
}); | ||
}); | ||
}); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL should be
/yso/en/
with the final slash included. (This was also wrong in the previous version)The URL without the final slash will work, but there is an extra redirect because it's not the "canonical" URL of the vocabulary home page.