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-158314 : NALA] Add nala tests for additional marquee variants #2950

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
57 changes: 57 additions & 0 deletions nala/blocks/marquee-anchors/marquee-anchors.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export default class MarqueeAnchors {
constructor(page, nth = 0) {
this.page = page;

// marquee anchor variants locators
this.marqueeAnchors = page.locator('.marquee-anchors').nth(nth);
this.marqueeAnchorsTransparent = page.locator('.marquee-anchors').nth(nth);

// marquee details
this.detailM = this.marqueeAnchors.locator('.detail-m');
this.detailL = this.marqueeAnchors.locator('.detail-l');

// marquee headings
this.headingL = this.marqueeAnchors.locator('.heading-l').nth(0);

// marquee body area
this.bodyM = this.marqueeAnchors.locator('.body-m').nth(0);

// marquee actions area
this.actionArea = this.marqueeAnchors.locator('.action-area');
this.outlineButton = this.marqueeAnchors.locator('.con-button.outline');
this.blueButton = this.marqueeAnchors.locator('.con-button.blue');
this.supplementalText = this.marqueeAnchors.locator('.supplemental-text');
this.foregroundImage = this.marqueeAnchors.locator('.supplemental-text img');
// marquee anchor link
this.anchorHeader = this.marqueeAnchors.locator('.links-header');
this.anchorFooter = this.marqueeAnchors.locator('.links-footer');

this.anchorLinks = this.marqueeAnchors.locator('.anchor-link');
this.anchorLink = {
howTo: {
link: this.anchorLinks.nth(0),
linkHeader: this.anchorLinks.nth(0).locator('#anchor-how-to'),
linkText: this.anchorLinks.nth(0).locator('#anchor-how-to p').nth(0),
icon: this.anchorLinks.nth(0).locator('img.icon-milo'),
},
text: {
link: this.anchorLinks.nth(1),
linkHeader: this.anchorLinks.locator('#anchor-text'),
linkText: this.anchorLinks.locator('#anchor-text p').nth(0),
icon: this.anchorLinks.nth(1).locator('img.icon-milo'),
},
media: {
link: this.anchorLinks.nth(2),
linkHeader: this.anchorLinks.locator('#anchor-media'),
linkText: this.anchorLinks.locator('#anchor-media p').nth(0),
icon: this.anchorLinks.nth(2).locator('img.icon-milo'),
},
linkToAdobe: {
link: this.anchorLinks.nth(3),
linkHeader: this.anchorLinks.locator('h4#anchor-link-to-adobe'),
linkText: this.anchorLinks.locator('#anchor-link-to-adobe p').nth(0),
icon: this.anchorLinks.nth(3).locator('img.icon-milo'),
},
};
}
}
81 changes: 81 additions & 0 deletions nala/blocks/marquee-anchors/marquee-anchors.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
module.exports = {
name: 'Marquee Anchors Block',
features: [
{
tcid: '0',
name: 'Marquee Anchors',
path: '/drafts/nala/blocks/marquee/marquee-anchors',
data: {
detailText: 'Heading M Bold 24/30',
h2Text: 'Heading XL Bold (36/45) Lorem ipsum (Image Background)',
bodyText: 'Lorem ipsum dolor sit amet,.',
outlineButtonText: 'Lorem ipsum',
blueButtonText: 'Call to action',
anchors: {
linkCount: 4,
headerText: 'Anchors header (optional)',
footerText: 'Anchors footer What we offer (optional)',
howTo: {
h4Text: 'How to',
linkText: 'Link to a section with header “How To”',
href: 'http://how-to-block/',
},
text: {
h4Text: 'Text',
linkText: 'Link to a section with header “Text”',
href: 'http://text-block/',
},
media: {
h4Text: 'Media',
linkText: 'Link to a section with header “Media”',
href: 'http://media-block/',
},
linkToAdobe: {
h4Text: 'Link to Adobe',
linkText: 'Link to a new page',
href: 'https://adobe.com/',
},
},
},
tags: '@marquee @marquee-anchors @smoke @regression @milo',
},
{
tcid: '1',
name: 'Marquee Anchors (Transparent)',
path: '/drafts/nala/blocks/marquee/marquee-anchors-transparent',
data: {
detailText: 'Heading M Bold 24/30',
h2Text: 'Heading XL Bold (36/45) Lorem ipsum (Image Background)',
bodyText: 'Lorem ipsum dolor sit amet.',
outlineButtonText: 'Lorem ipsum',
blueButtonText: 'Call to action',
anchors: {
linkCount: 4,
headerText: 'Anchors header (optional)',
footerText: 'Anchors footer What we offer (optional)',
howTo: {
h4Text: 'How to',
linkText: 'Link to a section with header “How To”',
href: 'http://how-to-block/',
},
text: {
h4Text: 'Text',
linkText: 'Link to a section with header “Text”',
href: 'http://text-block/',
},
media: {
h4Text: 'Media',
linkText: 'Link to a section with header “Media”',
href: 'http://media-block/',
},
linkToAdobe: {
h4Text: 'Link to Adobe',
linkText: 'Link to a new page',
href: 'https://adobe.com/',
},
},
},
tags: '@marquee @marquee-anchors @smoke @regression @milo',
},
],
};
132 changes: 132 additions & 0 deletions nala/blocks/marquee-anchors/marquee-anchors.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import { expect, test } from '@playwright/test';
import WebUtil from '../../libs/webutil.js';
import { features } from './marquee-anchors.spec.js';
import MarqueeAnchors from './marquee-anchors.page.js';

