Skip to content

Commit

Permalink
update collection test
Browse files Browse the repository at this point in the history
  • Loading branch information
dualcnhq committed Jun 12, 2024
1 parent 82cd023 commit 9a3b7eb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 40 deletions.
53 changes: 28 additions & 25 deletions tests/collection/collection-page.spec.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
import { test } from '../../tests/fixtures';

test(`Collections basic display - use collection page layout`, async ({
collectionPage,
}) => {
await test.step(`Check if collection thumbnail, summary and action bar appears`, async () => {
await collectionPage.validatePageHeaderElements();
});
// test(`Collections basic display - use collection page layout`, async ({
// collectionPage,
// }) => {
// await test.step(`Check if collection thumbnail, summary and action bar appears`, async () => {
// await collectionPage.validatePageHeaderElements();
// });

await test.step(`Check if Collection | About | Forum tabs are displayed`, async () => {
await collectionPage.validateCollectionPageTabs();
});
});
// await test.step(`Check if Collection | About | Forum tabs are displayed`, async () => {
// await collectionPage.validateCollectionPageTabs();
// });
// });

test(`Collections page - "More..." link to About tab appears below description`, async ({
page,
collectionPage,
}) => {
await test.step(`Go to "ytjdradio" collection page`, async () => {
await page.goto('/details/ytjdradio');
});
// test(`Collections page - "More..." link to About tab appears below description`, async ({
// page,
// collectionPage,
// }) => {
// await test.step(`Go to "ytjdradio" collection page`, async () => {
// await page.goto('/details/ytjdradio');
// });

await test.step(`Click the "More..." link and check if About page is displayed`, async () => {
await collectionPage.clickMoreBtnFromSummary();
await collectionPage.validateAboutTabPage();
});
});
// await test.step(`Click the "More..." link and check if About page is displayed`, async () => {
// await collectionPage.clickMoreBtnFromSummary();
// await collectionPage.validateAboutTabPage();
// });
// });

test(`Tab navigation`, async ({ collectionPage }) => {
await test.step(`Click "About" tab button and check if About page is displayed in "oldtimeradio" collection page`, async () => {
await collectionPage.clickCollectionTab('About');
await collectionPage.validateAboutTabPage();
await collectionPage.validateTabPage('About');
// await collectionPage.validateAboutTabPage();
});

await test.step(`Click "Forum" tab button and check if Forum page is displayed in "oldtimeradio" collection page`, async () => {
await collectionPage.clickCollectionTab('Forum');
await collectionPage.validateForumTabPage();
// await collectionPage.validateForumTabPage();
await collectionPage.validateTabPage('Forum');
});

await test.step(`Click "Collection" tab button and check if Collections page is displayed in "oldtimeradio" collection page`, async () => {
await collectionPage.clickCollectionTab('Collection');
await collectionPage.validateCollectionTabPage();
// await collectionPage.validateCollectionTabPage();
await collectionPage.validateTabPage('Collection');
});
});
44 changes: 29 additions & 15 deletions tests/page-objects/collection-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,34 @@ export class CollectionPage {
await expect(this.pageTabs.getByLabel('About')).toBeVisible();
}

async validateTabPage(tab: string) {
console.log('tab: ', tab)
await this.checkLocatorInnerHtml(this.pageTabs, 'loading-placeholder-row');

if(tab === 'About') {
await this.validateAboutTabPage();
} else if (tab === 'Collection') {
await this.validateCollectionTabPage();
} else if (tab === 'Forum') {
await this.validateForumTabPage();
}
}

async validateAboutTabPage() {
console.log('page: ', await this.pageTabs.innerHTML())
console.log('page: ', await this.pageTabs.locator('li').allInnerTexts())
await expect(
this.page.getByRole('heading', { name: 'Activity' }),
).toBeVisible();
// await expect(
// this.page.getByRole('button', { name: 'reviews.' }),
// ).toBeVisible();
// ytjdradio details page doesn't have forum posts, commenting this part for now
// await expect(this.page.getByRole('button', { name: 'forum posts.' })).toBeVisible();
// await expect(
// this.page.getByRole('heading', { name: 'Collection Info' }),
// ).toBeVisible();
// expect(await this.pageTabs.locator('li.tab.active').innerText()).toContain(
// 'About',
// );
await expect(
this.page.getByRole('heading', { name: 'Collection Info' }),
).toBeVisible();
expect(await this.pageTabs.locator('li.tab.active').innerText()).toContain(
'ABOUT',
);
}

async validateForumTabPage() {
console.log('page: ', await this.pageTabs.innerHTML())
console.log('page: ', await this.pageTabs.locator('li').allInnerTexts())
const forumContainer = this.page.locator('#forum-container');
const newPostButtonLocator = forumContainer.getByRole('link', {
name: 'New Post',
Expand All @@ -102,13 +108,21 @@ export class CollectionPage {
}

async validateCollectionTabPage() {
console.log('page: ', await this.pageTabs.innerHTML())
console.log('page: ', await this.pageTabs.locator('li').allInnerTexts())
expect(await this.pageTabs.locator('li.tab.active').innerText()).toContain(
'COLLECTION',
);
await expect(
this.page.locator('#collection-browser-container'),
).toBeVisible();
}

async checkLocatorInnerHtml(locator: Locator, elem: string) {
const innerHtmlContent = await locator.innerHTML();
console.log('elem: ', elem, 'innerHtmlContent: ', innerHtmlContent)
if (innerHtmlContent.includes(elem)) {
await this.checkLocatorInnerHtml(locator, elem); // Recursive call
} else {
return; // Exit the function when the condition is met
}
}
}

0 comments on commit 9a3b7eb

Please sign in to comment.