Skip to content

Commit

Permalink
pkp#8346 Try another way to change languages
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr authored and asmecher committed Apr 21, 2023
1 parent 796c843 commit ed9f164
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,21 +867,10 @@ Cypress.Commands.add('uploadSubmissionFiles', (files, options) => {
});
});

Cypress.Commands.add('changeLanguage', (locale, contextPath) => {
Cypress.Commands.add('changeLanguage', (language, contextPath) => {
contextPath = contextPath || 'publicknowledge';

// Workaround to make the request with a referrer
// It is not possible to set the referrer header with cy.visit()
cy.window()
.then((win) => {
const link = win.document.createElement('a');
const url = Cypress.config().baseUrl + '/index.php/' + contextPath + '/user/setLocale/' + locale;
link.setAttribute('href', url);
link.setAttribute('id', 'cypressChangeLanguage');
link.innerHTML = locale;
win.document.body.appendChild(link);
});
cy.get('a#cypressChangeLanguage')
.click();
cy.get('html[lang="' + locale.replace('_', '-') + '"]');
cy.get('.app__userNav > button').click();
cy.get('.app__userNav a:contains("Français")').click();
cy.wait(2000);
});

0 comments on commit ed9f164

Please sign in to comment.