From 05d1ac7ade53c88c4b717118146fe9db9cbc7242 Mon Sep 17 00:00:00 2001 From: Unni Kohonen Date: Thu, 25 Apr 2024 11:28:51 +0300 Subject: [PATCH 1/3] Fetch letters and concepts based on content language --- resource/js/tab-alpha.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resource/js/tab-alpha.js b/resource/js/tab-alpha.js index 46560534..775321fd 100644 --- a/resource/js/tab-alpha.js +++ b/resource/js/tab-alpha.js @@ -42,7 +42,7 @@ const tabAlphaApp = Vue.createApp({ this.loadingLetters = true // Remove scrolling event listener while letters are loaded this.$refs.tabAlpha.$refs.list.removeEventListener('scroll', this.handleScrollEvent) - fetch('rest/v1/' + window.SKOSMOS.vocab + '/index/?lang=' + window.SKOSMOS.lang) + fetch('rest/v1/' + window.SKOSMOS.vocab + '/index/?lang=' + window.SKOSMOS.content_lang) .then(data => { return data.json() }) @@ -58,7 +58,7 @@ const tabAlphaApp = Vue.createApp({ this.currentOffset = 0 // Remove scrolling event listener while concepts are loaded this.$refs.tabAlpha.$refs.list.removeEventListener('scroll', this.handleScrollEvent) - const url = 'rest/v1/' + window.SKOSMOS.vocab + '/index/' + letter + '?lang=' + window.SKOSMOS.lang + '&limit=250' + const url = 'rest/v1/' + window.SKOSMOS.vocab + '/index/' + letter + '?lang=' + window.SKOSMOS.content_lang + '&limit=250' fetchWithAbort(url, 'alpha') .then(data => { return data.json() @@ -83,7 +83,7 @@ const tabAlphaApp = Vue.createApp({ this.loadingMoreConcepts = true // Remove scrolling event listener while new concepts are loaded this.$refs.tabAlpha.$refs.list.removeEventListener('scroll', this.handleScrollEvent) - const url = 'rest/v1/' + window.SKOSMOS.vocab + '/index/' + this.selectedLetter + '?lang=' + window.SKOSMOS.lang + '&limit=250&offset=' + this.currentOffset + const url = 'rest/v1/' + window.SKOSMOS.vocab + '/index/' + this.selectedLetter + '?lang=' + window.SKOSMOS.content_lang + '&limit=250&offset=' + this.currentOffset fetchWithAbort(url, 'alpha') .then(data => { return data.json() From 6e2a188ea9118415e78fcb220ac9d0a6eece2f02 Mon Sep 17 00:00:00 2001 From: Unni Kohonen Date: Thu, 25 Apr 2024 13:31:23 +0300 Subject: [PATCH 2/3] Add cypress test --- tests/cypress/template/sidebar.cy.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/cypress/template/sidebar.cy.js b/tests/cypress/template/sidebar.cy.js index 38e50739..53393be3 100644 --- a/tests/cypress/template/sidebar.cy.js +++ b/tests/cypress/template/sidebar.cy.js @@ -12,4 +12,12 @@ describe('Sidebar', () => { cy.get('#sidebar-tabs').find('.active').should('have.length', 1) cy.get('.tab-content').find('.active').should('have.length', 1) }) + it('Concepts and letters in alphabetical index are displayed in the correct language', () => { + // go to YSO vocab from page with UI language in English and content language in Finnish + cy.visit('/yso/en/?clang=fi') + // check that first item in the list is in the correct language + cy.get('#tab-alphabetical .sidebar-list a').first().invoke('text').should('contain', 'aarrelöydöt') + // check that letters contain Y and not C + cy.get('#tab-alphabetical .pagination a').invoke('text').should('contain', 'Y').should('not.contain', 'C') + }) }) From 199305d7ad38790bef96348c7ec2128055689f04 Mon Sep 17 00:00:00 2001 From: Unni Kohonen Date: Thu, 25 Apr 2024 13:43:30 +0300 Subject: [PATCH 3/3] Fix typo --- tests/cypress/template/sidebar.cy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cypress/template/sidebar.cy.js b/tests/cypress/template/sidebar.cy.js index 53393be3..df46b662 100644 --- a/tests/cypress/template/sidebar.cy.js +++ b/tests/cypress/template/sidebar.cy.js @@ -13,9 +13,9 @@ describe('Sidebar', () => { cy.get('.tab-content').find('.active').should('have.length', 1) }) it('Concepts and letters in alphabetical index are displayed in the correct language', () => { - // go to YSO vocab from page with UI language in English and content language in Finnish + // go to YSO vocab from page with UI language set to English and content language set to Finnish cy.visit('/yso/en/?clang=fi') - // check that first item in the list is in the correct language + // check that the first item in the list is in the correct language cy.get('#tab-alphabetical .sidebar-list a').first().invoke('text').should('contain', 'aarrelöydöt') // check that letters contain Y and not C cy.get('#tab-alphabetical .pagination a').invoke('text').should('contain', 'Y').should('not.contain', 'C')