Skip to content

Commit

Permalink
New: added apc sign in flow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristijan Vizi authored and Kristijan Vizi committed Jul 23, 2024
1 parent 4dc9f26 commit 305aed8
Show file tree
Hide file tree
Showing 4 changed files with 160 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--dx-partners--adobecom.hlx.live',
};
38 changes: 38 additions & 0 deletions features/dme/signin.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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: 'distributor-apac:',
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: 'reseller-us-gold:',
expectedToSeeInURL: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/protected-home',
},
},
{
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: 'distributor-na-gold:',
expectedToSeeInURL: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/protected-home',
},
},
],
};
24 changes: 24 additions & 0 deletions selectors/dme/signin.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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();
}
}
97 changes: 97 additions & 0 deletions tests/dme/signin.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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;

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}`);
});
});

test(`${features[1].name},${features[1].tags}`, async ({ page, context }) => {
await test.step('Go to stage.adobe.com', async () => {
const url = `${features[1].baseURL}`;
await page.evaluate((navigationUrl) => {
window.location.href = navigationUrl;
}, url);

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

await test.step('Sign in with Reseller Gold US user', async () => {
await signInPage.signIn(page, `${features[1].data.partnerLevel}`);
await signInPage.userNameDisplay.waitFor({ state: 'visible', timeout: 15000 });
});

await test.step('Open public page in a new tab', async () => {
const newTab = await context.newPage();
await newTab.goto(`${features[1].path}`);
const newTabPage = new SignInPage(newTab);
await newTabPage.profileIconButton.waitFor({ state: 'visible', timeout: 20000 });
const pages = await page.context().pages();
await expect(pages[1].url())
.toContain(`${features[1].data.expectedToSeeInURL}`);
});
});

test(`${features[2].name},${features[2].tags}`, async ({ page, context }) => {
await test.step('Go to stage.adobe.com', async () => {
const url = `${features[2].baseURL}`;
await page.evaluate((navigationUrl) => {
window.location.href = navigationUrl;
}, url);

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

await test.step('Sign in with Distributor Gold NA user', async () => {
await signInPage.signIn(page, `${features[2].data.partnerLevel}`);
await signInPage.userNameDisplay.waitFor({ state: 'visible', timeout: 15000 });
});

await test.step('Open restricted page in a new tab', async () => {
const newTab = await context.newPage();
await newTab.goto(`${features[2].path}`);
const newTabPage = new SignInPage(newTab);
await newTabPage.profileIconButton.waitFor({ state: 'visible', timeout: 20000 });
const pages = await page.context().pages();
await expect(pages[1].url())
.toContain(`${features[2].data.expectedToSeeInURL}`);
});
});
});

0 comments on commit 305aed8

Please sign in to comment.