Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix device language getter #211

Merged
merged 4 commits into from Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions cypress/integration/experiences.js
@@ -0,0 +1,32 @@
/// <reference types="Cypress" />

import { ArticlePage } from '../page-objects/article-page'
import { ArticleMenuPage } from '../page-objects/article-menu-page'

const articlePage = new ArticlePage()
const articleMenuPage = new ArticleMenuPage()

describe('Article view', () => {
it('change article language', () => {
cy.setLocalStorage('has-onboard-before', true)
cy.visit('http://127.0.0.1:8080/#/article/en/Cat')
articlePage.selectOptionFromActionsMenu('languages')
cy.get('input').type('português')
cy.get('.description').should('have.text', 'Gato')
cy.downArrow().enter()
cy.clickDoneButton()
articlePage.title().should('have.text', 'Gato')
})

it('check footer', () => {
articlePage.selectOptionFromActionsMenu('sections')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just check on cypress, when you have a new it() scope, it clears all the local storage item.

Therefore, the following script is needed at the beginning of the scope

cy.setLocalStorage('has-onboard-before', true)
cy.visit('http://127.0.0.1:8080/#/article/en/Cat')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpita does this work for you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, the has-onboard-before variable has nothing to do with the language.
shall we ignore this and merge the code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per the meeting discussion, please ignore this and merge the code without experience.js.

articleMenuPage.selectOptionFromSections('Suggested_articles')
cy.screenshot()
// articlePage.footerTitle().should('have.text', enJson['suggested-articles'])
// articlePage.recommendationsList().should('have.length', 3)
// cy.downArrow()
// articlePage.footerImage().should('exist')
// articlePage.footerLicense().should('exist')
// .should('exist')
})
})
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -41,7 +41,7 @@
"babel-loader": "^8.0.6",
"babel-plugin-module-resolver": "^3.2.0",
"css-loader": "^3.2.0",
"cypress": "4.3.0",
"cypress": "4.4.1",
"cypress-localstorage-commands": "^1.1.6",
"cypress-wait-until": "^1.6.1",
"eslint": "^6.6.0",
Expand Down
4 changes: 3 additions & 1 deletion src/utils/languages.js
Expand Up @@ -1550,5 +1550,7 @@ export const checkHasDeviceLanguageChanged = () => {

const getCurrentDeviceLanguage = () => {
const navigatorLang = navigator.language
return navigatorLang.substr(0, navigatorLang.indexOf('-'))
return navigatorLang.includes('-')
? navigatorLang.substr(0, navigatorLang.indexOf('-'))
: navigatorLang
}