-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,10 @@ const dataSelectorValue = '[data-cy="details-item-value"]'; | |
|
||
// variables | ||
const newNickname = 'Cyklobaron'; | ||
const newGender = 'female'; | ||
const genderFemale = 'female'; | ||
const genderFemaleKey = 'global.woman'; | ||
const genderMale = 'male'; | ||
const genderMaleKey = 'global.man'; | ||
const newEmail = '[email protected]'; | ||
const password = 'password'; | ||
|
||
|
@@ -423,15 +426,14 @@ function coreTests() { | |
.click(); | ||
// gender edit form | ||
cy.dataCy(selectorFormGender).should('be.visible'); | ||
// change gender | ||
// change gender to woman | ||
cy.dataCy(selectorFormGender) | ||
.find('.q-radio__label') | ||
// female | ||
.first() | ||
.contains(i18n.global.t(genderFemaleKey)) | ||
.click(); | ||
// cancel | ||
cy.dataCy(selectorFormGender).find(dataSelectorButtonCancel).click(); | ||
// gender is the same | ||
// gender stays the same (male) | ||
cy.dataCy(selectorGender) | ||
.find(dataSelectorValue) | ||
.should('be.visible') | ||
|
@@ -446,16 +448,15 @@ function coreTests() { | |
// change gender | ||
cy.dataCy(selectorFormGender) | ||
.find('.q-radio__label') | ||
// female | ||
.first() | ||
.contains(i18n.global.t(genderFemaleKey)) | ||
.click(); | ||
// save | ||
cy.dataCy(selectorFormGender).find(dataSelectorButtonSave).click(); | ||
// gender is different | ||
cy.dataCy(selectorGender) | ||
.find(dataSelectorValue) | ||
.should('be.visible') | ||
.and('have.text', newGender); | ||
.and('have.text', genderFemale); | ||
// reset gender | ||
cy.dataCy(selectorGender) | ||
.find(dataSelectorEdit) | ||
|
@@ -466,11 +467,15 @@ function coreTests() { | |
// change gender | ||
cy.dataCy(selectorFormGender) | ||
.find('.q-radio__label') | ||
// male | ||
.last() | ||
.contains(i18n.global.t(genderMaleKey)) | ||
.click(); | ||
// save | ||
cy.dataCy(selectorFormGender).find(dataSelectorButtonSave).click(); | ||
// gender is male | ||
cy.dataCy(selectorGender) | ||
.find(dataSelectorValue) | ||
.should('be.visible') | ||
.and('have.text', genderMale); | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { routesConf } from '../../../src/router/routes_conf'; | ||
|
||
// selectors | ||
const selectorProfilePage = 'profile-page'; | ||
const selectorProfilePageTitle = 'profile-page-title'; | ||
const selectorNickname = 'profile-details-nickname'; | ||
const selectorEmail = 'profile-details-email'; | ||
const selectorGender = 'profile-details-gender'; | ||
const selectorFormNickname = 'profile-details-form-nickname'; | ||
const selectorFormEmail = 'profile-details-form-email'; | ||
const selectorFormGender = 'profile-details-form-gender'; | ||
const dataSelectorEdit = '[data-cy="details-item-edit"]'; | ||
const dataSelectorInput = '[data-cy="form-input"]'; | ||
const dataSelectorInputEmail = '[data-cy="form-email"]'; | ||
const dataSelectorInputPassword = '[data-cy="form-password"]'; | ||
const dataSelectorButtonSave = '[data-cy="form-button-save"]'; | ||
const dataSelectorValue = '[data-cy="details-item-value"]'; | ||
|
||
// variables | ||
const newNickname = 'Cyklobaron'; | ||
const newEmail = '[email protected]'; | ||
const password = 'testpassword123'; | ||
const genderFemale = 'female'; | ||
const genderFemaleKey = 'global.woman'; | ||
|
||
describe('Profile page', () => { | ||
context('desktop', () => { | ||
beforeEach(() => { | ||
cy.visit('#' + routesConf['profile']['children']['fullPath']); | ||
cy.viewport('macbook-16'); | ||
// load config and i18n objects as aliases | ||
cy.task('getAppConfig', process).then((config) => { | ||
// alias config | ||
cy.wrap(config).as('config'); | ||
cy.window().should('have.property', 'i18n'); | ||
cy.window().then((win) => { | ||
// alias i18n | ||
cy.wrap(win.i18n).as('i18n'); | ||
}); | ||
}); | ||
}); | ||
|
||
coreTests(); | ||
|
||
it('renders left drawer', () => { | ||
cy.dataCy('q-drawer').should('be.visible'); | ||
cy.dataCy('drawer-header').should('be.visible'); | ||
cy.dataCy('user-select').should('be.visible'); | ||
cy.dataCy('drawer-toggle-buttons').should('be.visible'); | ||
cy.dataCy('drawer-menu').should('be.visible'); | ||
}); | ||
}); | ||
}); | ||
|
||
function coreTests() { | ||
it('has translation for all strings', () => { | ||
cy.get('@i18n').then((i18n) => { | ||
cy.testLanguageStringsInContext(['titleProfile'], 'profile', i18n); | ||
}); | ||
}); | ||
|
||
it('renders page', () => { | ||
cy.get('@i18n').then((i18n) => { | ||
cy.dataCy(selectorProfilePage).should('be.visible'); | ||
// title | ||
cy.dataCy(selectorProfilePageTitle) | ||
.should('be.visible') | ||
.and('contain', i18n.global.t('profile.titleProfile')); | ||
}); | ||
}); | ||
|
||
it('allows user to change nickname, email, and gender', () => { | ||
cy.get('@i18n').then((i18n) => { | ||
// Change nickname | ||
cy.dataCy(selectorNickname).find(dataSelectorEdit).click(); | ||
cy.dataCy(selectorFormNickname).find(dataSelectorInput).clear(); | ||
cy.dataCy(selectorFormNickname).find(dataSelectorInput).type(newNickname); | ||
cy.dataCy(selectorFormNickname).find(dataSelectorButtonSave).click(); | ||
cy.dataCy(selectorNickname) | ||
.find(dataSelectorValue) | ||
.should('have.text', newNickname); | ||
|
||
// Change email | ||
cy.dataCy(selectorEmail).find(dataSelectorEdit).click(); | ||
cy.dataCy(selectorFormEmail).find(dataSelectorInputEmail).clear(); | ||
cy.dataCy(selectorFormEmail).find(dataSelectorInputEmail).type(newEmail); | ||
cy.dataCy(selectorFormEmail) | ||
.find(dataSelectorInputPassword) | ||
.type(password); | ||
cy.dataCy(selectorFormEmail).find(dataSelectorButtonSave).click(); | ||
cy.dataCy(selectorEmail) | ||
.find(dataSelectorValue) | ||
.should('have.text', newEmail); | ||
|
||
// Change gender | ||
cy.dataCy(selectorGender).find(dataSelectorEdit).click(); | ||
cy.dataCy(selectorFormGender) | ||
.find('.q-radio__label') | ||
.contains(i18n.global.t(genderFemaleKey)) | ||
.click(); | ||
cy.dataCy(selectorFormGender).find(dataSelectorButtonSave).click(); | ||
cy.dataCy(selectorGender) | ||
.find(dataSelectorValue) | ||
.should('have.text', genderFemale); | ||
}); | ||
}); | ||
} |