Skip to content

Commit

Permalink
[MWPW-160961][NALA]Move and Update Nala Personalization feature autom…
Browse files Browse the repository at this point in the history
…ation tests to Milo repo (#3087)

* add personalization tests

* fix eslint errors

* remove commented lines

---------

Co-authored-by: Santoshkumar Sharanappa Nateekar <[email protected]>
  • Loading branch information
skumar09 and Santoshkumar Sharanappa Nateekar authored Oct 24, 2024
1 parent 2392240 commit 029f841
Show file tree
Hide file tree
Showing 2 changed files with 181 additions and 0 deletions.
44 changes: 44 additions & 0 deletions nala/features/personalization/personalization.spec.js
Original file line number Diff line number Diff line change
@@ -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 ',
},
],
};
137 changes: 137 additions & 0 deletions nala/features/personalization/personalization.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
});

0 comments on commit 029f841

Please sign in to comment.