-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
189 additions
and
4 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,31 @@ | ||
import { FrameLocator, Page } from '@playwright/test'; | ||
import { strictEqual } from 'assert'; | ||
import { waitFor } from '../../waitFor'; | ||
|
||
export default class FindingDetailsWebview { | ||
constructor(protected readonly page: Page) {} | ||
|
||
private frameSelector = 'iframe.webview.ready'; | ||
private frame?: FrameLocator; | ||
private initializeErrorMsg = 'No frame found. Call initialize() first'; | ||
|
||
public async assertTitleRenders(expectedTitle: string): Promise<void> { | ||
if (!this.frame) throw Error(this.initializeErrorMsg); | ||
|
||
const title = this.frame.locator('[data-cy="title"]'); | ||
strictEqual(await title.count(), 1, 'Expected one title element'); | ||
strictEqual(await title.innerText(), expectedTitle); | ||
} | ||
|
||
public async initialize(expectedFrames: number): Promise<void> { | ||
const checkForIFrames = async () => { | ||
const iframes = await this.page.locator(this.frameSelector).count(); | ||
return iframes === expectedFrames; | ||
}; | ||
|
||
await waitFor('waiting for second iframe', checkForIFrames.bind(this)); | ||
const outerFrame = this.page.frameLocator(this.frameSelector).last(); | ||
await outerFrame.locator('iframe#active-frame').waitFor(); | ||
this.frame = outerFrame.frameLocator('#active-frame'); | ||
} | ||
} |
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,49 @@ | ||
import { FrameLocator, Page } from '@playwright/test'; | ||
import { strictEqual } from 'assert'; | ||
import { waitFor } from '../../waitFor'; | ||
|
||
export default class FindingsOverviewWebview { | ||
constructor(protected readonly page: Page) {} | ||
|
||
private title = 'Runtime Analysis'; | ||
private frameSelector = 'iframe.webview.ready'; | ||
private frame?: FrameLocator; | ||
private initializeErrorMsg = 'No frame found. Call initialize() first'; | ||
|
||
public async assertNumberOfFindingsInOverview(expected: number): Promise<void> { | ||
if (!this.frame) throw Error(this.initializeErrorMsg); | ||
|
||
const count = await this.frame.locator('[data-cy="finding"]').count(); | ||
strictEqual(count, expected, `Expected number of findings to be ${expected}`); | ||
} | ||
|
||
public async assertTitleRenders(): Promise<void> { | ||
if (!this.frame) throw Error(this.initializeErrorMsg); | ||
|
||
const title = this.frame.locator('[data-cy="title"]'); | ||
strictEqual(await title.count(), 1, 'Expected one title element'); | ||
strictEqual(await title.innerText(), this.title); | ||
} | ||
|
||
public async openFirstFindingDetail(): Promise<void> { | ||
if (!this.frame) throw Error(this.initializeErrorMsg); | ||
|
||
this.frame | ||
.locator('[data-cy="finding"]') | ||
.first() | ||
.locator('ul') | ||
.click(); | ||
} | ||
|
||
public async initialize(expectedFrames: number): Promise<void> { | ||
const checkForIFrames = async () => { | ||
const iframes = await this.page.locator(this.frameSelector).count(); | ||
return iframes === expectedFrames; | ||
}; | ||
|
||
await waitFor('waiting for second iframe', checkForIFrames.bind(this)); | ||
const outerFrame = this.page.frameLocator(this.frameSelector).last(); | ||
await outerFrame.locator('iframe#active-frame').waitFor(); | ||
this.frame = outerFrame.frameLocator('#active-frame'); | ||
} | ||
} |
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