Skip to content

Commit

Permalink
Add basic e2e testing for i18n
Browse files Browse the repository at this point in the history
(cherry picked from commit a74cd84)
  • Loading branch information
tdonohue authored and github-actions[bot] committed Oct 17, 2024
1 parent e9db8d8 commit b29a12d
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 b29a12d

Please sign in to comment.