Skip to content

Commit

Permalink
Merge pull request #1733 from NatLibFi/issue1728-groups-cypress-tests
Browse files Browse the repository at this point in the history
Add tests for groups component
  • Loading branch information
UnniKohonen authored Dec 19, 2024
2 parents f1cec44 + e1a4b3f commit 33119f5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/cypress/template/sidebar-groups.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
describe('Groups tab', () => {
it('Loads groups on vocab page', () => {
// Go to test vocab home page
cy.visit('/groups/en/')
// Check that groups tab is available and click it open
cy.get('#groups').should('not.have.class', 'disabled').click({force: true})
// Check that groups includes correct top groups
cy.get('#groups-list li').should('have.length', 3).invoke('text')
.should('contain', 'Fish')
.should('contain', 'Freshwater fish')
.should('contain', 'Saltwater fish')
})
it('Loads groups and expands hierarchy on group page', () => {
// Go to "Freshwater fish" group page
cy.visit('groups/en/page/?uri=http%3A%2F%2Fwww.skosmos.skos%2Fgroups%2Ffresh')
// Check that selected element is "Freshwater fish"
cy.get('#groups-list .selected').should('have.length', 1).invoke('text').should('contain', 'Freshwater fish')
// Check that "Freshwater fish" has 1 child "Carp"
cy.get('#groups-list li:has(.selected)').last().find('ul').should('have.length', 1).invoke('text').should('contain', 'Carp')
// Check that other groups are loaded
cy.get('#groups-list li').invoke('text')
.should('contain', 'Fish')
.should('contain', 'Saltwater fish')
})
it('Loads groups on concept page', () => {
// Go to "Carp" concept page
cy.visit('/groups/en/page/?uri=http%3A%2F%2Fwww.skosmos.skos%2Fgroups%2Fta112')
// Check that groups includes correct top groups
cy.get('#groups-list li').should('have.length', 3).invoke('text')
.should('contain', 'Fish')
.should('contain', 'Freshwater fish')
.should('contain', 'Saltwater fish')
})
it('Loads members and hides them on button click', () => {
// Go to test vocab home page
cy.visit('/groups/en/')
// Click groups tab open
cy.get('#groups').should('not.have.class', 'disabled').click({force: true})
// Click open button of second group
cy.get('#groups-list li button').eq(1).click({force: true})
// Check that child "Carp" is loaded in
cy.get('#groups-list li ul', {'timeout': 15000}).first().children().should('have.length', 1).invoke('text').should('include', 'Carp')
// Click open button again
cy.get('#groups-list li button').eq(1).click({force: true})
// Check that children are hidden
cy.get('#groups-list li ul').should('not.exist')
})
it('Loads members on group click', () => {
// Go to test vocab home page
cy.visit('/groups/en/')
// Click groups tab open
cy.get('#groups').should('not.have.class', 'disabled').click({force: true})
// Click second group
cy.get('#groups-list li a').eq(1).click({force: true})
// Check that children are loaded in
cy.get('#groups-list li ul', {'timeout': 15000}).first().children().should('have.length', 1)
// Check that child is correct
cy.get('#groups-list li ul').invoke('text').should('include', 'Carp')
})
})
1 change: 1 addition & 0 deletions tests/testconfig.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
void:uriSpace "http://www.skosmos.skos/onto/groups/";
skosmos:arrayClass isothes:ThesaurusArray ;
skosmos:groupClass skos:Collection ;
skosmos:defaultConceptSidebarView "groups" ;
skosmos:language "fi", "en";
skosmos:defaultLanguage "fi";
skosmos:indexShowClass meta:TestClass, meta:TestClass2;
Expand Down

0 comments on commit 33119f5

Please sign in to comment.