let webUtil;
let marquee;

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

test.describe('Milo Marquee Anchors test suite', () => {
test.beforeEach(async ({ page }) => {
webUtil = new WebUtil(page);
marquee = new MarqueeAnchors(page);
});

// Test 0 : Marquee anchors
test(`[Test Id - ${features[0].tcid}] ${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Space after comma, before tags.

console.info(`[Test Page]: ${baseURL}${features[0].path}${miloLibs}`);
const { data } = features[0];

await test.step('step-1: Go to Marquee anchors block 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 marquee anchors specs', async () => {
await expect(await marquee.marqueeAnchors).toBeVisible();

await expect(await marquee.detailM).toContainText(data.detailText);
await expect(await marquee.headingL).toContainText(data.h2Text);
await expect(await marquee.bodyM).toContainText(data.bodyText);
await expect(await marquee.outlineButton).toContainText(data.outlineButtonText);
await expect(await marquee.blueButton).toContainText(data.blueButtonText);

await expect(await marquee.foregroundImage).toBeVisible();

// verify marquee anchors links
await expect(marquee.anchorLinks).toHaveCount(data.anchors.linkCount);
await expect(marquee.anchorHeader).toContainText(data.anchors.headerText);

await expect(marquee.anchorLink.howTo.link).toContainText(data.anchors.howTo.linkText);
await expect(marquee.anchorLink.howTo.linkHeader).toContainText(data.anchors.howTo.h4Text);
await expect(marquee.anchorLink.howTo.link).toHaveAttribute('href', data.anchors.howTo.href);
await expect(marquee.anchorLink.howTo.icon).toBeVisible();

await expect(marquee.anchorLink.text.link).toContainText(data.anchors.text.linkText);
await expect(marquee.anchorLink.text.linkHeader).toContainText(data.anchors.text.h4Text);
await expect(marquee.anchorLink.text.link).toHaveAttribute('href', data.anchors.text.href);
await expect(marquee.anchorLink.text.icon).toBeVisible();

await expect(marquee.anchorLink.media.link).toContainText(data.anchors.media.linkText);
await expect(marquee.anchorLink.media.linkHeader).toContainText(data.anchors.media.h4Text);
await expect(marquee.anchorLink.media.link).toHaveAttribute('href', data.anchors.media.href);
await expect(marquee.anchorLink.media.icon).toBeVisible();

await expect(marquee.anchorLink.linkToAdobe.link).toContainText(data.anchors.linkToAdobe.linkText);
await expect(marquee.anchorLink.linkToAdobe.linkHeader).toContainText(data.anchors.linkToAdobe.h4Text);
await expect(marquee.anchorLink.linkToAdobe.link).toHaveAttribute('href', data.anchors.linkToAdobe.href);
await expect(marquee.anchorLink.linkToAdobe.icon).toBeVisible();

await expect(marquee.anchorFooter).toContainText(data.anchors.footerText);
});

await test.step('step-3: Verify analytics attributes', async () => {
await expect(await marquee.marqueeAnchors).toHaveAttribute('daa-lh', await webUtil.getBlockDaalh('marquee-anchors', 1));
await expect(await marquee.anchorLink.howTo.link).toHaveAttribute('daa-ll', await webUtil.getLinkDaall(`${data.anchors.howTo.h4Text} ${data.anchors.howTo.linkText}`, 3, data.anchors.headerText));
await expect(await marquee.anchorLink.text.link).toHaveAttribute('daa-ll', await webUtil.getLinkDaall(`${data.anchors.text.h4Text} ${data.anchors.text.linkText}`, 4, data.anchors.howTo.h4Text));
await expect(await marquee.anchorLink.media.link).toHaveAttribute('daa-ll', await webUtil.getLinkDaall(`${data.anchors.media.h4Text} ${data.anchors.media.linkText}`, 5, data.anchors.text.h4Text));
await expect(await marquee.anchorLink.linkToAdobe.link).toHaveAttribute('daa-ll', await webUtil.getLinkDaall(`${data.anchors.linkToAdobe.h4Text} ${data.anchors.linkToAdobe.linkText}`, 6, data.anchors.media.h4Text));
});
});

// Test 1 : Marquee anchors (transparent)
test(`[Test Id - ${features[1].tcid}] ${features[1].name},${features[1].tags}`, async ({ page, baseURL }) => {
console.info(`[Test Page]: ${baseURL}${features[1].path}${miloLibs}`);
const { data } = features[1];

await test.step('step-1: Go to Marquee anchors (Transparent) block 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 marquee anchors (Transparent) specs', async () => {
await expect(await marquee.marqueeAnchorsTransparent).toBeVisible();

await expect(await marquee.detailM).toContainText(data.detailText);
await expect(await marquee.headingL).toContainText(data.h2Text);
await expect(await marquee.bodyM).toContainText(data.bodyText);
await expect(await marquee.outlineButton).toContainText(data.outlineButtonText);
await expect(await marquee.blueButton).toContainText(data.blueButtonText);

await expect(await marquee.foregroundImage).toBeVisible();

// verify marquee anchors links
await expect(marquee.anchorLinks).toHaveCount(data.anchors.linkCount);
await expect(marquee.anchorHeader).toContainText(data.anchors.headerText);

await expect(marquee.anchorLink.howTo.link).toContainText(data.anchors.howTo.linkText);
await expect(marquee.anchorLink.howTo.linkHeader).toContainText(data.anchors.howTo.h4Text);
await expect(marquee.anchorLink.howTo.link).toHaveAttribute('href', data.anchors.howTo.href);
await expect(marquee.anchorLink.howTo.icon).toBeVisible();

await expect(marquee.anchorLink.text.link).toContainText(data.anchors.text.linkText);
await expect(marquee.anchorLink.text.linkHeader).toContainText(data.anchors.text.h4Text);
await expect(marquee.anchorLink.text.link).toHaveAttribute('href', data.anchors.text.href);
await expect(marquee.anchorLink.text.icon).toBeVisible();

await expect(marquee.anchorLink.media.link).toContainText(data.anchors.media.linkText);
await expect(marquee.anchorLink.media.linkHeader).toContainText(data.anchors.media.h4Text);
await expect(marquee.anchorLink.media.link).toHaveAttribute('href', data.anchors.media.href);
await expect(marquee.anchorLink.media.icon).toBeVisible();

await expect(marquee.anchorLink.linkToAdobe.link).toContainText(data.anchors.linkToAdobe.linkText);
await expect(marquee.anchorLink.linkToAdobe.linkHeader).toContainText(data.anchors.linkToAdobe.h4Text);
await expect(marquee.anchorLink.linkToAdobe.link).toHaveAttribute('href', data.anchors.linkToAdobe.href);
await expect(marquee.anchorLink.linkToAdobe.icon).toBeVisible();

await expect(marquee.anchorFooter).toContainText(data.anchors.footerText);

await test.step('step-3: Verify analytics attributes', async () => {
await expect(await marquee.marqueeAnchorsTransparent).toHaveAttribute('daa-lh', await webUtil.getBlockDaalh('marquee-anchors', 1));
await expect(await marquee.anchorLink.howTo.link).toHaveAttribute('daa-ll', await webUtil.getLinkDaall(`${data.anchors.howTo.h4Text} ${data.anchors.howTo.linkText}`, 3, data.anchors.headerText));
await expect(await marquee.anchorLink.text.link).toHaveAttribute('daa-ll', await webUtil.getLinkDaall(`${data.anchors.text.h4Text} ${data.anchors.text.linkText}`, 4, data.anchors.howTo.h4Text));
await expect(await marquee.anchorLink.media.link).toHaveAttribute('daa-ll', await webUtil.getLinkDaall(`${data.anchors.media.h4Text} ${data.anchors.media.linkText}`, 5, data.anchors.text.h4Text));
await expect(await marquee.anchorLink.linkToAdobe.link).toHaveAttribute('daa-ll', await webUtil.getLinkDaall(`${data.anchors.linkToAdobe.h4Text} ${data.anchors.linkToAdobe.linkText}`, 6, data.anchors.media.h4Text));
});
});
});
});
11 changes: 9 additions & 2 deletions nala/blocks/marquee/marquee.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ export default class Marquee {
// marquee types locators
this.marquee = page.locator('.marquee').nth(nth);
this.marqueeLight = page.locator('.marquee.light');
this.marqueeLightXxlButton = page.locator('.marquee.light.xxl-button');
this.marqueeSmall = page.locator('.marquee.small');
this.marqueeSmallLight = page.locator('.marquee.small.light');
this.marqueeDark = page.locator('.marquee.dark');
this.marqueeSmallDark = page.locator('.marquee.small.dark');
this.marqueeLarge = page.locator('.marquee.large');
this.marqueeLargeLight = page.locator('.marquee.large.light');
this.marqueeLargeDark = page.locator('.marquee.large.dark');
this.marqueeLargeStandardDark = page.locator('.marquee.large.standard.dark');
this.marqueeLargeCompactDark = page.locator('.marquee.large.compact.dark');
this.marqueeQuiet = page.locator('.marquee.quiet');
this.marqueeInline = page.locator('.marquee');
this.marqueeSplitSmall = page.locator('.marquee.split.small');
Expand All @@ -26,12 +30,12 @@ export default class Marquee {
this.brandImage = this.marquee.locator('.detail-m');

// marquee headings
this.headingXL = this.marquee.locator('.heading-xl');
this.headingXL = this.marquee.locator('.heading-xl').nth(0);
this.headingXXL = this.marquee.locator('.heading-xxl');

// marquee body area
this.bodyM = this.marquee.locator('.body-m');
this.bodyXL = this.marquee.locator('.body-xl');
this.bodyXL = this.marquee.locator('.body-xl').nth(0);

// marquee actions area
this.actionArea = this.marquee.locator('.action-area');
Expand All @@ -52,7 +56,9 @@ export default class Marquee {

this.actionLink1 = this.marquee.locator('a').nth(0);
this.actionLink2 = this.marquee.locator('a').nth(1);
this.actionLink3 = this.marquee.locator('a').nth(2);

this.supplementalText = this.marquee.locator('.supplemental-text');
// background images
this.background = this.marquee.locator('.background');
this.backgroundImage = this.marquee.locator('div.background img');
Expand All @@ -71,6 +77,7 @@ export default class Marquee {

// media images
this.mediaImage = this.marquee.locator('div.asset img');
this.foregroundAssetImage = this.marquee.locator('div.asset img');

// marquee attributes
this.attributes = {
Expand Down
Loading
Loading