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

[Gitlab-112] Reworked password change test to not interfere with other tests #50

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions tests/base/account.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {test, expect} from '@playwright/test';
import {MainMenuPage} from './fixtures/mainmenu.page';
import {LoginPage} from './fixtures/login.page';
import {RegisterPage} from './fixtures/register.page';
import {AccountPage} from './fixtures/account.page';
import {NewsletterSubscriptionPage} from './fixtures/newsletter.page';

Expand Down Expand Up @@ -46,24 +48,47 @@ test.describe('Account information actions', {annotation: {type: 'Account Dashbo
* @then I should see a notification that my password has been updated
* @and I should be able to login with my new credentials.
*/
test('I can change my password',{ tag: '@account-credentials', }, async ({page, browserName}) => {

//TODO: Remove the skip when all issues are fixed.
test.skip('I can change my password',{ tag: '@account-credentials', }, async ({page}) => {
// Create instances and set variables
const mainMenu = new MainMenuPage(page);
const registerPage = new RegisterPage(page);
const accountPage = new AccountPage(page);
let changedPasswordValue = process.env.MAGENTO_EXISTING_ACCOUNT_CHANGED_PASSWORD;
const loginPage = new LoginPage(page);

const browserEngine = browserName?.toUpperCase() || "UNKNOWN";
let randomNumberforEmail = Math.floor(Math.random() * 101);
let emailPasswordUpdatevalue = `passwordupdate-${randomNumberforEmail}-${browserEngine}@example.com`;
let passwordInputValue = process.env.MAGENTO_EXISTING_ACCOUNT_PASSWORD;
let changedPasswordValue = process.env.MAGENTO_EXISTING_ACCOUNT_CHANGED_PASSWORD;

// Log out of current account
if(await page.getByRole('link', { name: selectors.mainMenu.myAccountLogoutItem }).isVisible()){
await mainMenu.logout();
}

// Create account
if(!changedPasswordValue || !passwordInputValue) {
throw new Error("Changed password or original password in your .env file is not defined or could not be read.");
}

// Navigate to Account Information, confirm by checking heading above sidebar
const sidebarAccountInfoLink = page.getByRole('link', { name: 'Account Information' });
sidebarAccountInfoLink.click();
await expect(page.getByRole('heading', { name: 'Account Information' }).locator('span')).toBeVisible();
await registerPage.createNewAccount(inputvalues.accountCreation.firstNameValue, inputvalues.accountCreation.lastNameValue, emailPasswordUpdatevalue, passwordInputValue);

// Update password
await page.goto(slugs.account.changePasswordSlug);
await page.waitForLoadState();
await accountPage.updatePassword(passwordInputValue, changedPasswordValue);

// If login with changePasswordValue is possible, then password change was succesful.
await loginPage.login(emailPasswordUpdatevalue, changedPasswordValue);

// Logout again, login with original account
await mainMenu.logout();
let emailInputValue = process.env[`MAGENTO_EXISTING_ACCOUNT_EMAIL_${browserEngine}`];
if(!emailInputValue) {
throw new Error("MAGENTO_EXISTING_ACCOUNT_EMAIL_${browserEngine} and/or MAGENTO_EXISTING_ACCOUNT_PASSWORD have not defined in the .env file, or the account hasn't been created yet.");
}
await loginPage.login(emailInputValue, passwordInputValue);
});
});

Expand Down
3 changes: 2 additions & 1 deletion tests/base/config/slugs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"createAccountSlug": "/customer/account/create",
"addressBookSlug": "/customer/address",
"addressIndexSlug": "/customer/address/index",
"addressNewSlug": "customer/address/new"
"addressNewSlug": "customer/address/new",
"changePasswordSlug": "/customer/account/edit/changepass/1/"
},
"productpage": {
"simpleProductSlug": "/push-it-messenger-bag.html",
Expand Down
Loading