Skip to content

Commit

Permalink
MWPW-162847 [MEP][nala] add ul-li selector test (#3238)
Browse files Browse the repository at this point in the history
* add ul-li selector test

* add test id

---------

Co-authored-by: John Pratt <jpratt@adobe.com>
  • Loading branch information
jpratt2 and John Pratt authored Dec 5, 2024
1 parent b6e67a7 commit 44ee6f1
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nala/features/personalization/ul-ol-li.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
name: 'Personalization Feature',
features: [
{
tcid: '0',
name: '@check ul selector',
desc: 'Verify that ul selectors work (skipping ol selectors)',
path: '/drafts/nala/features/personalization/ul-ol-li/ul-selector',
data: { defaultURL: '/drafts/nala/features/personalization/ul-ol-li/ul-selector?mep=%2Fdrafts%2Fnala%2Ffeatures%2Fpersonalization%2Ful-ol-li%2Ful-selector.json--default' },
tags: '@ul0 @smoke @regression @milo ',
},
{
tcid: '1',
name: '@check li selectors',
desc: 'Verify that li selectors work',
path: '/drafts/nala/features/personalization/ul-ol-li/li-selectors',
data: { defaultURL: '/drafts/nala/features/personalization/ul-ol-li/li-selectors?mep=%2Fdrafts%2Fnala%2Ffeatures%2Fpersonalization%2Ful-ol-li%2Fli-selectors.json--default' },
tags: '@ul1 @smoke @regression @milo ',
},
],
};
57 changes: 57 additions & 0 deletions nala/features/personalization/ul-ol-li.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { expect, test } from '@playwright/test';
import { features } from './ul-ol-li.spec.js';

const miloLibs = process.env.MILO_LIBS || '';

// Test 0 : check ul selectors (skipping ol selectors)
test(`[Test Id - ${features[0].tcid}] ${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => {
const pznUrl = `${baseURL}${features[0].path}${miloLibs}`;
const defaultUrl = `${baseURL}${features[0].data.defaultURL}${miloLibs}`;
const pznUpdateLocator = '[data-manifest-id="ul-selector.json"]';
const defaultUlLocator = 'ul.icon-list';

await test.step('step-1: verify the default test page has a regular ul list with 3 bullets', async () => {
console.info(`[Test Page]: ${defaultUrl}`);
await page.goto(defaultUrl);
await expect(page.locator(pznUpdateLocator)).toHaveCount(0);
await expect(page.locator(defaultUlLocator)).toHaveCount(1);
const element = page.locator(defaultUlLocator);
await expect(element.locator('li')).toHaveCount(3);
});

await test.step('step-2: Verify personalized page has a text replacement for the ul list', async () => {
console.info(`[Test Page]: ${pznUrl}`);
await page.goto(pznUrl);
const element = page.locator(pznUpdateLocator);
const innerHtml = await element.innerHTML();
await expect(page.locator(pznUpdateLocator)).toHaveCount(1);
await expect(page.locator(defaultUlLocator)).toHaveCount(0);
await expect(innerHtml).toEqual('replacement for the ul');
});
});

// Test 1 : check li selectors
test(`[Test Id - ${features[1].tcid}] ${features[1].name},${features[1].tags}`, async ({ page, baseURL }) => {
const pznUrl = `${baseURL}${features[1].path}${miloLibs}`;
const defaultUrl = `${baseURL}${features[1].data.defaultURL}${miloLibs}`;
const pznUpdateLocator = 'li[data-manifest-id="li-selectors.json"]';
const defaultUlLocator = 'ul.icon-list';

await test.step('step-1: verify the default test page has a regular ul list with 3 bullets', async () => {
console.info(`[Test Page]: ${defaultUrl}`);
await page.goto(defaultUrl);
await expect(page.locator(pznUpdateLocator)).toHaveCount(0);
await expect(page.locator(defaultUlLocator)).toHaveCount(1);
const element = page.locator(defaultUlLocator);
await expect(element.locator('li')).toHaveCount(3);
});

await test.step('step-2: Verify that the personalized page has 3 replacements for the line items', async () => {
console.info(`[Test Page]: ${pznUrl}`);
await page.goto(pznUrl);
const element = page.locator(pznUpdateLocator).first();
const innerHtml = await element.innerHTML();
await expect(page.locator(pznUpdateLocator)).toHaveCount(3);
await expect(innerHtml).toEqual('replace all line items');
});
});

0 comments on commit 44ee6f1

Please sign in to comment.