Skip to content

Commit

Permalink
Merge pull request DSpace#3461 from tdonohue/i18n_e2e_test
Browse files Browse the repository at this point in the history
Add basic e2e testing for i18n
  • Loading branch information
tdonohue authored Oct 17, 2024
2 parents 12d67ec + a74cd84 commit 34b9124
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cypress/e2e/header.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,29 @@ describe('Header', () => {
// Analyze <ds-header> for accessibility
testA11y('ds-header');
});

it('should allow for changing language to German (for example)', () => {
cy.visit('/');

// Click the language switcher (globe) in header
cy.get('a[data-test="lang-switch"]').click();
// Click on the "Deusch" language in dropdown
cy.get('#language-menu-list li').contains('Deutsch').click();

// HTML "lang" attribute should switch to "de"
cy.get('html').invoke('attr', 'lang').should('eq', 'de');

// Login menu should now be in German
cy.get('a[data-test="login-menu"]').contains('Anmelden');

// Change back to English from language switcher
cy.get('a[data-test="lang-switch"]').click();
cy.get('#language-menu-list li').contains('English').click();

// HTML "lang" attribute should switch to "en"
cy.get('html').invoke('attr', 'lang').should('eq', 'en');

// Login menu should now be in English
cy.get('a[data-test="login-menu"]').contains('Log In');
});
});
1 change: 1 addition & 0 deletions src/app/shared/lang-switch/lang-switch.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
aria-haspopup="menu"
[title]="'nav.language' | translate"
(click)="$event.preventDefault()" data-toggle="dropdown" ngbDropdownToggle
data-test="lang-switch"
tabindex="0">
<i class="fas fa-globe-asia fa-lg fa-fw"></i>
</a>
Expand Down

0 comments on commit 34b9124

Please sign in to comment.