diff --git a/features/cc/accordion.spec.js b/features/cc/accordion.spec.js new file mode 100644 index 00000000..f1ab3159 --- /dev/null +++ b/features/cc/accordion.spec.js @@ -0,0 +1,30 @@ +module.exports = { + name: 'accordion', + features: [ + { + tcid: '0', + name: '@accordion-display', + path: '/drafts/Automation-PW/accordion-faqs?georouting=off', + tags: '@cc @cc-accordion @cc-accordionUI', + }, + { + tcid: '1', + name: '@accordion-questionexpand', + path: '/drafts/Automation-PW/accordion-faqs?georouting=off', + tags: '@cc @cc-accordion @cc-accordionexpandfeature', + }, + { + tcid: '2', + name: '@accordion-questioncollapse', + path: '/drafts/Automation-PW/accordion-faqs?georouting=off', + tags: '@cc @cc-accordion @cc-accordioncollapsefeature', + }, + { + tcid: '3', + name: '@accordion-innterlinks', + path: '/drafts/Automation-PW/accordion-faqs?georouting=off', + tags: '@cc @cc-accordion @cc-accordionlinkscheck', + url: 'https://www.adobe.com/creativecloud/plans.html', + }, + ], +}; diff --git a/selectors/cc/accordion.page.js b/selectors/cc/accordion.page.js new file mode 100644 index 00000000..0950b502 --- /dev/null +++ b/selectors/cc/accordion.page.js @@ -0,0 +1,15 @@ +export default class accordion { + constructor(page) { + this.page = page; + // Accordion UI elements in page + this.accordionSection = page.locator('.accordion-container.seo.static-links.con-block.max-width-10-desktop'); + this.accordionName = this.accordionSection.locator('#accordion-1'); + this.accordionQuestion1 = this.accordionName.locator('//dt[@role="heading"]').nth(0); + this.accordionDefinition1 = this.accordionName.locator('#accordion-1-trigger-1'); + this.accordionQuestion2 = this.accordionName.locator('//dt[@role="heading"]').nth(1); + this.accordionDefinition2 = this.accordionName.locator('#accordion-1-trigger-2'); + this.DefaultState = this.accordionName.locator('//button[@id="accordion-1-trigger-1" and @aria-expanded="false"]'); + this.accordexpanded = this.accordionName.locator('//button[@id="accordion-1-trigger-1" and @aria-expanded="true"]'); + this.firstQuestionLink = page.locator('//a[@daa-ll="Learn more about the-2--What is Adobe Creati"]'); + } +} diff --git a/tests/cc/accordion.test.js b/tests/cc/accordion.test.js new file mode 100644 index 00000000..e46c084b --- /dev/null +++ b/tests/cc/accordion.test.js @@ -0,0 +1,84 @@ +import { expect, test } from '@playwright/test'; +import { features } from '../../features/cc/accordion.spec.js'; +import Accordion from '../../selectors/cc/accordion.page.js'; + +let accordion; +test.describe('verify accordion showing up with authored question and answers with expand/collapse features', () => { + test.beforeEach(async ({ page }) => { + accordion = new Accordion(page); + }); + // Verify accordion showing up with authored question and answers and UI + test(`${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => { + console.info(`[Test Page]: ${baseURL}${features[0].path}`); + await test.step('accordion UI', async () => { + await page.goto(`${baseURL}${features[0].path}`); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(`${baseURL}${features[0].path}`); + }); + await test.step('accordion ui with expected elements', async () => { + await page.waitForLoadState(); + expect(await accordion.accordionSection).toBeTruthy(); + expect(await accordion.accordionName).toBeTruthy(); + expect(await accordion.accordionQuestion1).toBeTruthy(); + expect(await accordion.accordionDefinition1).toBeTruthy(); + expect(await accordion.accordionQuestion2).toBeTruthy(); + expect(await accordion.accordionDefinition2).toBeTruthy(); + expect(await accordion.DefaultState).toBeTruthy(); + }); + }); + // check the expand feature when click on first question + test(`${features[1].name},${features[1].tags}`, async ({ page, baseURL }) => { + console.info(`[Test Page]: ${baseURL}${features[1].path}`); + await test.step('accordion expand on first question click', async () => { + await page.goto(`${baseURL}${features[1].path}`); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(`${baseURL}${features[1].path}`); + }); + await test.step('accordion expand when first question clicked', async () => { + await page.waitForLoadState(); + expect(await accordion.accordionName).toBeTruthy(); + expect(await accordion.accordionQuestion1).toBeTruthy(); + expect(await accordion.accordionDefinition1).toBeTruthy(); + await accordion.accordionQuestion1.click(); + expect(await accordion.accordexpanded).toBeTruthy(); + }); + }); + // check the collapse feature when click on first question + test(`${features[2].name},${features[2].tags}`, async ({ page, baseURL }) => { + console.info(`[Test Page]: ${baseURL}${features[2].path}`); + await test.step('accordion collapse on first question click', async () => { + await page.goto(`${baseURL}${features[2].path}`); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(`${baseURL}${features[2].path}`); + }); + await test.step('accordion collapse when first question in expanded form', async () => { + await page.waitForLoadState(); + expect(await accordion.accordionName).toBeTruthy(); + expect(await accordion.accordionQuestion1).toBeTruthy(); + expect(await accordion.accordionDefinition1).toBeTruthy(); + await accordion.accordionQuestion1.click(); + expect(await accordion.accordexpanded).toBeTruthy(); + await accordion.accordionQuestion1.click(); + expect(await accordion.DefaultState).toBeTruthy(); + }); + }); + // check the links are functional in the question summary + test(`${features[3].name},${features[3].tags}`, async ({ page, baseURL }) => { + console.info(`[Test Page]: ${baseURL}${features[3].path}`); + const { url } = features[3]; + await test.step('links are functional in the question summary', async () => { + await page.goto(`${baseURL}${features[3].path}`); + await page.waitForLoadState('domcontentloaded'); + await expect(page).toHaveURL(`${baseURL}${features[3].path}`); + }); + await test.step('links are functional in the given answers', async () => { + await page.waitForLoadState(); + expect(await accordion.accordionQuestion1).toBeTruthy(); + expect(await accordion.accordionDefinition1).toBeTruthy(); + await accordion.accordionQuestion1.click(); + expect(await accordion.accordexpanded).toBeTruthy(); + await accordion.firstQuestionLink.click(); + await expect(page).toHaveURL(url); + }); + }); +});