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-140873] Refactor automation test scripts #233

Merged
merged 7 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
109 changes: 0 additions & 109 deletions selectors/milo/quote.block.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,115 +62,6 @@ export default class Quote {
'quote-align-right': { 'class': 'quote contained align-right con-block' },
'quote-xl-spacing': { 'class': 'quote contained xl-spacing con-block' },
'section-dark': { 'style': 'background: rgb(102, 102, 102);' },

};
}

/**
* Verifies the visibility, css, attributes, styles, of elements or sections of
* the specified Quote block.
*
* @param {string} quoteType - The type of the Quote block to verify.
* Possible values are 'quote', 'quote (contained)', 'quote (inline)'.
* quote (borders), quote (align-right), and quote (xl-spaced)
* @returns {Promise<boolean>} - Returns true if the specified Quote type has the expected values.
*/
async verifyQuote(quoteType, data) {
await expect(await this.quote).toBeVisible();

switch (quoteType) {
case 'quote':
// verify quote block image visibility, attributes, css and different contents
await expect(await this.quoteImage).toBeVisible();
expect(await WebUtil.verifyAttributes(
await this.quote,
this.attProperties.quote,
)).toBeTruthy();
expect(await WebUtil.verifyCSS(await this.quote, this.cssProperties.quote)).toBeTruthy();
await expect(await this.quoteCopy).toContainText(data.quoteCopy);
await expect(await this.quoteFigCaption).toContainText(data.figCaption);
await expect(await this.quoteFigCaptionCite).toContainText(data.cite);

return true;
case 'quote (contained)':
// verify quote (contained) block image visibility, attributes, css and different contents
await expect(await this.quoteImage).toBeVisible();
expect(await WebUtil.verifyAttributes(
await this.quote,
this.attProperties['quote-contained'],
)).toBeTruthy();
expect(await WebUtil.verifyCSS(await this.quote, this.cssProperties['quote-contained'])).toBeTruthy();
await expect(await this.quoteCopy).toContainText(data.quoteCopy);
await expect(await this.quoteFigCaption).toContainText(data.figCaption);
await expect(await this.quoteFigCaptionCite).toContainText(data.cite);

return true;

case 'quote (inline)':
// verify quote (inline) block image visibility, attributes, css and different contents
await expect(await this.quoteImage).toBeVisible();
expect(await WebUtil.verifyAttributes(
await this.quote,
this.attProperties['quote-inline'],
)).toBeTruthy();
expect(await WebUtil.verifyCSS(await this.quote, this.cssProperties.quote)).toBeTruthy();
expect(await WebUtil.verifyCSS(await this.quoteImage, this.cssProperties['quote-inline-figure'])).toBeTruthy();
await expect(await this.quoteCopy).toContainText(data.quoteCopy);
await expect(await this.quoteFigCaption).toContainText(data.figCaption);
await expect(await this.quoteFigCaptionCite).toContainText(data.cite);

return true;

case 'quote (borders)':
// verify quote (borders) block image not visibility, attributes, css and different contents
await expect(await this.quoteImage).not.toBeVisible();
expect(await WebUtil.verifyAttributes(
await this.quote,
this.attProperties['quote-borders'],
)).toBeTruthy();
expect(await WebUtil.verifyCSS(await this.quote, this.cssProperties.quote)).toBeTruthy();
await expect(await this.quoteCopy).toContainText(data.quoteCopy);
await expect(await this.quoteFigCaption).toContainText(data.figCaption);
await expect(await this.quoteFigCaptionCite).toContainText(data.cite);

return true;

case 'quote (align-right)':
// verify quote (align-right) block image visibility, attributes, css and different content
await expect(await this.quoteImage).toBeVisible();
expect(await WebUtil.verifyAttributes(
await this.quote,
this.attProperties['quote-align-right'],
)).toBeTruthy();
expect(await WebUtil.verifyCSS(await this.quote, this.cssProperties['quote-align-right'])).toBeTruthy();
await expect(await this.quoteCopy).toContainText(data.quoteCopy);
await expect(await this.quoteFigCaption).toContainText(data.figCaption);
await expect(await this.quoteFigCaptionCite).toContainText(data.cite);

return true;

case 'quote (xl-spaced)':
// verify quote (xl-spaced) block image visibility, attributes, css and different content
await expect(await this.sectionDark).toBeVisible();
expect(await WebUtil.verifyAttributes(
await this.sectionDark,
this.attProperties['section-dark'],
)).toBeTruthy();

await expect(await this.quoteImage).not.toBeVisible();
expect(await WebUtil.verifyAttributes(
await this.quote,
this.attProperties['quote-xl-spacing'],
)).toBeTruthy();

expect(await WebUtil.verifyCSS(await this.quote, this.cssProperties.quote)).toBeTruthy();
await expect(await this.quoteCopy).toContainText(data.quoteCopy);
await expect(await this.quoteFigCaption).toContainText(data.figCaption);
await expect(await this.quoteFigCaptionCite).toContainText(data.cite);

return true;
default:
throw new Error(`Unsupported Text type: ${this.quoteType}`);
}
}
}
75 changes: 62 additions & 13 deletions tests/milo/quote.block.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { expect, test } from '@playwright/test';
import { WebUtil } from '../../libs/webutil.js';
import { features } from '../../features/milo/quote.block.spec.js';
import QuoteBlock from '../../selectors/milo/quote.block.page.js';

