Skip to content

Commit

Permalink
Updating dynamic nav tests to exclude status (#469)
Browse files Browse the repository at this point in the history
Co-authored-by: Dennis Li <[email protected]>
  • Loading branch information
Dli3 and Dennis Li authored Dec 14, 2024
1 parent 39c19f5 commit a3433c7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
3 changes: 2 additions & 1 deletion selectors/feds/feds.header.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default class FedsHeader {
this.headerContainer = page.locator('header.global-navigation');
this.mainNavLogo = page.locator('a.feds-brand, a.gnav-brand');
this.mainNavContainer = page.locator('nav.feds-topnav, .gnav-wrapper');
this.thirdNavItem = this.mainNavContainer.locator('.feds-nav > div:nth-child(3)');
this.fedsNav = this.mainNavContainer.locator('.feds-nav');
this.thirdNavItem = this.fedsNav.locator('div:nth-child(3)');
this.fedsCta = this.mainNavContainer.getByText('Get Started');
this.megaMenuToggle = page.locator('button.feds-navLink.feds-navLink--hoverCaret, .section-menu').first();
this.megaMenuContainer = page.locator('section.feds-navItem--megaMenu div.feds-popup, .section-menu .gnav-menu-container');
Expand Down
4 changes: 2 additions & 2 deletions tests/bacom/e2e/marketo.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ test.describe('Marketo block test suite', () => {
test(
`1: Marketo essential template, ${features[1].tags}, path: ${path}`,
async ({ page, baseURL }) => {
const params = miloLibs ? `?${miloLibs}&georouting=off` : '?georouting=off';
const params = miloLibs ? `${miloLibs}&georouting=off` : '?georouting=off';
const testPage = `${baseURL}${path}${params}`;
console.info(`[Test Page]: ${testPage}`);

await test.step('step-1: Go to the Marketo block full template test page', async () => {
await page.goto(testPage);
await page.waitForLoadState('domcontentloaded');
await expect(page).toHaveURL(testPage);
await expect(page.url()).toContain(path);

await marketoBlock.marketo.scrollIntoViewIfNeeded();
await expect(marketoBlock.email).toBeVisible({ timeout: 8000 });
Expand Down
30 changes: 12 additions & 18 deletions tests/bacom/features/dynamic-nav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,26 @@ test.describe('Dynamic Navigation Test Suite', () => {
await test.step('1. Navigate to on page and check the nav and breadcrumbs', async () => {
await page.goto(onPage);
await page.waitForLoadState('domcontentloaded');
await page.waitForSelector('button.feds-signIn', { state: 'visible' });
await expect(header.signInButton).toBeVisible();
await page.waitForSelector('nav.feds-breadcrumbs', { state: 'visible' });

await expect(async () => {
await expect(header.breadcrumbContainer).toBeVisible();
onNav = await header.mainNavContainer.innerText();
onNav = await header.fedsNav.innerText();
onNav = onNav.toLowerCase();
await expect(onNav.length).toBeGreaterThan(0);
await expect(onNav).toContain('sign in');
}).toPass();
});

await test.step('2. Navigate to a page with dynamic nav set to "entry"', async () => {
await page.goto(entryPage);
await page.waitForLoadState('domcontentloaded');
await page.waitForSelector('button.feds-signIn', { state: 'visible' });
await expect(header.signInButton).toBeVisible();

await expect(async () => {
entryNav = await header.mainNavContainer.innerText();
entryNav = await header.fedsNav.innerText();
entryNav = entryNav.toLowerCase();
await expect(entryNav.length).toBeGreaterThan(0);
await expect(entryNav).toContain('sign in');
}).toPass();
});

Expand All @@ -56,14 +54,13 @@ test.describe('Dynamic Navigation Test Suite', () => {
await test.step('4. Check that the expected nav displays and breadcrumbs do not', async () => {
await page.waitForURL(/.*\/on/);
await page.waitForLoadState('domcontentloaded');
await page.waitForSelector('button.feds-signIn', { state: 'visible' });
await expect(header.signInButton).toBeVisible();
await page.waitForSelector('nav.feds-breadcrumbs', { state: 'hidden' });

await expect(async () => {
onNavAfterEntry = await header.mainNavContainer.innerText();
onNavAfterEntry = await header.fedsNav.innerText();
onNavAfterEntry = onNavAfterEntry.toLowerCase();
await expect(onNavAfterEntry.length).toBeGreaterThan(0);
await expect(onNavAfterEntry).toContain('sign in');
await expect(entryNav).toBe(onNavAfterEntry);
await expect(onNavAfterEntry).not.toBe(onNav);
await expect(header.breadcrumbContainer).not.toBeVisible();
Expand All @@ -84,28 +81,26 @@ test.describe('Dynamic Navigation Test Suite', () => {
await test.step('1. Navigate to the off page and check the nav and breadcrumbs', async () => {
await page.goto(offPage);
await page.waitForLoadState('domcontentloaded');
await page.waitForSelector('button.feds-signIn', { state: 'visible' });
await expect(header.signInButton).toBeVisible();

await expect(async () => {
await expect(header.breadcrumbContainer).toBeVisible();
offNav = await header.mainNavContainer.innerText();
offNav = await header.fedsNav.innerText();
offNav = offNav.toLowerCase();
await expect(offNav.length).toBeGreaterThan(0);
await expect(offNav).toContain('sign in');
}).toPass();
});

await test.step('2. Navigate to a page with dynamic nav set to "entry"', async () => {
await page.goto(entryPage);
await page.waitForLoadState('domcontentloaded');
await page.waitForSelector('button.feds-signIn', { state: 'visible' });
await expect(header.signInButton).toBeVisible();
await page.waitForSelector('nav.feds-breadcrumbs', { state: 'visible' });

await expect(async () => {
entryNav = await header.mainNavContainer.innerText();
entryNav = await header.fedsNav.innerText();
entryNav = entryNav.toLowerCase();
await expect(entryNav.length).toBeGreaterThan(0);
await expect(entryNav).toContain('sign in');
}).toPass();
});

Expand All @@ -117,16 +112,15 @@ test.describe('Dynamic Navigation Test Suite', () => {
await test.step('4. Check that the expected nav and breadcrumb displays.', async () => {
await page.waitForURL(/.*\/off/);
await page.waitForLoadState('domcontentloaded');
await page.waitForSelector('button.feds-signIn', { state: 'visible' });
await expect(header.signInButton).toBeVisible();

// TODO: Uncomment the following line when the bug is fixed.
// await page.waitForSelector('nav.feds-breadcrumbs', { state: 'visible' });

await expect(async () => {
offNavAfterEntry = await header.mainNavContainer.innerText();
offNavAfterEntry = await header.fedsNav.innerText();
offNavAfterEntry = offNavAfterEntry.toLowerCase();
await expect(offNavAfterEntry.length).toBeGreaterThan(0);
await expect(offNavAfterEntry).toContain('sign in');
}).toPass();

await expect(offNavAfterEntry).toBe(offNav);
Expand Down

0 comments on commit a3433c7

Please sign in to comment.