Skip to content

Commit

Permalink
Merge pull request #14 from KristijanVizi/MWPW-154523-implement-mapc-…
Browse files Browse the repository at this point in the history
…sign-in-test-cases

New: added mapc sign in flow tests
  • Loading branch information
cod17828 authored Jul 24, 2024
2 parents 1a18026 + ce3612a commit cdb7c34
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 1 deletion.
2 changes: 1 addition & 1 deletion envs/envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ module.exports = {
'@local6456': 'http://localhost:6456',
'@helpx_live': 'https://helpx-internal.stage.adobe.com',
'@dx_stage': 'https://stage--dx-partners--adobecom.hlx.live',
'@dme_stage': 'https://partners.stage.adobe.com',
'@dme_stage': 'https://stage--dme-partners--adobecom.hlx.live',
};
40 changes: 40 additions & 0 deletions features/dme/signin.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module.exports = {
FeatureName: 'DME sign in flow page',
features: [
{
tcid: '1',
name: '@login-sign-in-sign-out-public-page',
path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page',
tags: '@dme-signin @regression @login @nopr',
data: {
partnerLevel: 'cpp-spain-platinum:',
expectedProtectedHomeURL: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/protected-home',
expectedPublicPageURL: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page',
},
},
{
tcid: '2',
name: '@login-accessing-public-home-page-with-member-user-logged-in-to-adobe',
path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page',
baseURL: 'https://www.stage.adobe.com/partners.html',
tags: '@dme-signin @regression @login @nopr',
data: {
partnerLevel: 'cpp-spain-platinum:',
expectedToSeeInURL: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/protected-home',
page: 'public page',
},
},
{
tcid: '3',
name: '@login-accessing-restricted-home-page-with-member-user-logged-in-to-adobe',
path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/protected-home',
baseURL: 'https://www.stage.adobe.com/partners.html',
tags: '@dme-signin @regression @login @nopr',
data: {
partnerLevel: 'cpp-spain-platinum:',
expectedToSeeInURL: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/protected-home',
page: 'restricted page',
},
},
],
};
51 changes: 51 additions & 0 deletions selectors/dme/signin.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
export default class SignInPage {
constructor(page) {
this.page = page;
this.signInButton = page.locator('button[daa-ll="Sign In"].feds-signIn');
this.signInButtonStageAdobe = page.locator('.profile-comp.secondary-button');
this.profileIconButton = page.locator('.feds-profile-button');
this.userNameDisplay = page.locator('.user-name');
this.logoutButton = page.locator('[daa-ll="Sign Out"]');

this.emailField = page.locator('#EmailPage-EmailField');
this.emailPageContinueButton = page.locator('//button[@data-id="EmailPage-ContinueButton"]');
this.passwordField = page.locator('#PasswordPage-PasswordField');
this.passwordPageContinueButton = page.locator('//button[@data-id="PasswordPage-ContinueButton"]');
}

async signIn(page, partnerLevel) {
const email = process.env.IMS_EMAIL.split(partnerLevel)[1].split(';')[0];
await page.waitForLoadState('networkidle');
await this.emailField.fill(email);
await this.emailPageContinueButton.click();
await this.passwordField.fill(process.env.IMS_PASS);
await this.passwordPageContinueButton.click();
}

async verifyRedirectAfterLogin({
page, test, expect, newTab, newTabPage, feature,
}) {
await test.step('Go to stage.adobe.com', async () => {
const url = `${feature.baseURL}`;
await page.evaluate((navigationUrl) => {
window.location.href = navigationUrl;
}, url);

await this.signInButtonStageAdobe.click();
await page.waitForLoadState('domcontentloaded');
});

await test.step('Sign in with cpp spain platinum user', async () => {
await this.signIn(page, `${feature.data.partnerLevel}`);
await this.userNameDisplay.waitFor({ state: 'visible', timeout: 20000 });
});

await test.step(`Open ${feature.data.page} in a new tab`, async () => {
await newTab.goto(`${feature.path}`);
await newTabPage.profileIconButton.waitFor({ state: 'visible', timeout: 20000 });
const pages = await page.context().pages();
await expect(pages[1].url())
.toContain(`${feature.data.expectedToSeeInURL}`);
});
}
}
59 changes: 59 additions & 0 deletions tests/dme/signin.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { test, expect } from '@playwright/test';
import SignInPage from '../../selectors/dme/signin.page.js';

let signInPage;
const signin = require('../../features/dme/signin.spec.js');

const { features } = signin;
const redirectionFeatures = features.slice(1, 3);

test.describe('MAPC sign in flow', () => {
test.beforeEach(async ({ page }) => {
signInPage = new SignInPage(page);
});

test(`${features[0].name},${features[0].tags}`, async ({ page }) => {
await test.step('Go to the home page', async () => {
await page.goto(`${features[0].path}`);
await page.waitForLoadState('domcontentloaded');
await signInPage.signInButton.click();
});

await test.step('Sign in', async () => {
await signInPage.signIn(page, `${features[0].data.partnerLevel}`);
});

await test.step('Verify redirection to restricted home after successful login', async () => {
await signInPage.profileIconButton.waitFor({ state: 'visible', timeout: 20000 });
const pages = await page.context().pages();
await expect(pages[0].url()).toContain(`${features[0].data.expectedProtectedHomeURL}`);
});

await test.step('Logout', async () => {
await signInPage.profileIconButton.click();
await signInPage.logoutButton.click();
});

await test.step('Verify redirection to public page after logout', async () => {
await signInPage.signInButton.waitFor({ state: 'visible', timeout: 10000 });
const pages = await page.context().pages();
await expect(pages[0].url())
.toContain(`${features[0].data.expectedPublicPageURL}`);
});
});

redirectionFeatures.forEach((feature) => {
test(`${feature.name},${feature.tags}`, async ({ page, context }) => {
const newTab = await context.newPage();
const newTabPage = new SignInPage(newTab);
await signInPage.verifyRedirectAfterLogin({
page,
test,
expect,
newTab,
newTabPage,
feature,
});
});
});
});

0 comments on commit cdb7c34

Please sign in to comment.