diff --git a/features/dx/news.spec.js b/features/dx/news.spec.js index db50ee7b..9bdb1d5f 100644 --- a/features/dx/news.spec.js +++ b/features/dx/news.spec.js @@ -24,6 +24,7 @@ module.exports = { name: '@desc-regression-news-page-read-article', path: '/solutionpartners/drafts/automation/regression/partner-news', tags: '@dx-news @regression @anonymous', + expectedToSeeInURL: '/solutionpartners/drafts/automation/regression/caas-cards/automation-regression-card-no1', }, { tcid: '5', @@ -36,6 +37,11 @@ module.exports = { name: '@login-news-page-platinum-user', path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/partner-news', tags: '@dx-news @regression @login @nopr', + data: { + partnerLevel: 'spp-platinum:', + expectedToSeeInURL: '/solutionpartners/drafts/' + + 'automation/regression/caas-cards/automation-regression-platinum-card-no1', + }, }, { tcid: '7', @@ -91,6 +97,7 @@ module.exports = { path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/partner-news', baseURL: 'https://www.stage.adobe.com/partners.html', tags: '@dx-news @regression @login @nopr', + partnerLevel: 'tpp-platinum:', }, ], }; diff --git a/features/dx/signin.spec.js b/features/dx/signin.spec.js new file mode 100644 index 00000000..82ef593e --- /dev/null +++ b/features/dx/signin.spec.js @@ -0,0 +1,129 @@ +module.exports = { + FeatureName: 'DX Sign In Flow', + features: [ + { + tcid: '1', + name: '@login-redirect-to-protected-home', + testId: '@MWPW-140197', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'spp-platinum:', + expectedProtectedURL: '/solutionpartners/drafts/automation/regression/protected-home', + expectedPublicURL: '/solutionpartners/drafts/automation/regression/public-page', + }, + }, + { + tcid: '2', + name: '@login-no-redirection-public-news', + testId: '@MWPW-140198 @MWPW-140201', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/partner-news', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'spp-gold:', + expectedToSeeInURL: '/solutionpartners/drafts/automation/regression/partner-news', + }, + }, + { + tcid: '3', + name: '@login-accessing-public-home-page-with-member-user-logged-in-to-adobe', + testId: '@MWPW-140202', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page', + baseURL: 'https://www.stage.adobe.com/partners.html', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'spp-community:', + expectedProtectedURL: '/solutionpartners/drafts/automation/regression/protected-home', + }, + }, + { + tcid: '4', + name: '@login-accessing-restricted-home-page-with-member-user-logged-in-to-adobe', + testId: '@MWPW-140203', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page', + baseURL: 'https://www.stage.adobe.com/partners.html', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'spp-platinum:', + expectedProtectedURL: '/solutionpartners/drafts/automation/regression/protected-home', + }, + }, + { + tcid: '5', + name: '@login-public-page-sign-in-with-non-member', + testId: '@MWPW-140207', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page', + newsPath: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/partner-news', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'tpp-platinum:', + expectedToSeeInURL: '/solutionpartners/error/contact-not-found', + }, + }, + { + tcid: '6', + name: '@login-accessing-restricted-home-page-with-non-member-user-logged-in-to-adobe', + testId: '@MWPW-140202', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/protected-home', + baseURL: 'https://www.stage.adobe.com/partners.html', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'tpp-platinum:', + expectedToSeeInURL: '/solutionpartners/error/contact-not-found', + }, + }, + { + tcid: '7', + name: '@login-accessing-public-page-with-non-member-user-logged-in-to-adobe', + testId: '@MWPW-140212', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page', + baseURL: 'https://www.stage.adobe.com/partners.html', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'tpp-platinum:', + expectedToSeeInURL: '/solutionpartners/error/contact-not-found', + }, + }, + { + tcid: '8', + name: '@login-accessing-restricted-home-page-with-non-logged-in-user', + testId: '@MWPW-140213', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/protected-home', + tags: '@dx-signin @regression @login @nopr', + expectedToSeeInURL: 'https://auth-stg1.services.adobe.com/', + }, + { + tcid: '9', + name: '@login-with-submitted-in-review-spp-user', + testId: '@MWPW-140214', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'spp-submitted-in-review:', + expectedLandingPageURL: 'https://partners.stage.adobe.com/solutionpartners/error/submitted-in-review', + }, + }, + { + tcid: '10', + name: '@login-with-deactivated-spp-user', + testId: '@MWPW-140224', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'spp-deactivated:', + expectedLandingPageURL: 'https://partners.stage.adobe.com/solutionpartners/error/contact-inactive', + }, + }, + { + tcid: '11', + name: '@login-with-expired-spp-user', + testId: 'MWPW-140215', + path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page', + tags: '@dx-signin @regression @login @nopr', + data: { + partnerLevel: 'spp-expired:', + expectedLandingPageURL: 'https://partners.stage.adobe.com/solutionpartners/error/account-expired', + }, + }, + ], +}; diff --git a/selectors/dx/news.page.js b/selectors/dx/news.page.js index 3717ca5d..8414f408 100644 --- a/selectors/dx/news.page.js +++ b/selectors/dx/news.page.js @@ -15,10 +15,6 @@ export default class NewsPage { this.lastCardDate = page.locator('.card-date').nth(5); this.signInButton = page.locator('button[daa-ll="Sign In"].feds-signIn'); - 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"]'); this.profileIconButton = page.locator('.feds-profile-button'); this.profileName = page.locator('.feds-profile-name'); this.logoutButton = page.locator('[daa-ll="Sign Out"]'); @@ -42,12 +38,4 @@ export default class NewsPage { async clearFilter(filter, number) { await this.page.locator(`[aria-label="${filter}"] + [aria-label="${number}"]`).click(); } - - async signIn(partnerLevel) { - const email = process.env.IMS_EMAIL.split(partnerLevel)[1].split(';')[0]; - await this.emailField.fill(email); - await this.emailPageContinueButton.click(); - await this.passwordField.fill(process.env.IMS_PASS); - await this.passwordPageContinueButton.click(); - } } diff --git a/selectors/dx/signin.page.js b/selectors/dx/signin.page.js new file mode 100644 index 00000000..e7ab3e1d --- /dev/null +++ b/selectors/dx/signin.page.js @@ -0,0 +1,39 @@ +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.joinNowButton = page.locator('a:has-text("Join now")'); + this.explorePastArticles = page.locator('a:has-text("Explore past articles")'); + this.newsletterLink = page.locator('a:has-text("product newsletter")'); + this.logoutButton = page.locator('[daa-ll="Sign Out"]'); + this.userNameDisplay = page.locator('.user-name'); + + this.IMSEmailPage = page.locator('form#EmailForm'); + this.emailField = page.locator('#EmailPage-EmailField'); + this.emailPageContinueButton = page.locator('//button[@data-id="EmailPage-ContinueButton"]'); + this.IMSPasswordPage = page.locator('form#PasswordForm'); + 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('domcontentloaded'); + await this.emailField.fill(email); + await this.emailPageContinueButton.click(); + await this.passwordField.fill(process.env.IMS_PASS); + await this.passwordPageContinueButton.click(); + } + + async verifyLandingPageAfterLogin({ page, expect, path, partnerLevel, expectedLandingPageURL }) { + await page.goto(path); + await page.waitForLoadState('domcontentloaded'); + await this.signInButton.click(); + await this.signIn(page, partnerLevel); + await this.profileIconButton.waitFor({ state: 'visible', timeout: 20000 }); + const pages = await page.context().pages(); + await expect(pages[0].url()).toContain(expectedLandingPageURL); + } +} diff --git a/tests/dx/news.test.js b/tests/dx/news.test.js index 24c035ae..65dd008d 100644 --- a/tests/dx/news.test.js +++ b/tests/dx/news.test.js @@ -1,7 +1,9 @@ import { test, expect } from '@playwright/test'; import NewsPage from '../../selectors/dx/news.page.js'; +import SignInPage from '../../selectors/dx/signin.page.js'; let newsPage; +let signInPage; const News = require('../../features/dx/news.spec.js'); const { features } = News; @@ -9,6 +11,7 @@ const { features } = News; test.describe('Validate news block', () => { test.beforeEach(async ({ page }) => { newsPage = new NewsPage(page); + signInPage = new SignInPage(page); }); async function findCardsForPartnerLevel(page, path, cardPartnerLevel, partnerLevel, resultTotal, cardLevelAbove) { @@ -25,7 +28,7 @@ test.describe('Validate news block', () => { }); await test.step('I load the news page', async () => { - await newsPage.signIn(partnerLevel); + await signInPage.signIn(page, partnerLevel); }); await test.step('Find automation regression cards for current partner level', async () => { @@ -173,6 +176,7 @@ test.describe('Validate news block', () => { await test.step('Go to News page', async () => { await page.goto(`${baseURL}${features[3].path}`); await newsPage.searchField.fill('Automation regression news card SPP Public no1'); + await newsPage.firstCardTitle.waitFor({ state: 'visible', timeout: 10000 }); const resultAfterSearch = await newsPage.resultNumber.textContent(); await expect(parseInt(resultAfterSearch.split(' ')[0], 10)).toBe(1); }); @@ -181,7 +185,7 @@ test.describe('Validate news block', () => { await newsPage.readCard.click(); const pages = await page.context().pages(); await expect(pages[0].url()) - .toContain('/solutionpartners/drafts/automation/regression/caas-cards/automation-regression-card-no1'); + .toContain(`${features[3].expectedToSeeInURL}`); }); }); @@ -229,7 +233,7 @@ test.describe('Validate news block', () => { }); await test.step('I load the news page', async () => { - await newsPage.signIn('spp-platinum:'); + await signInPage.signIn(page, `${features[5].data.partnerLevel}`); }); await test.step('Find platinum automation regression cards', async () => { @@ -245,7 +249,7 @@ test.describe('Validate news block', () => { await newsPage.readCard.click(); const pages = await page.context().pages(); await expect(pages[0].url()) - .toContain('/solutionpartners/drafts/automation/regression/caas-cards/automation-regression-platinum-card-no1'); + .toContain(`${features[5].data.expectedToSeeInURL}`); }); }); @@ -297,7 +301,7 @@ test.describe('Validate news block', () => { test(`${features[10].name},${features[10].tags}`, async ({ page, context }) => { await test.step('Go to stage.adobe.com', async () => { - const url = `${features[10].path}`; + const url = `${features[10].baseURL}`; await page.evaluate((navigationUrl) => { window.location.href = navigationUrl; }, url); @@ -307,7 +311,7 @@ test.describe('Validate news block', () => { }); await test.step('Sign in with non spp member', async () => { - await newsPage.signIn('tpp-platinum:'); + await signInPage.signIn(page, `${features[10].partnerLevel}`); }); await test.step(`Open ${features[10].path} in a new tab`, async () => { diff --git a/tests/dx/signin.test.js b/tests/dx/signin.test.js new file mode 100644 index 00000000..585d888c --- /dev/null +++ b/tests/dx/signin.test.js @@ -0,0 +1,272 @@ +import { test, expect } from '@playwright/test'; +import SignInPage from '../../selectors/dx/signin.page.js'; + +let signInPage; +const signin = require('../../features/dx/signin.spec.js'); + +const { features } = signin; +const uniqueFeatures = features.slice(8, 11); + +test.describe('MAPP 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 public 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 protected home page 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.expectedProtectedURL}`); + }); + + await test.step('Logout', async () => { + await signInPage.profileIconButton.click(); + await signInPage.logoutButton.click(); + }); + + await test.step('Verify redirection to public home 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.expectedPublicURL}`); + }); + }); + + test(`${features[1].name},${features[1].tags}`, async ({ page }) => { + await test.step('Go to public home page', async () => { + await page.goto(`${features[1].path}`); + await page.waitForLoadState('domcontentloaded'); + const joinNowButton = await signInPage.joinNowButton; + await expect(joinNowButton).toBeVisible(); + const explorePastArticlesButton = await signInPage.explorePastArticles; + await expect(explorePastArticlesButton).toBeVisible(); + const newsletterLink = await signInPage.newsletterLink; + await expect(newsletterLink).toBeHidden(); + await signInPage.signInButton.click(); + }); + + await test.step('Sign in', async () => { + await signInPage.signIn(page, `${features[1].data.partnerLevel}`); + }); + + await test.step('Verify restricted news 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[1].data.expectedToSeeInURL}`); + const joinNowButton = await signInPage.joinNowButton; + await expect(joinNowButton).toBeHidden(); + const explorePastArticlesButton = await signInPage.explorePastArticles; + await expect(explorePastArticlesButton).toBeVisible(); + const newsletterLink = await signInPage.newsletterLink; + await expect(newsletterLink).toBeVisible(); + }); + + await test.step('Logout', async () => { + await signInPage.profileIconButton.click(); + await signInPage.logoutButton.click(); + }); + + await test.step('Verify public news 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[1].data.expectedToSeeInURL}`); + const joinNowButton = await signInPage.joinNowButton; + await expect(joinNowButton).toBeVisible(); + const explorePastArticlesButton = await signInPage.explorePastArticles; + await expect(explorePastArticlesButton).toBeVisible(); + const newsletterLink = await signInPage.newsletterLink; + await expect(newsletterLink).toBeHidden(); + }); + }); + + 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 spp community user', async () => { + await signInPage.signIn(page, `${features[2].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[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.expectedProtectedURL}`); + }); + }); + + test(`${features[3].name},${features[3].tags}`, async ({ page, context }) => { + await test.step('Go to stage.adobe.com', async () => { + const url = `${features[3].baseURL}`; + await page.evaluate((navigationUrl) => { + window.location.href = navigationUrl; + }, url); + + await signInPage.signInButtonStageAdobe.click(); + await page.waitForLoadState('domcontentloaded'); + }); + + await test.step('Sign in with spp platinum user', async () => { + await signInPage.signIn(page, `${features[3].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[3].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[3].data.expectedProtectedURL}`); + }); + }); + + test(`${features[4].name},${features[4].tags}`, async ({ page }) => { + await test.step('Go to public home page', async () => { + await page.goto(`${features[4].path}`); + await page.waitForLoadState('domcontentloaded'); + await signInPage.signInButton.click(); + }); + + await test.step('Sign in', async () => { + await signInPage.signIn(page, `${features[4].data.partnerLevel}`); + }); + + await test.step('Verify redirection to contact not found page 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[4].data.expectedToSeeInURL}`); + }); + + await test.step('Logout', async () => { + await signInPage.profileIconButton.click(); + await signInPage.logoutButton.click(); + }); + + await test.step('Go to public news page', async () => { + await page.goto(`${features[4].newsPath}`); + await page.waitForLoadState('domcontentloaded'); + await signInPage.signInButton.click(); + }); + + await test.step('Sign in', async () => { + await signInPage.signIn(page, `${features[4].data.partnerLevel}`); + }); + + await test.step('Verify redirection to contact not found page 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[4].data.expectedToSeeInURL}`); + }); + }); + + test(`${features[5].name},${features[5].tags}`, async ({ page, context }) => { + await test.step('Go to stage.adobe.com', async () => { + const url = `${features[5].baseURL}`; + await page.evaluate((navigationUrl) => { + window.location.href = navigationUrl; + }, url); + + await signInPage.signInButtonStageAdobe.click(); + await page.waitForLoadState('domcontentloaded'); + }); + + await test.step('Sign in with tpp platinum user', async () => { + await signInPage.signIn(page, `${features[5].data.partnerLevel}`); + await signInPage.userNameDisplay.waitFor({ state: 'visible', timeout: 15000 }); + }); + + await test.step('Open protected home page in a new tab', async () => { + const newTab = await context.newPage(); + await newTab.goto(`${features[5].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[5].data.expectedToSeeInURL}`); + const signInButton = await signInPage.signInButton; + await expect(signInButton).toBeHidden(); + }); + }); + + test(`${features[6].name},${features[6].tags}`, async ({ page, context }) => { + await test.step('Go to stage.adobe.com', async () => { + const url = `${features[6].baseURL}`; + await page.evaluate((navigationUrl) => { + window.location.href = navigationUrl; + }, url); + + await signInPage.signInButtonStageAdobe.click(); + await page.waitForLoadState('domcontentloaded'); + }); + + await test.step('Sign in with tpp platinum user', async () => { + await signInPage.signIn(page, `${features[6].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[6].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[6].data.expectedToSeeInURL}`); + const signInButton = await newTabPage.signInButton; + await expect(signInButton).toBeHidden(); + const joinNowButton = await newTabPage.joinNowButton; + await expect(joinNowButton).toBeVisible(); + }); + }); + + test(`${features[7].name},${features[7].tags}`, async ({ page }) => { + await test.step('Go to protected home page', async () => { + await page.goto(`${features[7].path}`); + const pages = await page.context().pages(); + await expect(pages[0].url()) + .toContain(`${features[7].expectedToSeeInURL}`); + }); + }); + + uniqueFeatures.forEach((feature) => { + test(`${feature.name},${feature.tags}`, async ({ page }) => { + await test.step('Verify landing page after successful login', async () => { + await signInPage.verifyLandingPageAfterLogin({ + page, + expect, + path: feature.path, + partnerLevel: feature.data.partnerLevel, + expectedLandingPageURL: feature.data.expectedLandingPageURL, + }); + }); + }); + }); +});