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

warriors: update and activate commerce tests #418

Merged
merged 7 commits into from
Aug 16, 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
23 changes: 15 additions & 8 deletions features/milo/commerce.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ module.exports = {
tcid: '0',
name: '@Commerce-Price-Term',
path: '/drafts/nala/features/commerce/prices-with-term',
tags: '@commerce @smoke @regression @nopr',
tags: '@commerce @smoke @regression',
},
{
tcid: '1',
name: '@Commerce-Price-Unit-Term',
path: '/drafts/nala/features/commerce/prices-with-term-unit',
tags: '@commerce @smoke @regression @nopr',
tags: '@commerce @smoke @regression',

},
{
tcid: '2',
name: '@Commerce-Price-Taxlabel-Unit-Term',
path: '/drafts/nala/features/commerce/prices-with-term-unit-taxlabel',
tags: '@commerce @smoke @regression @nopr',
tags: '@commerce @smoke @regression',
},
{
tcid: '3',
name: '@Commerce-Promo',
path: '/drafts/nala/features/commerce/promo-placeholders',
data: { promo: 'nicopromo' },
tags: '@commerce @smoke @regression @nopr',
data: { promo: 'UMRM2MUSPr501YOC' },
tags: '@commerce @smoke @regression',
},
{
tcid: '4',
Expand All @@ -49,18 +49,25 @@ module.exports = {
tcid: '6',
name: '@Commerce-KitchenSink-Smoke',
path: '/docs/library/kitchen-sink/merch-card',
tags: '@commerce @kitchensink @smoke @regression @nopr',
tags: '@commerce @kitchensink @smoke @regression',
},
{
tcid: '7',
name: '@Commerce-Localized',
path: '/de/drafts/nala/features/commerce/promo-placeholders',
data: {
promo: 'nicopromo',
promo: 'PEMAP50AASTE2',
CO: 'co=DE',
lang: 'lang=de',
},
tags: '@commerce @smoke @regression @nopr',
tags: '@commerce @smoke @regression',
},
{
tcid: '8',
name: '@Commerce-Old-Promo',
path: '/drafts/nala/features/commerce/promo-old-price',
data: { promo: 'UMRM2MUSPr501YOC' },
tags: '@commerce @smoke @regression',
},
],
};
2 changes: 1 addition & 1 deletion features/milo/promotions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module.exports = {
},
{
tcid: '13',
name: '@Promo-insert-fragment',
name: '@Promo-fragment-insert',
path: '/drafts/nala/features/promotions/promo-with-fragments-insert',
data: {
textMarquee: 'Fragment marquee',
Expand Down
93 changes: 45 additions & 48 deletions tests/milo/commerce.feature.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import FedsHeader from '../../selectors/feds/feds.header.page.js';
const miloLibs = process.env.MILO_LIBS || '';

let COMM;
test.beforeEach(async ({ page, baseURL }) => {
test.beforeEach(async ({ page, baseURL, browserName }) => {
COMM = new CommercePage(page);
const skipOn = ['bacom', 'business'];

skipOn.some((skip) => {
if (baseURL.includes(skip)) test.skip(true, `Skipping the commerce tests for ${baseURL}`);
return null;
});

// Skipping tests for chromium on github actions dut to net::ERR_HTTP2_PROTOCOL_ERROR.
if (browserName === 'chromium' && process.env.GITHUB_ACTIONS) test.skip();
});

test.describe('Commerce feature test suite', () => {
Expand All @@ -31,32 +34,23 @@ test.describe('Commerce feature test suite', () => {

await test.step('Validate regular price display', async () => {
await COMM.price.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.price).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.price).toHaveAttribute('data-display-per-unit', 'false');
await expect(COMM.price).toHaveAttribute('data-display-tax', 'false');
expect(await COMM.price.innerText()).toContain('US$263.88');
expect(await COMM.price.innerText()).toContain('US$263.88/yr');
expect(await COMM.price.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.price.locator('.price-unit-type').innerText()).toBe('');
expect(await COMM.price.locator('.price-tax-inclusivity').innerText()).toBe('');
});

await test.step('Validate optical price display', async () => {
await COMM.priceOptical.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.priceOptical).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.priceOptical).toHaveAttribute('data-display-per-unit', 'false');
await expect(COMM.priceOptical).toHaveAttribute('data-display-tax', 'false');
expect(await COMM.priceOptical.innerText()).toContain('US$21.99');
expect(await COMM.priceOptical.innerText()).toContain('US$21.99/mo');
expect(await COMM.priceOptical.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.priceOptical.locator('.price-unit-type').innerText()).toBe('');
expect(await COMM.priceOptical.locator('.price-tax-inclusivity').innerText()).toBe('');
});

await test.step('Validate strikethrough price display', async () => {
await COMM.priceStrikethrough.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-per-unit', 'false');
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-tax', 'false');
expect(await COMM.priceStrikethrough.innerText()).toContain('US$263.88');
expect(await COMM.priceStrikethrough.innerText()).toContain('US$263.88/yr');
expect(await COMM.priceStrikethrough.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.priceStrikethrough.locator('.price-unit-type').innerText()).toBe('');
expect(await COMM.priceStrikethrough.locator('.price-tax-inclusivity').innerText()).toBe('');
Expand All @@ -79,32 +73,23 @@ test.describe('Commerce feature test suite', () => {

await test.step('Validate regular price display', async () => {
await COMM.price.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.price).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.price).toHaveAttribute('data-display-per-unit', 'true');
await expect(COMM.price).toHaveAttribute('data-display-tax', 'false');
expect(await COMM.price.innerText()).toContain('US$263.88');
expect(await COMM.price.innerText()).toContain('US$');
expect(await COMM.price.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.price.locator('.price-unit-type').innerText()).not.toBe('');
expect(await COMM.price.locator('.price-tax-inclusivity').innerText()).toBe('');
});

await test.step('Validate optical price display', async () => {
await COMM.priceOptical.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.priceOptical).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.priceOptical).toHaveAttribute('data-display-per-unit', 'true');
await expect(COMM.priceOptical).toHaveAttribute('data-display-tax', 'false');
expect(await COMM.priceOptical.innerText()).toContain('US$21.99');
expect(await COMM.priceOptical.innerText()).toContain('US$');
expect(await COMM.priceOptical.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.priceOptical.locator('.price-unit-type').innerText()).not.toBe('');
expect(await COMM.priceOptical.locator('.price-tax-inclusivity').innerText()).toBe('');
});

await test.step('Validate strikethrough price display', async () => {
await COMM.priceStrikethrough.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-per-unit', 'true');
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-tax', 'false');
expect(await COMM.priceStrikethrough.innerText()).toContain('US$263.88');
expect(await COMM.priceStrikethrough.innerText()).toContain('US$');
expect(await COMM.priceStrikethrough.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.priceStrikethrough.locator('.price-unit-type').innerText()).not.toBe('');
expect(await COMM.priceStrikethrough.locator('.price-tax-inclusivity').innerText()).toBe('');
Expand All @@ -127,32 +112,23 @@ test.describe('Commerce feature test suite', () => {

await test.step('Validate regular price display', async () => {
await COMM.price.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.price).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.price).toHaveAttribute('data-display-per-unit', 'true');
await expect(COMM.price).toHaveAttribute('data-display-tax', 'true');
expect(await COMM.price.innerText()).toContain('US$263.88');
expect(await COMM.price.innerText()).toContain('US$');
expect(await COMM.price.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.price.locator('.price-unit-type').innerText()).not.toBe('');
expect(await COMM.price.locator('.price-tax-inclusivity').innerText()).not.toBe('');
});

await test.step('Validate optical price display', async () => {
await COMM.priceOptical.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.priceOptical).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.priceOptical).toHaveAttribute('data-display-per-unit', 'true');
await expect(COMM.priceOptical).toHaveAttribute('data-display-tax', 'true');
expect(await COMM.priceOptical.innerText()).toContain('US$21.99');
expect(await COMM.priceOptical.innerText()).toContain('US$');
expect(await COMM.priceOptical.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.priceOptical.locator('.price-unit-type').innerText()).not.toBe('');
expect(await COMM.priceOptical.locator('.price-tax-inclusivity').innerText()).not.toBe('');
});

await test.step('Validate strikethrough price display', async () => {
await COMM.priceStrikethrough.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-per-unit', 'true');
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-tax', 'true');
expect(await COMM.priceStrikethrough.innerText()).toContain('US$263.88');
expect(await COMM.priceStrikethrough.innerText()).toContain('US$');
expect(await COMM.priceStrikethrough.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.priceStrikethrough.locator('.price-unit-type').innerText()).not.toBe('');
expect(await COMM.priceStrikethrough.locator('.price-tax-inclusivity').innerText()).not.toBe('');
Expand All @@ -178,6 +154,9 @@ test.describe('Commerce feature test suite', () => {
await test.step('Validate regular price has promo', async () => {
await COMM.price.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.price).toHaveAttribute('data-promotion-code', data.promo);
await expect(COMM.price).toHaveAttribute('data-display-old-price', 'true');
await COMM.price.locator('.price').first().waitFor({ state: 'visible', timeout: 10000 });
await COMM.price.locator('.price-strikethrough').waitFor({ state: 'visible', timeout: 10000 });
});

await test.step('Validate optical price has promo', async () => {
Expand Down Expand Up @@ -205,6 +184,8 @@ test.describe('Commerce feature test suite', () => {

// @Commerce-Upgrade-Entitlement - Validate Upgrade commerce flow
test(`${features[4].name}, ${features[4].tags}`, async ({ page, baseURL }) => {
test.skip(); // Skipping due to missing login

const testPage = `${baseURL}${features[4].path}${miloLibs}`;
console.info('[Test Page]: ', testPage);

Expand Down Expand Up @@ -244,6 +225,8 @@ test.describe('Commerce feature test suite', () => {

// @Commerce-Download-Entitlement - Validate Download commerce flow
test(`${features[5].name}, ${features[5].tags}`, async ({ page, baseURL }) => {
test.skip(); // Skipping due to missing login

const testPage = `${baseURL}${features[5].path}${miloLibs}`;
console.info('[Test Page]: ', testPage);
const { data } = features[5];
Expand Down Expand Up @@ -296,7 +279,7 @@ test.describe('Commerce feature test suite', () => {

// Validate there are no unresolved commerce placeholders
await test.step('Validate wcs placeholders', async () => {
await COMM.merchCard.first().waitFor({ state: 'visible', timeout: 30000 });
await COMM.merchCard.first().waitFor({ state: 'visible', timeout: 45000 });
await webUtil.scrollPage('down', 'slow');
const unresolvedPlaceholders = await page.evaluate(
() => [...document.querySelectorAll('[data-wcs-osi]')].filter(
Expand Down Expand Up @@ -347,10 +330,7 @@ test.describe('Commerce feature test suite', () => {

await test.step('Validate regular price display', async () => {
await COMM.price.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.price).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.price).toHaveAttribute('data-display-per-unit', 'false');
await expect(COMM.price).toHaveAttribute('data-display-tax', 'false');
expect(await COMM.price.innerText()).toContain('€/Monat');
expect(await COMM.price.innerText()).toContain('€/Jahr');
expect(await COMM.price.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.price.locator('.price-unit-type').innerText()).toBe('');
expect(await COMM.price.locator('.price-tax-inclusivity').innerText()).toBe('');
Expand All @@ -359,9 +339,6 @@ test.describe('Commerce feature test suite', () => {

await test.step('Validate optical price display', async () => {
await COMM.priceOptical.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.priceOptical).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.priceOptical).toHaveAttribute('data-display-per-unit', 'false');
await expect(COMM.priceOptical).toHaveAttribute('data-display-tax', 'false');
expect(await COMM.priceOptical.innerText()).toContain('€/Monat');
expect(await COMM.priceOptical.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.priceOptical.locator('.price-unit-type').innerText()).toBe('');
Expand All @@ -371,9 +348,6 @@ test.describe('Commerce feature test suite', () => {

await test.step('Validate strikethrough price display', async () => {
await COMM.priceStrikethrough.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-recurrence', 'true');
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-per-unit', 'false');
await expect(COMM.priceStrikethrough).toHaveAttribute('data-display-tax', 'false');
expect(await COMM.priceStrikethrough.innerText()).toContain('€/Jahr');
expect(await COMM.priceStrikethrough.locator('.price-recurrence').innerText()).not.toBe('');
expect(await COMM.priceStrikethrough.locator('.price-unit-type').innerText()).toBe('');
Expand All @@ -385,4 +359,27 @@ test.describe('Commerce feature test suite', () => {
await expect(COMM.priceStrikethrough).toHaveAttribute('data-promotion-code', data.promo);
});
});

// @Commerce-Old-Promo - Validate promo price WITHOUT old price
test(`${features[8].name},${features[8].tags}`, async ({ page, baseURL }) => {
const testPage = `${baseURL}${features[8].path}${miloLibs}`;
const { data } = features[8];

console.info('[Test Page]: ', testPage);

await test.step('Go to the test page', async () => {
await page.goto(testPage);
await page.waitForLoadState('domcontentloaded');
});

await test.step('Validate promo price does not show old price', async () => {
await COMM.price.waitFor({ state: 'visible', timeout: 10000 });
await expect(COMM.price).toHaveAttribute('data-promotion-code', data.promo);
await expect(COMM.price).not.toHaveAttribute('data-display-old-price', 'true');
// expect(await COMM.price.innerText()).toContain('US$17.24');
// expect(await COMM.price.innerText()).not.toContain('US$34.49');
await expect(await COMM.price.locator('.price').first()).toBeVisible();
await expect(await COMM.price.locator('.price-strikethrough')).not.toBeVisible();
});
});
});
2 changes: 1 addition & 1 deletion tests/milo/promotions.feature.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ test.describe('Promotions feature test suite', () => {
});
});

// @Promo-insert-fragment - Validate promo insert text after and before fragment
// @Promo-fragment-insert - Validate promo insert text after and before fragment
test(`${features[13].name},${features[13].tags}`, async ({ page, baseURL }) => {
const testPage = `${baseURL}${features[13].path}${miloLibs}`;
const { data } = features[13];
Expand Down
Loading