Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-162847 [MEP][nala] add ul-li selector test #3238

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
Loading