Skip to content

Commit

Permalink
pkp#8346 Add Cypress command to change the UI language
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr committed Apr 10, 2023
1 parent ec030fb commit 63fd0ae
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Cypress.Commands.add('dispatchTestQueueJobs', (times) => {

times = times || 1;
for (let index = 0; index < times; index++) {
cy.exec('php lib/pkp/tools/jobs.php test');
cy.exec('php lib/pkp/tools/jobs.php test');
}
});

Expand Down Expand Up @@ -866,3 +866,21 @@ Cypress.Commands.add('uploadSubmissionFiles', (files, options) => {
});
});
});

Cypress.Commands.add('changeLanguage', (locale, 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();
});

0 comments on commit 63fd0ae

Please sign in to comment.