diff --git a/features/dme/signin.spec.js b/features/dme/signin.spec.js index 01e63d93..1c500e2c 100644 --- a/features/dme/signin.spec.js +++ b/features/dme/signin.spec.js @@ -21,6 +21,7 @@ module.exports = { data: { partnerLevel: 'cpp-spain-platinum:', expectedToSeeInURL: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/protected-home', + page: 'public page', }, }, { @@ -32,6 +33,7 @@ module.exports = { data: { partnerLevel: 'cpp-spain-platinum:', expectedToSeeInURL: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/protected-home', + page: 'restricted page', }, }, ], diff --git a/selectors/dme/signin.page.js b/selectors/dme/signin.page.js index 60cbc2f4..00584c3f 100644 --- a/selectors/dme/signin.page.js +++ b/selectors/dme/signin.page.js @@ -21,4 +21,31 @@ export default class SignInPage { 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}`); + }); + } } diff --git a/tests/dme/signin.test.js b/tests/dme/signin.test.js index 7c31bf50..54825557 100644 --- a/tests/dme/signin.test.js +++ b/tests/dme/signin.test.js @@ -5,6 +5,7 @@ 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 }) => { @@ -41,57 +42,18 @@ test.describe('MAPC sign in flow', () => { }); }); - 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 cpp spain platinum user', async () => { - await signInPage.signIn(page, `${features[1].data.partnerLevel}`); - await signInPage.userNameDisplay.waitFor({ state: 'visible', timeout: 20000 }); - }); - - await test.step('Open public page in a new tab', async () => { + redirectionFeatures.forEach((feature) => { + test(`${feature.name},${feature.tags}`, async ({ page, context }) => { 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 cpp spain platinum user', async () => { - await signInPage.signIn(page, `${features[2].data.partnerLevel}`); - await signInPage.userNameDisplay.waitFor({ state: 'visible', timeout: 20000 }); - }); - - 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}`); + await signInPage.verifyRedirectAfterLogin({ + page, + test, + expect, + newTab, + newTabPage, + feature, + }); }); }); });