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

New: added pagination test for partner news #17

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
34 changes: 25 additions & 9 deletions features/dx/news.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
},
{
tcid: '2',
name: '@desc-regression-news-page-pagination-sort',
name: '@desc-regression-news-page-load-more-sort',
path: '/solutionpartners/drafts/automation/regression/partner-news',
data: {
cardTitle: 'Automation regression news card SPP',
Expand All @@ -31,6 +31,22 @@ module.exports = {
},
{
tcid: '3',
name: '@desc-regression-news-page-pagination',
path: '/solutionpartners/drafts/automation/regression/partner-news-paginated',
tags: '@dx-news @regression @anonymous',
data: {
searchCards: 'Automation regression news card SPP',
firstPageResult: '1 - 3 of 8 results',
secondPageResult: '4 - 6 of 8 results',
thirdPageResult: '7 - 8 of 8 results',
numberOfCardsWithTitle: 8,
numberOfPublicCards: 9,
pageButtonNumber: 2,
totalPageCount: 3,
},
},
{
tcid: '4',
name: '@desc-regression-news-page-filters',
path: '/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression @anonymous',
Expand All @@ -55,7 +71,7 @@ module.exports = {
},
},
{
tcid: '4',
tcid: '5',
name: '@desc-regression-news-page-read-article',
path: '/solutionpartners/drafts/automation/regression/partner-news',
data: {
Expand All @@ -66,7 +82,7 @@ module.exports = {
tags: '@dx-news @regression @anonymous',
},
{
tcid: '5',
tcid: '6',
name: '@desc-news-page-edge-cases',
path: '/solutionpartners/drafts/automation/regression/partner-news',
data: {
Expand All @@ -82,7 +98,7 @@ module.exports = {
tags: '@dx-news @regression @anonymous',
},
{
tcid: '6',
tcid: '7',
name: '@login-news-page-platinum-user',
path: '/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression @anonymous',
Expand All @@ -99,7 +115,7 @@ module.exports = {
},
},
{
tcid: '7',
tcid: '8',
name: '@login-news-page-gold-user',
path: '/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression @anonymous',
Expand All @@ -115,7 +131,7 @@ module.exports = {
},
},
{
tcid: '8',
tcid: '9',
name: '@login-news-page-silver-user',
path: '/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression @anonymous',
Expand All @@ -131,7 +147,7 @@ module.exports = {
},
},
{
tcid: '9',
tcid: '10',
name: '@login-news-page-bronze-user',
path: '/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression @anonymous',
Expand All @@ -147,7 +163,7 @@ module.exports = {
},
},
{
tcid: '10',
tcid: '11',
name: '@login-news-page-community-user',
path: '/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression @anonymous',
Expand All @@ -163,7 +179,7 @@ module.exports = {
},
},
{
tcid: '11',
tcid: '12',
name: '@login-news-page-non-member-of-spp-user',
path: '/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression @anonymous',
Expand Down
8 changes: 8 additions & 0 deletions selectors/dx/news.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export default class NewsPage {
this.loadMore = page.locator('[aria-label="Load more"]');
this.firstCardDate = page.locator('.card-date').nth(0);
this.lastCardDate = page.locator('.card-date').nth(5);
this.paginationPrevButton = page.locator('button.pagination-prev-btn');
this.paginationNextButton = page.locator('button.pagination-next-btn');
this.pageNumButton = page.locator('button.page-btn');
this.pageCount = page.locator('.page-btn');

this.signInButton = page.locator('button[daa-ll="Sign In"].feds-signIn');
this.profileIconButton = page.locator('.feds-profile-button');
Expand All @@ -38,4 +42,8 @@ export default class NewsPage {
async clearFilter(filter, number) {
await this.page.locator(`[aria-label="${filter}"] + [aria-label="${number}"]`).click();
}

async clickPageNumButton(pageNum) {
await this.page.locator(`button[aria-label="Page ${pageNum}"]`).click();
}
}
102 changes: 67 additions & 35 deletions tests/dx/news.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ test.describe('Validate news block', () => {
}

test(`${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => {
const { data } = features[0];
const { data, path } = features[0];
await test.step('Go to News page', async () => {
console.log('url: ', baseURL + features[0].path);
await page.goto(`${baseURL}${features[0].path}`);
await page.goto(`${baseURL}${path}`);
await page.waitForResponse(chimeraApi);
const result = await newsPage.resultNumber.textContent();
await expect(parseInt(result.split(' ')[0], 10)).toBe(data.numberOfPublicCards);
Expand Down Expand Up @@ -83,9 +82,9 @@ test.describe('Validate news block', () => {
});

test(`${features[1].name},${features[1].tags}`, async ({ page, baseURL }) => {
const { data } = features[1];
const { data, path } = features[1];
await test.step('Go to News page', async () => {
await page.goto(`${baseURL}${features[1].path}`);
await page.goto(`${baseURL}${path}`);
await page.waitForResponse(chimeraApi);
await newsPage.firstCardDate.waitFor({ state: 'visible', timeout: 20000 });
const result = await newsPage.resultNumber.textContent();
Expand Down Expand Up @@ -118,9 +117,42 @@ test.describe('Validate news block', () => {
});

test(`${features[2].name},${features[2].tags}`, async ({ page, baseURL }) => {
const { data } = features[2];
const { data, path } = features[2];
await test.step('Go to News page', async () => {
await page.goto(`${baseURL}${features[2].path}`);
await page.goto(`${baseURL}${path}`);
await newsPage.firstCardDate.waitFor({ state: 'visible', timeout: 15000 });
const result = await newsPage.resultNumber.textContent();
await expect(parseInt(result.split(' ')[0], 10)).toBe(data.numberOfPublicCards);
await newsPage.searchField.fill(data.searchCards);
const filteredCards = await newsPage.resultNumber.textContent();
await expect(parseInt(filteredCards.split(' ')[0], 10)).toBe(data.numberOfCardsWithTitle);
});

await test.step('Verify pagination buttons', async () => {
let paginationText = await newsPage.paginationText.textContent();
await expect(paginationText.toLowerCase()).toBe(data.firstPageResult);
const paginationPrevButton = await newsPage.paginationPrevButton;
await expect(paginationPrevButton).toHaveClass(/disabled/);
const paginationNextButton = await newsPage.paginationNextButton;
await expect(paginationNextButton).not.toHaveClass(/disabled/);
await expect(await newsPage.pageCount.count()).toBe(data.totalPageCount);
await newsPage.clickPageNumButton(data.pageButtonNumber);
paginationText = await newsPage.paginationText.textContent();
await expect(paginationText.toLowerCase()).toBe(data.secondPageResult);
await expect(paginationPrevButton).not.toHaveClass(/disabled/);
await expect(paginationNextButton).not.toHaveClass(/disabled/);
await paginationNextButton.click();
paginationText = await newsPage.paginationText.textContent();
await expect(paginationText.toLowerCase()).toBe(data.thirdPageResult);
await expect(paginationPrevButton).not.toHaveClass(/disabled/);
await expect(paginationNextButton).toHaveClass(/disabled/);
});
});

test(`${features[3].name},${features[3].tags}`, async ({ page, baseURL }) => {
const { data, path } = features[3];
await test.step('Go to News page', async () => {
await page.goto(`${baseURL}${path}`);
await page.waitForResponse(chimeraApi);
await newsPage.firstCardDate.waitFor({ state: 'visible', timeout: 20000 });
const result = await newsPage.resultNumber.textContent();
Expand Down Expand Up @@ -174,10 +206,10 @@ test.describe('Validate news block', () => {
});
});

test(`${features[3].name},${features[3].tags}`, async ({ page, baseURL }) => {
const { data } = features[3];
test(`${features[4].name},${features[4].tags}`, async ({ page, baseURL }) => {
const { data, path } = features[4];
await test.step('Go to News page', async () => {
await page.goto(`${baseURL}${features[3].path}`);
await page.goto(`${baseURL}${path}`);
await page.waitForLoadState('domcontentloaded');
await newsPage.searchField.fill(data.cardTitle);
await newsPage.firstCardTitle.waitFor({ state: 'visible', timeout: 10000 });
Expand All @@ -193,10 +225,10 @@ test.describe('Validate news block', () => {
});
});

test(`${features[4].name},${features[4].tags}`, async ({ page, baseURL }) => {
const { data } = features[4];
test(`${features[5].name},${features[5].tags}`, async ({ page, baseURL }) => {
const { data, path } = features[5];
await test.step('Go to News page', async () => {
await page.goto(`${baseURL}${features[4].path}`);
await page.goto(`${baseURL}${path}`);
await page.waitForResponse(chimeraApi);
const result = await newsPage.resultNumber.textContent();
await expect(parseInt(result.split(' ')[0], 10)).toBe(data.numberOfPublicCards);
Expand Down Expand Up @@ -224,18 +256,18 @@ test.describe('Validate news block', () => {
});
});

test(`${features[5].name},${features[5].tags}`, async ({ page, context, baseURL }) => {
const { data } = features[5];
test(`${features[6].name},${features[6].tags}`, async ({ page, context, baseURL }) => {
const { data, path } = features[6];
await test.step('Click Sign In', async () => {
await page.goto(`${baseURL}${features[5].path}`);
await page.goto(`${baseURL}${path}`);
await page.waitForLoadState('domcontentloaded');
await page.waitForResponse(chimeraApi);
const result = await newsPage.resultNumber.textContent();
await expect(parseInt(result.split(' ')[0], 10)).toBe(data.numberOfPublicCards);
await newsPage.searchField.fill(data.platinumCard);
const resultPlatinum = await newsPage.resultNumber.textContent();
await expect(parseInt(resultPlatinum.split(' ')[0], 10)).toBe(data.noCards);
await signInPage.addCookie(data.partnerPortal, data.partnerLevel, baseURL + features[5].path, context);
await signInPage.addCookie(data.partnerPortal, data.partnerLevel, baseURL + path, context);

await page.reload();
await page.waitForLoadState('domcontentloaded');
Expand All @@ -258,60 +290,60 @@ test.describe('Validate news block', () => {
});
});

test(`${features[6].name},${features[6].tags}`, async ({ page, context, baseURL }) => {
const { data } = features[6];
test(`${features[7].name},${features[7].tags}`, async ({ page, context, baseURL }) => {
const { data, path } = features[7];
await findCardsForPartnerLevel(
page,
baseURL + features[6].path,
baseURL + path,
data,
context,
);
});

test(`${features[7].name},${features[7].tags}`, async ({ page, context, baseURL }) => {
const { data } = features[7];
test(`${features[8].name},${features[8].tags}`, async ({ page, context, baseURL }) => {
const { data, path } = features[8];
await findCardsForPartnerLevel(
page,
baseURL + features[7].path,
baseURL + path,
data,
context,
);
});

test(`${features[8].name},${features[8].tags}`, async ({ page, context, baseURL }) => {
const { data } = features[8];
test(`${features[9].name},${features[9].tags}`, async ({ page, context, baseURL }) => {
const { data, path } = features[9];
await findCardsForPartnerLevel(
page,
baseURL + features[8].path,
baseURL + path,
data,
context,
);
});

test(`${features[9].name},${features[9].tags}`, async ({ page, context, baseURL }) => {
const { data } = features[9];
test(`${features[10].name},${features[10].tags}`, async ({ page, context, baseURL }) => {
const { data, path } = features[10];
await test.step('Click Sign In', async () => {
await findCardsForPartnerLevel(
page,
baseURL + features[9].path,
baseURL + path,
data,
context,
);
});
});

test(`${features[10].name},${features[10].tags}`, async ({ page, context, baseURL }) => {
const { data } = features[10];
test(`${features[11].name},${features[11].tags}`, async ({ page, context, baseURL }) => {
const { data, path } = features[11];
await test.step('Go to stage.adobe.com', async () => {
await page.goto(`${baseURL}${features[10].path}`);
await signInPage.addCookie(data.partnerPortal, data.partnerLevel, baseURL + features[10].path, context);
await page.goto(`${baseURL}${path}`);
await signInPage.addCookie(data.partnerPortal, data.partnerLevel, baseURL + path, context);
await page.reload();
await page.waitForLoadState('domcontentloaded');
});

await test.step(`Open ${features[10].path} in a new tab`, async () => {
await test.step(`Open ${path} in a new tab`, async () => {
const newTab = await context.newPage();
await newTab.goto(`${features[10].path}`);
await newTab.goto(`${path}`);
const newTabPage = new NewsPage(newTab);
await newTab.waitForResponse(chimeraApi);
const resultCards = await newTabPage.resultNumber.textContent();
Expand Down
Loading