From 029f841ac8c2b17ffb0030b88fc7492eb78e0a59 Mon Sep 17 00:00:00 2001 From: Santoshkumar Nateekar Date: Thu, 24 Oct 2024 07:55:32 -0700 Subject: [PATCH] [MWPW-160961][NALA]Move and Update Nala Personalization feature automation tests to Milo repo (#3087) * add personalization tests * fix eslint errors * remove commented lines --------- Co-authored-by: Santoshkumar Sharanappa Nateekar --- .../personalization/personalization.spec.js | 44 ++++++ .../personalization/personalization.test.js | 137 ++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 nala/features/personalization/personalization.spec.js create mode 100644 nala/features/personalization/personalization.test.js diff --git a/nala/features/personalization/personalization.spec.js b/nala/features/personalization/personalization.spec.js new file mode 100644 index 0000000000..fca7286295 --- /dev/null +++ b/nala/features/personalization/personalization.spec.js @@ -0,0 +1,44 @@ +module.exports = { + name: 'Personalization Feature', + features: [ + { + tcid: '0', + name: '@Replace content', + desc: 'Personalization with action=replaceContent', + path: '/drafts/nala/features/personalization/pzn-replacecontent', + data: { + target: 'textpersonlization', + pznExpName: 'param-target=textpersonlization', + pznFileName: 'pzn1', + h3Text: 'Text', + }, + tags: '@pzn @smoke @regression @milo ', + }, + { + tcid: '1', + name: '@Insert Content Before', + desc: 'Personalization with action=insertContentBefore', + path: '/drafts/nala/features/personalization/pzn-insertcontent-before', + data: { + target: 'textpersonlization', + pznExpName: 'param-target=textpersonlization', + pznFileName: 'insert-content-before', + h3Text: 'Text', + }, + tags: '@pzn @smoke @regression @milo ', + }, + { + tcid: '2', + name: '@Insert Content After', + desc: 'Personalization with action=insertContentAfter', + path: '/drafts/nala/features/personalization/pzn-insertcontent-after', + data: { + target: 'textpersonlization', + pznExpName: 'param-target=textpersonlization', + pznFileName: 'insert-content-before', + h3Text: 'Text', + }, + tags: '@pzn @smoke @regression @milo ', + }, + ], +}; diff --git a/nala/features/personalization/personalization.test.js b/nala/features/personalization/personalization.test.js new file mode 100644 index 0000000000..d4bcbd86d1 --- /dev/null +++ b/nala/features/personalization/personalization.test.js @@ -0,0 +1,137 @@ +import { expect, test } from '@playwright/test'; +import WebUtil from '../../libs/webutil.js'; +import { features } from './personalization.spec.js'; +import MarqueeBlock from '../../blocks/marquee/marquee.page.js'; +import TextBlock from '../../blocks/text/text.page.js'; +import Howto from '../../blocks/howto/howto.page.js'; + +let webUtil; +let howto; +let marquee; +let text; +let pznUrl; + +const miloLibs = process.env.MILO_LIBS || ''; + +test.describe('Milo Personalization feature test suite', () => { + test.beforeEach(async ({ page }) => { + webUtil = new WebUtil(page); + }); + + test.beforeAll(async ({ baseURL }) => { + const skipOn = ['bacom', 'business']; + + skipOn.some((skip) => { + if (baseURL.includes(skip)) test.skip(true, `Skipping the personalization tests for ${baseURL}`); + return null; + }); + }); + + // Test 0 : Personalization (Replace content) + test(`${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => { + console.info(`[Test Page]: ${baseURL}${features[0].path}${miloLibs}`); + const { data } = features[0]; + text = new TextBlock(page); + marquee = new MarqueeBlock(page); + pznUrl = `${baseURL}${features[0].path}${'?target='}${data.target}&${miloLibs}`; + + await test.step('step-1: Go to default test page', async () => { + await page.goto(`${baseURL}${features[0].path}${miloLibs}`); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(`${baseURL}${features[0].path}${miloLibs}`); + }); + + await test.step('step-2: Verify default test page content/specs', async () => { + await expect(await marquee.marquee).toBeVisible(); + }); + + await test.step('step-3: Navigate to personlized page and verify content/specs', async () => { + await page.goto(pznUrl); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(pznUrl); + console.info(`[Pzn Page]: ${pznUrl}`); + + await expect(await text.text).toBeVisible(); + await expect(await text.headline).toContainText(data.h3Text); + + const blockDll = await webUtil.getPznBlockDaalh('text', 1, data.pznExpName, data.pznFileName); + await expect(await text.text).toHaveAttribute('daa-lh', blockDll); + }); + }); + + // Test 1 : Personalization (Insert Content Before) + test(`${features[1].name},${features[1].tags}`, async ({ page, baseURL }) => { + console.info(`[Test Page]: ${baseURL}${features[1].path}${miloLibs}`); + const { data } = features[1]; + text = new TextBlock(page); + marquee = new MarqueeBlock(page); + pznUrl = `${baseURL}${features[1].path}${'?target='}${data.target}&${miloLibs}`; + + await test.step('step-1: Go to default test page', async () => { + await page.goto(`${baseURL}${features[1].path}${miloLibs}`); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(`${baseURL}${features[1].path}${miloLibs}`); + }); + + await test.step('step-2: Verify default test page content/specs', async () => { + await expect(await marquee.marquee).toBeVisible(); + }); + + await test.step('step-3: Navigate to personlized page and verify content/specs', async () => { + await page.goto(pznUrl); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(pznUrl); + console.info(`[Pzn Page]: ${pznUrl}`); + + await expect(await text.text).toBeVisible(); + await expect(await text.headline).toContainText(data.h3Text); + + // text block Dll analytics + const textBlockDll = await webUtil.getPznBlockDaalh('text', 1, data.pznExpName, data.pznFileName); + await expect(await text.text).toHaveAttribute('daa-lh', textBlockDll); + + // Marquee block Dll analytics + await expect(await marquee.marquee).toBeVisible(); + const marqueeBlockDll = await webUtil.getPznBlockDaalh('marquee', 2, data.pznExpName, data.pznFileName); + await expect(await marquee.marquee).toHaveAttribute('daa-lh', marqueeBlockDll); + }); + }); + + // Test 2 : Personalization (Insert Content After) + test(`${features[2].name},${features[2].tags}`, async ({ page, baseURL }) => { + console.info(`[Test Page]: ${baseURL}${features[2].path}${miloLibs}`); + const { data } = features[2]; + text = new TextBlock(page); + howto = new Howto(page); + pznUrl = `${baseURL}${features[2].path}${'?target='}${data.target}&${miloLibs}`; + + await test.step('step-1: Go to default test page', async () => { + await page.goto(`${baseURL}${features[2].path}${miloLibs}`); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(`${baseURL}${features[2].path}${miloLibs}`); + }); + + await test.step('step-2: Verify default test page content/specs', async () => { + await expect(await howto.howTo).toBeVisible(); + }); + + await test.step('step-3: Navigate to personlized page and verify content/specs', async () => { + await page.goto(pznUrl); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(pznUrl); + console.info(`[Pzn Page]: ${pznUrl}`); + + await expect(await text.text).toBeVisible(); + await expect(await text.headline).toContainText(data.h3Text); + + // HowTo block Dll analytics + await expect(await howto.howTo).toBeVisible(); + const howtoBlockDll = await webUtil.getPznBlockDaalh('how-to', 1, data.pznExpName, data.pznFileName); + await expect(await howto.howTo).toHaveAttribute('daa-lh', howtoBlockDll); + + // text block Dll analytics + const textBlockDll = await webUtil.getPznBlockDaalh('text', 2, data.pznExpName, data.pznFileName); + await expect(await text.text).toHaveAttribute('daa-lh', textBlockDll); + }); + }); +});