Skip to content

Commit

Permalink
Add cypress files for alphabetical index and hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
UnniKohonen committed Oct 3, 2024
1 parent c287539 commit 28b176c
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 89 deletions.
64 changes: 64 additions & 0 deletions tests/cypress/template/sidebar-alpha.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
describe('Alphabetical index', () => {
it('Loads letters and concepts on page load', () => {
// Go to YSO vocab home page
cy.visit('/yso/en/')
// Check that letter pagination exists and has the right number of items
cy.get('#tab-alphabetical').find('.pagination li').should('have.length', 23)
// Check that the first letter is correct
cy.get('#tab-alphabetical').find('.pagination li').first().invoke('text').should('contain', 'A')
// Check that alphabetical list exists and has the right concepts
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', 'abstract objects')
})
it('Loads letters and concepts on tab open', () => {
// Go to "properties" YSO concept page
cy.visit('/yso/en/page/p2742')
// Click on alphabetical index tab
cy.get('#alphabetical').click()
// Check that letter pagination exists and has the right number of items
cy.get('#tab-alphabetical').find('.pagination li').should('have.length', 23)
// Check that the first letter is correct
cy.get('#tab-alphabetical').find('.pagination li').first().invoke('text').should('contain', 'A')
// Check that alphabetical list exists and has the right concepts
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', 'abstract objects')
})
it('Loads concepts on letter change', () => {
// Go to YSO vocab home page
cy.visit('/yso/en/')
// Click on second pagination item
cy.get('#tab-alphabetical').find('.pagination li').eq(1).click()
// Check that alphabetical list has the right concepts
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', 'birch bark manuscripts')
})
it('Concepts and letters in alphabetical index are displayed in the correct language', () => {
// Go to YSO vocab page with UI language set to English and content language set to Finnish
cy.visit('/yso/en/?clang=fi')
// Check that letters contain Y and not C
cy.get('#tab-alphabetical').find('.pagination li').invoke('text').should('contain', 'Y').should('not.contain', 'C')
// Check that the first item in the list is in the correct language
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', 'aarrelöydöt')
})
it('Shows altLabels', () => {
// Go to YSO vocab home page
cy.visit('/yso/fi/')
// Check that notation codes are displayed
cy.get('#tab-alphabetical').find('.sidebar-list li').eq(2).invoke('text').should('contain', 'aDNA').should('contain', 'muinais-DNA')
})
it('Shows notation codes', () => {
// Go to vocab home page in a vocab with notation codes in alphabetical index
cy.visit('/test-notation-sort/en/')
// Check that notation codes are displayed
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', '(33.02)')
})
it('Loads concepts on scroll', () => {
// Go to YSO vocab home page
cy.visit('/modified-vocab/fi/')
// Scroll to the bottom of sidebar list
cy.get('#tab-alphabetical').find('.sidebar-list').scrollTo('bottom')
// Check that new concepts have been loaded
cy.get('#tab-alphabetical').find('.sidebar-list li').should('have.length', 500, {'timeout': 20000})
// Scroll to the bottom of sidebar list again
cy.get('#tab-alphabetical').find('.sidebar-list').scrollTo('bottom')
// Check that new concepts have been loaded
cy.get('#tab-alphabetical').find('.sidebar-list li').should('have.length.gt', 500, {'timeout': 20000})
})
})
23 changes: 23 additions & 0 deletions tests/cypress/template/sidebar-hierarchy.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe('Hierarchy', () => {
it('Sorts concepts based on labels', () => {
// Go to "properties" concept page in a vocab with sorting based on labels
cy.visit('/yso/en/page/p2742')
// First and second concepts in hierarchy should be sorted by label
cy.get('#hierarchy-list .list-group-item').eq(0).find('.concept-label').invoke('text').should('contain', 'events and action')
cy.get('#hierarchy-list .list-group-item').eq(1).find('.concept-label').invoke('text').should('contain', 'objects')
})
it('Sorts concepts based on notation codes in lexical order', () => {
// Go to "Tuna" concept page in a vocab with lexical sorting
cy.visit('/test-notation-sort/en/page/?uri=http%3A%2F%2Fwww.skosmos.skos%2Ftest%2Fta0111')
// First and second concepts in hierarchy should be sorted by notation codes in lexical order
cy.get('#hierarchy-list .list-group-item').eq(1).find('.concept-notation').invoke('text').should('equal', '33.01')
cy.get('#hierarchy-list .list-group-item').eq(2).find('.concept-notation').invoke('text').should('equal', '33.02')
})
it('Sorts concepts based on notation codes in natural order', () => {
// Go to "Tuna" concept page in a vocab with natural sorting
cy.visit('/testNotation/en/page/?uri=http%3A%2F%2Fwww.skosmos.skos%2Ftest%2Fta0111')
// First and second concepts in hierarchy should be sorted by notation codes in natural order
cy.get('#hierarchy-list .list-group-item').eq(1).find('.concept-notation').invoke('text').should('equal', '33.1')
cy.get('#hierarchy-list .list-group-item').eq(2).find('.concept-notation').invoke('text').should('equal', '33.01')
})
})
89 changes: 0 additions & 89 deletions tests/cypress/template/sidebar.cy.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,3 @@
describe('Alphabetical index', () => {
it('Loads letters and concepts on page load', () => {
// Go to YSO vocab home page
cy.visit('/yso/en/')
// Check that letter pagination exists and has the right number of items
cy.get('#tab-alphabetical').find('.pagination li').should('have.length', 23)
// Check that the first letter is correct
cy.get('#tab-alphabetical').find('.pagination li').first().invoke('text').should('contain', 'A')
// Check that alphabetical list exists and has the right concepts
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', 'abstract objects')
})
it('Loads letters and concepts on tab open', () => {
// Go to "properties" YSO concept page
cy.visit('/yso/en/page/p2742')
// Click on alphabetical index tab
cy.get('#alphabetical').click()
// Check that letter pagination exists and has the right number of items
cy.get('#tab-alphabetical').find('.pagination li').should('have.length', 23)
// Check that the first letter is correct
cy.get('#tab-alphabetical').find('.pagination li').first().invoke('text').should('contain', 'A')
// Check that alphabetical list exists and has the right concepts
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', 'abstract objects')
})
it('Loads concepts on letter change', () => {
// Go to YSO vocab home page
cy.visit('/yso/en/')
// Click on second pagination item
cy.get('#tab-alphabetical').find('.pagination li').eq(1).click()
// Check that alphabetical list has the right concepts
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', 'birch bark manuscripts')
})
it('Concepts and letters in alphabetical index are displayed in the correct language', () => {
// Go to YSO vocab page with UI language set to English and content language set to Finnish
cy.visit('/yso/en/?clang=fi')
// Check that letters contain Y and not C
cy.get('#tab-alphabetical').find('.pagination li').invoke('text').should('contain', 'Y').should('not.contain', 'C')
// Check that the first item in the list is in the correct language
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', 'aarrelöydöt')
})
it('Shows altLabels', () => {
// Go to YSO vocab home page
cy.visit('/yso/fi/')
// Check that notation codes are displayed
cy.get('#tab-alphabetical').find('.sidebar-list li').eq(2).invoke('text').should('contain', 'aDNA').should('contain', 'muinais-DNA')
})
it('Shows notation codes', () => {
// Go to vocab home page in a vocab with notation codes in alphabetical index
cy.visit('/test-notation-sort/en/')
// Check that notation codes are displayed
cy.get('#tab-alphabetical').find('.sidebar-list li').first().invoke('text').should('contain', '(33.02)')
})
it('Loads concepts on scroll', () => {
// Go to YSO vocab home page
cy.visit('/modified-vocab/fi/')
// Scroll to the bottom of sidebar list
cy.get('#tab-alphabetical').find('.sidebar-list').scrollTo('bottom')
// Check that new concepts have been loaded
cy.get('#tab-alphabetical').find('.sidebar-list li').should('have.length', 500, {'timeout': 20000})
// Scroll to the bottom of sidebar list again
cy.get('#tab-alphabetical').find('.sidebar-list').scrollTo('bottom')
// Check that new concepts have been loaded
cy.get('#tab-alphabetical').find('.sidebar-list li').should('have.length.gt', 500, {'timeout': 20000})
})
})