let quote;
let webUtil

test.describe('Milo Quote Block test suite', () => {
test.beforeEach(async ({ page }) => {
webUtil = new WebUtil(page);
quote = new QuoteBlock(page);
});

// Test 0 : Quote default block
test(`${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => {
console.info(`[Test Page]: ${baseURL}${features[0].path}`);
const { data } = features[0];

await test.step('step-1: Go to Quote block test page', async () => {
await page.goto(`${baseURL}${features[0].path}`);
Expand All @@ -19,13 +24,21 @@ test.describe('Milo Quote Block test suite', () => {
});

await test.step('step-2: Verify Quote block content/specs', async () => {
const { data } = features[0];
expect(await quote.verifyQuote('quote', data)).toBeTruthy();
await expect(await quote.quoteImage).toBeVisible();
await expect(await quote.quoteCopy).toContainText(data.quoteCopy);
await expect(await quote.quoteFigCaption).toContainText(data.figCaption);
await expect(await quote.quoteFigCaptionCite).toContainText(data.cite);

expect(await webUtil.verifyAttributes_(await quote.quote, quote.attProperties.quote)).toBeTruthy();
expect(await webUtil.verifyCSS_(await quote.quote, quote.cssProperties.quote)).toBeTruthy();

});
});

// Test 1 : quote (contained)
test(`${features[1].name},${features[1].tags}`, async ({ page, baseURL }) => {
console.info(`[Test Page]: ${baseURL}${features[1].path}`);
const { data } = features[1];

await test.step('step-1: Go to Quote block test page', async () => {
await page.goto(`${baseURL}${features[1].path}`);
Expand All @@ -34,13 +47,20 @@ test.describe('Milo Quote Block test suite', () => {
});

await test.step('step-2: Verify Quote (contained) block content/specs', async () => {
const { data } = features[1];
expect(await quote.verifyQuote('quote (contained)', data)).toBeTruthy();
await expect(await quote.quoteImage).toBeVisible();
await expect(await quote.quoteCopy).toContainText(data.quoteCopy);
await expect(await quote.quoteFigCaption).toContainText(data.figCaption);
await expect(await quote.quoteFigCaptionCite).toContainText(data.cite);

expect(await webUtil.verifyAttributes_(await quote.quote, quote.attProperties['quote-contained'], )).toBeTruthy();
expect(await webUtil.verifyCSS_(await quote.quote, quote.cssProperties['quote-contained'])).toBeTruthy();
});
});

// Test 2 : Quote (inline,contained)
test(`${features[2].name},${features[2].tags}`, async ({ page, baseURL }) => {
console.info(`[Test Page]: ${baseURL}${features[2].path}`);
const { data } = features[2];

await test.step('step-1: Go to Quote (inline) block test page', async () => {
await page.goto(`${baseURL}${features[2].path}`);
Expand All @@ -49,13 +69,21 @@ test.describe('Milo Quote Block test suite', () => {
});

await test.step('step-2: Verify Quote (inline) block content/specs', async () => {
const { data } = features[2];
expect(await quote.verifyQuote('quote (inline)', data)).toBeTruthy();
await expect(await quote.quoteImage).toBeVisible();
await expect(await quote.quoteCopy).toContainText(data.quoteCopy);
await expect(await quote.quoteFigCaption).toContainText(data.figCaption);
await expect(await quote.quoteFigCaptionCite).toContainText(data.cite);

expect(await webUtil.verifyAttributes_(await quote.quote, quote.attProperties['quote-inline'])).toBeTruthy();
expect(await webUtil.verifyCSS_(await quote.quote, quote.cssProperties.quote)).toBeTruthy();
expect(await webUtil.verifyCSS_(await quote.quoteImage, quote.cssProperties['quote-inline-figure'])).toBeTruthy();
});
});

// Test 3 : quote (borders)
test(`${features[3].name},${features[3].tags}`, async ({ page, baseURL }) => {
console.info(`[MiloInfo] Checking page: ${baseURL}${features[3].path}`);
const { data } = features[3];

await test.step('step-1: Go to Quote (borders) block test page', async () => {
await page.goto(`${baseURL}${features[3].path}`);
Expand All @@ -64,13 +92,20 @@ test.describe('Milo Quote Block test suite', () => {
});

await test.step('step-2: Verify Quote (borders) block content/specs', async () => {
const { data } = features[3];
expect(await quote.verifyQuote('quote (borders)', data)).toBeTruthy();
await expect(await quote.quoteImage).not.toBeVisible();
await expect(await quote.quoteCopy).toContainText(data.quoteCopy);
await expect(await quote.quoteFigCaption).toContainText(data.figCaption);
await expect(await quote.quoteFigCaptionCite).toContainText(data.cite);

expect(await webUtil.verifyAttributes_(await quote.quote, quote.attProperties['quote-borders'])).toBeTruthy();
expect(await webUtil.verifyCSS_(await quote.quote, quote.cssProperties.quote)).toBeTruthy();
});
});

// Test 4 : quote (align-right)
test(`${features[4].name},${features[4].tags}`, async ({ page, baseURL }) => {
console.info(`[Test Page]: ${baseURL}${features[4].path}`);
const { data } = features[4];

await test.step('step-1: Go to Quote (align-right) block test page', async () => {
await page.goto(`${baseURL}${features[4].path}`);
Expand All @@ -79,13 +114,20 @@ test.describe('Milo Quote Block test suite', () => {
});

await test.step('step-2: Verify Quote (align-right) block content/specs', async () => {
const { data } = features[4];
expect(await quote.verifyQuote('quote (align-right)', data)).toBeTruthy();
await expect(await quote.quoteImage).toBeVisible();
await expect(await quote.quoteCopy).toContainText(data.quoteCopy);
await expect(await quote.quoteFigCaption).toContainText(data.figCaption);
await expect(await quote.quoteFigCaptionCite).toContainText(data.cite);

expect(await webUtil.verifyAttributes_(await quote.quote, quote.attProperties['quote-align-right'])).toBeTruthy();
expect(await webUtil.verifyCSS_(await quote.quote, quote.cssProperties['quote-align-right'])).toBeTruthy();
});
});

// Test 5 : quote (xl-spaced)
test(`${features[5].name},${features[5].tags}`, async ({ page, baseURL }) => {
console.info(`[Test Page]: ${baseURL}${features[5].path}`);
const { data } = features[5];

await test.step('step-1: Go to Quote (xl-spaced) block test page', async () => {
await page.goto(`${baseURL}${features[5].path}`);
Expand All @@ -94,8 +136,15 @@ test.describe('Milo Quote Block test suite', () => {
});

await test.step('step-2: Verify Quote (xl-spaced) block content/specs', async () => {
const { data } = features[5];
expect(await quote.verifyQuote('quote (xl-spaced)', data)).toBeTruthy();
await expect(await quote.sectionDark).toBeVisible();
await expect(await quote.quoteImage).not.toBeVisible();
await expect(await quote.quoteCopy).toContainText(data.quoteCopy);
await expect(await quote.quoteFigCaption).toContainText(data.figCaption);
await expect(await quote.quoteFigCaptionCite).toContainText(data.cite);

expect(await webUtil.verifyAttributes_(await quote.sectionDark, quote.attProperties['section-dark'])).toBeTruthy();
expect(await webUtil.verifyAttributes_(await quote.quote, quote.attProperties['quote-xl-spacing'])).toBeTruthy();
expect(await webUtil.verifyCSS_(await quote.quote, quote.cssProperties.quote)).toBeTruthy();
});
});
});
});