Path: blob/main/cypress/integration/translations/locales.spec.js
3855 views
/// <reference types="cypress" />12describe('Language Selector Macbook-15', () => {3beforeEach(() => {4cy.viewport('macbook-15')5.visit('/course/ch-prerequisites/introduction-to-python-and-jupyter-notebooks')67// set cookies to prevent IBM privacy policy popup8.setCookie('cmapi_cookie_privacy', 'permit_1|2|3')9.setCookie('cmapi_gtm_bl', '')10.setCookie('notice_gdpr_prefs', '0|1|2:')11.setCookie('notice_preferences', '2:')1213.reload()14})1516it('Can select a non-English, translated language', () => {17// navigate to page w/ translations18cy.url().should('include', '/ch-prerequisites/introduction-to-python-and-jupyter-notebooks')19// select Japanese20cy.get('.language-selector__dropdown').shadow().find('.bx--list-box__field').click()21cy.get('.language-selector__dropdown > .language-selector__item').contains('Japanese').click()2223cy.url().should('include', '?hl=ja')24cy.get('.language-selector__dropdown')25.shadow()26.find('#trigger-label')27.should('have.text', 'Japanese')2829// lang attribute30cy.get('html').should('have.attr', 'lang', 'ja')31})3233it('Can select the English version', () => {34// navigate to page w/ translations35cy.url().should('include', '/ch-prerequisites/introduction-to-python-and-jupyter-notebooks')3637// select Japanese38cy.get('.language-selector__dropdown').shadow().find('.bx--list-box__field').click()39cy.get('.language-selector__dropdown > .language-selector__item').contains('Japanese').click()40cy.url().should('include', '?hl=ja')4142// select English43cy.get('.language-selector__dropdown').shadow().find('.bx--list-box__field').click()44cy.get('.language-selector__dropdown > .language-selector__item').contains('English').click()4546cy.url().should('not.include', '?hl')47cy.get('.language-selector__dropdown')48.shadow()49.find('#trigger-label')50.should('have.text', 'English')5152// lang attribute53cy.get('html').should('have.attr', 'lang', 'en')54})5556it('Can render translate toggle button properly', () => {57// navigate to page w/ translations58cy.url().should('include', '/ch-prerequisites/introduction-to-python-and-jupyter-notebooks')5960// hide index61cy.get('#app-panel-footer-toggle').click()62cy.get('.language-selector').should('not.be.visible')63cy.get('#app-panel-language-toggle').should('be.visible')64})6566it('Can show LanguageSelector options when translate toggle button is clicked', () => {67// navigate to page w/ translations68cy.url().should('include', '/ch-prerequisites/introduction-to-python-and-jupyter-notebooks')6970// hide index71cy.get('#app-panel-footer-toggle').click()72cy.get('#app-panel-language-toggle').should('be.visible')73// show index74cy.get('#app-panel-language-toggle').click()75cy.get('.language-selector').should('be.visible')7677cy.get('.language-selector__dropdown > .language-selector__item').contains('English').should('be.visible')78cy.get('.language-selector__dropdown > .language-selector__item').contains('Japanese').should('be.visible')79})8081it('Should not show the unavailable language indicator', () => {82// navigate to page w/ translations83cy.url().should('include', '/ch-prerequisites/introduction-to-python-and-jupyter-notebooks')8485// click on the language selector drop down86cy.get('[data-test=language-selector]')87.shadow()88.find('[part=trigger-button]')89.click()9091// check the language option does not have an indicator92cy.get('[data-test=language-select-ja]')93.find('[data-test=language-select-tooltip]')94.should('not.exist')95})9697it('Should show the unavailable language indicator', () => {98// navigate to page w/o translations99cy.visit('/problem-sets/single_systems_problem_set')100cy.url().should('include', '/problem-sets/single_systems_problem_set')101102// click on the language selector drop down103cy.get('[data-test=language-selector]')104.shadow()105.find('[part=trigger-button]')106.click()107108// check the language option does have an indicator and no message visible109cy.get('[data-test=language-select-ja]')110.find('[data-test=language-select-tooltip]')111.should('exist')112})113})114115116