describe('Sidebar', () => {
it('Contains tabs', () => {
// go to the Skosmos front page
Expand All @@ -78,27 +13,3 @@ describe('Sidebar', () => {
cy.get('.tab-content').find('.active').should('have.length', 1)
})
})

describe('Hierarchy', () => {
it('Sorts concepts based on labels', () => {
// Go to "properties" concept page in a vocab with sorting based on labels
cy.visit('/yso/en/page/p2742')
// First and second concepts in hierarchy should be sorted by label
cy.get('#hierarchy-list .list-group-item').eq(0).find('.concept-label').invoke('text').should('contain', 'events and action')
cy.get('#hierarchy-list .list-group-item').eq(1).find('.concept-label').invoke('text').should('contain', 'objects')
})
it('Sorts concepts based on notation codes in lexical order', () => {
// Go to "Tuna" concept page in a vocab with lexical sorting
cy.visit('/test-notation-sort/en/page/?uri=http%3A%2F%2Fwww.skosmos.skos%2Ftest%2Fta0111')
// First and second concepts in hierarchy should be sorted by notation codes in lexical order
cy.get('#hierarchy-list .list-group-item').eq(1).find('.concept-notation').invoke('text').should('equal', '33.01')
cy.get('#hierarchy-list .list-group-item').eq(2).find('.concept-notation').invoke('text').should('equal', '33.02')
})
it('Sorts concepts based on notation codes in natural order', () => {
// Go to "Tuna" concept page in a vocab with natural sorting
cy.visit('/testNotation/en/page/?uri=http%3A%2F%2Fwww.skosmos.skos%2Ftest%2Fta0111')
// First and second concepts in hierarchy should be sorted by notation codes in natural order
cy.get('#hierarchy-list .list-group-item').eq(1).find('.concept-notation').invoke('text').should('equal', '33.1')
cy.get('#hierarchy-list .list-group-item').eq(2).find('.concept-notation').invoke('text').should('equal', '33.01')
})
})

0 comments on commit 28b176c

Please sign in to comment.