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

Functional tests - fix Employees tests #16469

Merged
merged 1 commit into from Nov 20, 2019
Merged
Changes from all 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
19 changes: 17 additions & 2 deletions tests/puppeteer/pages/BO/advancedParameters/team/add.js
Expand Up @@ -5,7 +5,7 @@ module.exports = class AddPageEmployee extends BOBasePage {
constructor(page) {
super(page);

this.pageTitleCreate = 'Add new • prestashop';
this.pageTitleCreate = 'Add new •';
this.pageTitleEdit = 'Edit:';

// Selectors
Expand All @@ -14,6 +14,7 @@ module.exports = class AddPageEmployee extends BOBasePage {
this.emailInput = '#employee_email';
this.passwordInput = '#employee_password';
this.defaultPageSelect = '#employee_default_page';
this.defaultPageSpan = '.select2-selection[aria-labelledby=\'select2-employee_default_page-container\']';
this.languageSelect = '#employee_language';
this.activeSwitchlabel = 'label[for=\'employee_active_%ID\']';
this.permissionProfileSelect = '#employee_profile';
Expand All @@ -37,7 +38,7 @@ module.exports = class AddPageEmployee extends BOBasePage {
await this.setValue(this.passwordInput, employeeData.password);
await this.selectByVisibleText(this.permissionProfileSelect, employeeData.permissionProfile);
await this.selectByVisibleText(this.languageSelect, employeeData.language);
await this.selectByVisibleText(this.defaultPageSelect, employeeData.defaultPage);
await this.selectDefaultPage(employeeData.defaultPage);
// replace %ID by 1 in the selector if active = YES / 0 if active = NO
if (employeeData.active) await this.page.click(this.activeSwitchlabel.replace('%ID', '1'));
else await this.page.click(this.activeSwitchlabel.replace('%ID', '0'));
Expand All @@ -46,6 +47,20 @@ module.exports = class AddPageEmployee extends BOBasePage {
return this.getTextContent(this.alertSuccessBlockParagraph);
}

/**
* Select default Page
* @param defaultPage
* @return {Promise<void>}
*/
async selectDefaultPage(defaultPage) {
await Promise.all([
this.page.click(this.defaultPageSpan),
this.page.waitForSelector(`${this.defaultPageSpan}[aria-expanded='true']`, {visible: true}),
]);
await this.page.keyboard.type(defaultPage);
await this.page.keyboard.press('Enter');
}

/**
* Cancel page
* @return {Promise<void>}
Expand Down