-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#225: Add nav item page object, update isOk() in pagePOs to also chec…
…k active nav item matches
- Loading branch information
Showing
9 changed files
with
111 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export interface PageDetails { | ||
route: string; | ||
title: string; | ||
iconAlt: string; | ||
iconImgName: string; | ||
} | ||
|
||
export const EXPECTED_DETAILS_BY_PAGE: Record<string, PageDetails> = { | ||
ANALYSIS: { | ||
route: '/analysis', | ||
title: '', | ||
iconAlt: 'Analysis', | ||
iconImgName: 'measure_icon.png' | ||
}, | ||
DESIGN_ALTERNATIVES: { | ||
route: '/design_alternatives', | ||
title: 'Design Alternatives', | ||
iconAlt: 'Design Alternatives', | ||
iconImgName: 'design_alts_icon.png' | ||
}, | ||
OUTPUTS: { | ||
route: '/outputs', | ||
title: 'Outputs', | ||
iconAlt: 'Outputs', | ||
iconImgName: 'outputs_icon.png' | ||
}, | ||
RUN: { | ||
route: '/run', | ||
title: 'Run', | ||
iconAlt: 'Run', | ||
iconImgName: 'run_icon.png' | ||
}, | ||
REPORTS: { | ||
route: '/reports', | ||
title: 'Reports', | ||
iconImgName: 'Reports', | ||
iconAlt: 'reports_icon.png' | ||
}, | ||
SERVER: { | ||
route: '/server', | ||
title: 'Server', | ||
iconAlt: 'Server', | ||
iconImgName: 'server_icon.png' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './expected-details-by-page'; | ||
export * from './ipc-main-handle.mocks'; | ||
export * from './projects.mocks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { expect, Locator } from '@playwright/test'; | ||
import { PageDetails } from '../mocks'; | ||
import { BasePageObject } from './base.po'; | ||
|
||
export class NavPageObject extends BasePageObject { | ||
get list(): Locator { | ||
return this.page.locator('ul.nav'); | ||
} | ||
|
||
get items(): Locator { | ||
return this.list.locator('li'); | ||
} | ||
|
||
get activeItem(): Locator { | ||
return this.list.locator('li.active'); | ||
} | ||
|
||
async getRouteFor(item: Locator) { | ||
const href = (await item.locator('a').getAttribute('href')) ?? ''; | ||
return href.startsWith('#') ? href.slice(1) : href; | ||
} | ||
|
||
async getIconAltFor(item: Locator) { | ||
const img = item.locator('a img'); | ||
return (await img.getAttribute('alt')) ?? ''; | ||
} | ||
|
||
async getIconImgNameFor(item: Locator) { | ||
const img = item.locator('a img'); | ||
const iconImgSrc = (await img.getAttribute('src')) ?? ''; | ||
return iconImgSrc.slice(iconImgSrc.lastIndexOf('/') + 1); | ||
} | ||
|
||
async isItemOk( | ||
item: Locator, | ||
expectedPageDetails: Omit<PageDetails, 'title'> | ||
) { | ||
expect(await this.getRouteFor(item)).toBe(expectedPageDetails.route); | ||
expect(await this.getIconAltFor(item)).toBe(expectedPageDetails.iconAlt); | ||
expect(await this.getIconImgNameFor(item)).toBe( | ||
expectedPageDetails.iconImgName | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { EXPECTED_DETAILS_BY_PAGE } from '../../mocks'; | ||
import { PagePageObject } from './page.po'; | ||
|
||
export class AnalysisPageObject extends PagePageObject { | ||
EXPECTED_ROUTE = '/analysis'; | ||
EXPECTED_TITLE = ''; | ||
EXPECTED_PAGE_DETAILS = EXPECTED_DETAILS_BY_PAGE.ANALYSIS; | ||
|
||
constructor(expectedTitle: string) { | ||
super(); | ||
this.EXPECTED_TITLE = expectedTitle; | ||
this.EXPECTED_PAGE_DETAILS = { | ||
...EXPECTED_DETAILS_BY_PAGE.ANALYSIS, | ||
title: expectedTitle | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters