diff --git a/nala/blocks/banners/banners.page.js b/nala/blocks/banners/banners.page.js new file mode 100644 index 0000000..0a9072c --- /dev/null +++ b/nala/blocks/banners/banners.page.js @@ -0,0 +1,12 @@ +export default class BannersPage { + constructor(page) { + this.page = page; + this.renewBanner = page.locator('div.renew-banner'); + this.bannerLink = page.locator('p.body-m.action-area > a.con-button.outline'); + this.profileIconButton = page.locator('.feds-profile-button'); + } + + getBannerParagraphByIndex(paragraphIndex) { + return this.page.locator(`.text > .body-m:nth-child(${paragraphIndex})`); + } +} diff --git a/nala/blocks/banners/banners.spec.js b/nala/blocks/banners/banners.spec.js new file mode 100644 index 0000000..a86422d --- /dev/null +++ b/nala/blocks/banners/banners.spec.js @@ -0,0 +1,287 @@ +export default { + FeatureName: 'DME Renew Banners', + features: [ + { + tcid: '1', + name: '@desc-regression-banners-logged-in-non-member-user', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'SPP', + partnerLevel: 'Platinum', + permissionRegion: 'North America', + }, + }, + }, + { + tcid: '2', + name: '@desc-regression-banners-logged-in-member-platinum-user-anniversary-date-out-of-range', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 35, + partnerLevel: 'Platinum', + permissionRegion: 'Europe West', + }, + }, + }, + { + tcid: '3', + name: '@desc-regression-banners-logged-in-member-distributor-user-anniversary-date-out-of-range', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 35, + partnerLevel: 'Distributor', + permissionRegion: 'Japan', + }, + }, + }, + { + tcid: '4', + name: '@desc-regression-banners-logged-in-member-gold-user-anniversary-date-out-of-range', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 35, + partnerLevel: 'Gold', + permissionRegion: 'United Kingdom,Europe West', + }, + }, + }, + { + tcid: '5', + name: '@desc-regression-banners-logged-in-member-certified-user-anniversary-date-out-of-range', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 35, + partnerLevel: 'Certified', + permissionRegion: 'Pacific', + }, + }, + }, + { + tcid: '6', + name: '@desc-regression-banners-logged-in-member-registered-user-anniversary-date-out-of-range', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 35, + partnerLevel: 'Registered', + permissionRegion: 'China', + }, + }, + }, + { + tcid: '7', + name: '@desc-regression-banners-logged-in-member-platinum-user-anniversary-date-last-90-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: -35, + partnerLevel: 'Platinum', + permissionRegion: 'Europe West', + }, + }, + }, + { + tcid: '8', + name: '@desc-regression-banners-logged-in-member-distributor-user-anniversary-date-last-90-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: -35, + partnerLevel: 'Distributor', + permissionRegion: 'Japan', + }, + }, + }, + { + tcid: '9', + name: '@desc-regression-banners-logged-in-member-platinum-user-anniversary-date-next-30-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 10, + partnerLevel: 'Platinum', + permissionRegion: 'Europe West', + }, + }, + }, + { + tcid: '10', + name: '@desc-regression-banners-logged-in-member-distributor-user-anniversary-date-next-30-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 10, + partnerLevel: 'Distributor', + permissionRegion: 'Japan', + }, + }, + }, + { + tcid: '11', + name: '@desc-regression-banners-logged-in-member-gold-user-anniversary-date-last-90-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: -35, + partnerLevel: 'Gold', + permissionRegion: 'United Kingdom,Europe West', + }, + paragraphIndex: 1, + bannerText: 'Your account is suspended. You need to renew your membership to be able to continue using your benefits with Adobe in the next 55 days.', + renewButtonText: 'Renew now', + renewLinkPath: 'https://channelpartners.adobe.com/s/renewal/', + }, + }, + { + tcid: '12', + name: '@desc-regression-banners-logged-in-member-certified-user-anniversary-date-last-90-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: -35, + partnerLevel: 'Certified', + permissionRegion: 'Pacific', + }, + paragraphIndex: 1, + bannerText: 'Your account is suspended. You need to renew your membership to be able to continue using your benefits with Adobe in the next 55 days.', + renewButtonText: 'Renew now', + renewLinkPath: 'https://channelpartners.adobe.com/s/renewal/', + }, + }, + { + tcid: '13', + name: '@desc-regression-banners-logged-in-member-registered-user-anniversary-date-last-90-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: -35, + partnerLevel: 'Registered', + permissionRegion: 'China', + }, + paragraphIndex: 1, + bannerText: 'Your account is suspended. You need to renew your membership to be able to continue using your benefits with Adobe in the next 55 days.', + renewButtonText: 'Renew now', + renewLinkPath: 'https://channelpartners.adobe.com/s/renewal/', + }, + }, + { + tcid: '14', + name: '@desc-regression-banners-logged-in-member-gold-user-anniversary-date-next-30-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 10, + partnerLevel: 'Gold', + permissionRegion: 'United Kingdom,Europe West', + }, + paragraphIndex: 1, + bannerText: 'Your membership will expire in 9 days. Make sure to renew so that you don’t loose your benefits with Adobe.', + renewButtonText: 'Renew now', + renewLinkPath: 'https://channelpartners.adobe.com/s/renewal/', + }, + }, + { + tcid: '15', + name: '@desc-regression-banners-logged-in-member-certified-user-anniversary-date-next-30-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 10, + partnerLevel: 'Certified', + permissionRegion: 'Pacific', + }, + paragraphIndex: 1, + bannerText: 'Your membership will expire in 9 days. Make sure to renew so that you don’t loose your benefits with Adobe.', + renewButtonText: 'Renew now', + renewLinkPath: 'https://channelpartners.adobe.com/s/renewal/', + }, + }, + { + tcid: '16', + name: '@desc-regression-banners-logged-in-member-registered-user-anniversary-date-next-30-days', + path: '/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @anonymous', + data: { + partnerData: { + partnerPortal: 'CPP', + daysToAnniversary: 10, + partnerLevel: 'Registered', + permissionRegion: 'China', + }, + paragraphIndex: 1, + bannerText: 'Your membership will expire in 9 days. Make sure to renew so that you don’t loose your benefits with Adobe.', + renewButtonText: 'Renew now', + renewLinkPath: 'https://channelpartners.adobe.com/s/renewal/', + }, + }, + { + tcid: '17', + name: '@desc-regression-banners-sign-in-registered-us-user-anniversary-date-next-30-days', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @circleCi', + data: { + partnerLevel: 'cpp-us-registered:', + paragraphIndex: 1, + bannerText: 'Your membership will expire', + renewButtonText: 'Renew now', + renewLinkPath: 'https://channelpartners.adobe.com/s/renewal/', + }, + }, + { + tcid: '18', + name: '@desc-regression-banners-sign-in-certified-us-user-anniversary-date-last-90-days', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @circleCi', + data: { + partnerLevel: 'cpp-us-certified:', + paragraphIndex: 1, + bannerText: 'Your account is suspended', + renewButtonText: 'Renew now', + renewLinkPath: 'https://channelpartners.adobe.com/s/renewal/', + }, + }, + { + tcid: '19', + name: '@desc-regression-banners-sign-in-gold-user-anniversary-date-out-of-range', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?akamaiLocale=na', + tags: '@dme-banners @regression @circleCi', + data: { + partnerLevel: 'cpp-us-gold:', + }, + }, + ], +}; diff --git a/nala/blocks/banners/banners.test.js b/nala/blocks/banners/banners.test.js new file mode 100644 index 0000000..282cb93 --- /dev/null +++ b/nala/blocks/banners/banners.test.js @@ -0,0 +1,212 @@ +import { test, expect } from '@playwright/test'; +import BannersPage from './banners.page.js'; +import SignInPage from '../signin/signin.page.js'; +import Banners from './banners.spec.js'; + +let bannersPage; +let signInPage; + +const { features } = Banners; +const anniversaryDateOutOfRangeCases = features.slice(1, 6); +const anniversaryNonPrimaryContacts = features.slice(6, 10); +const anniversaryPrimaryContacts = features.slice(10, 16); + +test.describe('Validate banners', () => { + test.beforeEach(async ({ page, baseURL, browserName, context }) => { + bannersPage = new BannersPage(page); + signInPage = new SignInPage(page); + if (!baseURL.includes('partners.stage.adobe.com')) { + await context.setExtraHTTPHeaders({ authorization: `token ${process.env.HLX_API_KEY}` }); + } + if (browserName === 'chromium' && !baseURL.includes('partners.stage.adobe.com')) { + await page.route('https://www.adobe.com/chimera-api/**', async (route, request) => { + const newUrl = request.url().replace( + 'https://www.adobe.com/chimera-api', + 'https://14257-chimera.adobeioruntime.net/api/v1/web/chimera-0.0.1', + ); + route.continue({ url: newUrl }); + }); + } + }); + + function generateDateWithDaysOffset(daysOffset) { + const date = new Date(); + date.setDate(date.getDate() + daysOffset); + return date; + } + + test(`${features[0].name},${features[0].tags}`, async ({ page, baseURL, context }) => { + const { data, path } = features[0]; + await test.step('Go to public page', async () => { + await page.goto(`${baseURL}${features[0].path}`); + }); + + await test.step('Set partner_data cookie', async () => { + await signInPage.addCookie( + data.partnerData, + `${baseURL}${path}`, + context, + ); + await page.reload(); + }); + + await test.step('Verify renew banner', async () => { + const renewBanner = await bannersPage.renewBanner; + await expect(renewBanner).toBeHidden(); + }); + }); + + anniversaryDateOutOfRangeCases.forEach((feature) => { + test(`${feature.name},${feature.tags}`, async ({ page, baseURL, context }) => { + await test.step('Go to public page', async () => { + await page.goto(`${baseURL}${feature.path}`); + }); + + await test.step('Set partner_data cookie', async () => { + const anniversaryDate = generateDateWithDaysOffset(feature.data.partnerData.daysToAnniversary); + const cookieData = { + ...feature.data.partnerData, + anniversaryDate, + }; + await signInPage.addCookie( + cookieData, + `${baseURL}${feature.path}`, + context, + ); + await page.reload(); + }); + + await test.step('Verify renew banner', async () => { + const renewBanner = await bannersPage.renewBanner; + await expect(renewBanner).toBeHidden(); + }); + }); + }); + + anniversaryNonPrimaryContacts.forEach((feature) => { + test(`${feature.name},${feature.tags}`, async ({ page, baseURL, context }) => { + await test.step('Go to public page', async () => { + await page.goto(`${baseURL}${feature.path}`); + }); + + await test.step('Set partner_data cookie', async () => { + const anniversaryDate = generateDateWithDaysOffset(feature.data.partnerData.daysToAnniversary); + const cookieData = { + ...feature.data.partnerData, + anniversaryDate, + }; + await signInPage.addCookie( + cookieData, + `${baseURL}${feature.path}`, + context, + ); + await page.reload(); + }); + + await test.step('Verify renew banner', async () => { + const renewBanner = await bannersPage.renewBanner; + await expect(renewBanner).toBeHidden(); + }); + }); + }); + + anniversaryPrimaryContacts.forEach((feature) => { + test(`${feature.name},${feature.tags}`, async ({ page, baseURL, context }) => { + await test.step('Go to public page', async () => { + await page.goto(`${baseURL}${feature.path}`); + }); + + await test.step('Set partner_data cookie', async () => { + const anniversaryDate = generateDateWithDaysOffset(feature.data.partnerData.daysToAnniversary); + const cookieData = { + ...feature.data.partnerData, + anniversaryDate, + }; + await signInPage.addCookie( + cookieData, + `${baseURL}${feature.path}`, + context, + ); + await page.reload(); + }); + + await test.step('Verify renew banner', async () => { + const renewBanner = await bannersPage.renewBanner; + await expect(renewBanner).toBeVisible(); + const firstParagraph = bannersPage.getBannerParagraphByIndex(feature.data.paragraphIndex); + await expect(firstParagraph).toHaveText(feature.data.bannerText); + const renewLink = await bannersPage.bannerLink; + await expect(renewLink).toHaveText(feature.data.renewButtonText); + await expect(renewLink).toHaveAttribute('href', feature.data.renewLinkPath); + }); + }); + }); + + test(`${features[16].name},${features[16].tags}`, async ({ page }) => { + const { data, path } = features[16]; + await test.step('Go to public page', async () => { + await page.goto(`${path}`); + await page.waitForLoadState('domcontentloaded'); + await signInPage.signInButton.click(); + }); + + await test.step('Sign in', async () => { + await signInPage.signIn(page, `${data.partnerLevel}`); + }); + + await test.step('Verify renew banner', async () => { + await bannersPage.profileIconButton.waitFor({ state: 'visible', timeout: 20000 }); + const renewBanner = await bannersPage.renewBanner; + await expect(renewBanner).toBeVisible(); + const firstParagraph = bannersPage.getBannerParagraphByIndex(data.paragraphIndex); + await expect(firstParagraph).toContainText(data.bannerText); + const renewLink = await bannersPage.bannerLink; + await expect(renewLink).toHaveText(data.renewButtonText); + await expect(renewLink).toHaveAttribute('href', data.renewLinkPath); + }); + }); + + test(`${features[17].name},${features[17].tags}`, async ({ page }) => { + const { data, path } = features[17]; + await test.step('Go to public page', async () => { + await page.goto(`${path}`); + await page.waitForLoadState('domcontentloaded'); + await signInPage.signInButton.click(); + }); + + await test.step('Sign in', async () => { + await signInPage.signIn(page, `${data.partnerLevel}`); + }); + + await test.step('Verify renew banner', async () => { + await bannersPage.profileIconButton.waitFor({ state: 'visible', timeout: 20000 }); + const renewBanner = await bannersPage.renewBanner; + await expect(renewBanner).toBeVisible(); + const firstParagraph = bannersPage.getBannerParagraphByIndex(data.paragraphIndex); + await expect(firstParagraph).toContainText(data.bannerText); + const renewLink = await bannersPage.bannerLink; + await expect(renewLink).toHaveText(data.renewButtonText); + await expect(renewLink).toHaveAttribute('href', data.renewLinkPath); + }); + }); + + test(`${features[18].name},${features[18].tags}`, async ({ page }) => { + const { data, path } = features[18]; + await test.step('Go to public page', async () => { + await page.goto(`${path}`); + await page.waitForLoadState('domcontentloaded'); + await signInPage.signInButton.click(); + }); + + await test.step('Sign in', async () => { + await signInPage.signIn(page, `${data.partnerLevel}`); + await page.waitForLoadState('domcontentloaded'); + }); + + await test.step('Verify renew banner', async () => { + await bannersPage.profileIconButton.waitFor({ state: 'visible', timeout: 20000 }); + const renewBanner = await bannersPage.renewBanner; + await expect(renewBanner).toBeHidden(); + }); + }); +}); diff --git a/nala/blocks/signin/signin.page.js b/nala/blocks/signin/signin.page.js index 6f4ef01..707d53a 100644 --- a/nala/blocks/signin/signin.page.js +++ b/nala/blocks/signin/signin.page.js @@ -15,41 +15,42 @@ export default class SignInPage { } 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(); - } + 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 verifyRedirectAfterLogin({ page, expect, path, partnerLevel, expectedLandingPageURL }) { - await page.goto(path); - await page.waitForLoadState('domcontentloaded'); - if (path.includes('stage.adobe.com/partners.html')) { - await this.signInButtonStageAdobe.click(); - } else { - await this.signInButton.click(); - } - await this.signIn(page, partnerLevel); - await page.waitForLoadState('domcontentloaded'); - if (path.includes('stage.adobe.com/partners.html')) { - await this.profileIconButtonAdobe.waitFor({ state: 'visible', timeout: 20000 }); - const pages = await page.context().pages(); - } else { - await this.profileIconButton.waitFor({ state: 'visible', timeout: 20000 }); - const pages = await page.context().pages(); - await expect(pages[0].url()).toContain(expectedLandingPageURL); - } + async verifyRedirectAfterLogin({ page, expect, path, partnerLevel, expectedLandingPageURL }) { + await page.goto(path); + await page.waitForLoadState('domcontentloaded'); + if (path.includes('stage.adobe.com/partners.html')) { + await this.signInButtonStageAdobe.waitFor({ state: 'visible', timeout: 30000 }); + await this.signInButtonStageAdobe.click(); + } else { + await this.signInButton.click(); } + await this.signIn(page, partnerLevel); + await page.waitForLoadState('domcontentloaded'); + if (path.includes('stage.adobe.com/partners.html')) { + await this.profileIconButtonAdobe.waitFor({ state: 'visible', timeout: 30000 }); + const pages = await page.context().pages(); + } else { + await this.profileIconButton.waitFor({ state: 'visible', timeout: 30000 }); + const pages = await page.context().pages(); + await expect(pages[0].url()).toContain(expectedLandingPageURL); + } + } async addCookie(partnerData, page, context) { this.context = context; await this.context.addCookies([{ name: 'partner_data', - value: `{"${partnerData.partnerPortal}":{"company":"Company"%2C` + value: `{"${partnerData.partnerPortal}":{"accountAnniversary":"${partnerData.anniversaryDate ? partnerData.anniversaryDate : '2040-08-22T00:00:00.000Z'}"%2C"company":"Company"%2C` + `"firstName":"${partnerData.firstName !== undefined && partnerData.firstName !== null ? partnerData.firstName : 'Name'}"%2C"lastName":"LastName"%2C` - + `"level":"${partnerData.partnerLevel}"%2C"permissionRegion":"${partnerData.permissionRegion}"%2C"status":"MEMBER"}}`, + + `"level":"${partnerData.partnerLevel}"%2C"permissionRegion":"${partnerData.permissionRegion}"%2C"primaryContact":true%2C"salesCenterAccess":true%2C"status":"MEMBER"}}`, url: `${page}`, }]); }