-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests) created tests for instance and profile panels WD-7370
Signed-off-by: Mason Hu <[email protected]>
- Loading branch information
Showing
4 changed files
with
167 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Page, expect } from "@playwright/test"; | ||
import { TIMEOUT } from "./constants"; | ||
|
||
export const openInstancePanel = async (page: Page, instance: string) => { | ||
await page.goto("/ui/"); | ||
const instanceRow = page.getByRole("row", { name: instance }).first(); | ||
await instanceRow.waitFor({ state: "visible" }); | ||
const cells = instanceRow.locator(":has-text('Container')"); | ||
await cells.click(); | ||
const instanceDetailPanel = page.locator("css=.detail-panel", { | ||
hasText: "instance summary", | ||
}); | ||
await expect(instanceDetailPanel).toBeVisible(TIMEOUT); | ||
}; | ||
|
||
export const closeInstancePanel = async (page: Page) => { | ||
const closeButton = page.locator("css=button[aria-label=Close]"); | ||
await closeButton.click(); | ||
const instanceDetailPanel = page.locator("css=.detail-panel", { | ||
hasText: "instance summary", | ||
}); | ||
await expect(instanceDetailPanel).toHaveCount(0, TIMEOUT); | ||
}; | ||
|
||
export const startInstanceFromPanel = async (page: Page, instance: string) => { | ||
const instanceDetailPanel = page.locator("css=.detail-panel", { | ||
hasText: "instance summary", | ||
}); | ||
const startButton = instanceDetailPanel.locator("css=button[title=Start]"); | ||
await startButton.click(); | ||
await page.waitForSelector(`text=Instance ${instance} started.`, TIMEOUT); | ||
}; | ||
|
||
export const stopInstanceFromPanel = async (page: Page, instance: string) => { | ||
const instanceDetailPanel = page.locator("css=.detail-panel", { | ||
hasText: "instance summary", | ||
}); | ||
const stopButton = instanceDetailPanel.locator("css=button[title=Stop]"); | ||
await stopButton.click(); | ||
const confirmModal = page.locator("css=.p-modal"); | ||
await confirmModal.waitFor({ state: "visible" }); | ||
const confirmStopButton = confirmModal.locator("css=button", { | ||
hasText: "Stop", | ||
}); | ||
await confirmStopButton.click(); | ||
await page.waitForSelector(`text=Instance ${instance} stopped.`, TIMEOUT); | ||
}; | ||
|
||
export const navigateToInstanceDetails = async ( | ||
page: Page, | ||
instance: string, | ||
) => { | ||
const instanceDetailPanel = page.locator("css=.detail-panel", { | ||
hasText: "instance summary", | ||
}); | ||
const detailLink = instanceDetailPanel.locator("css=a", { | ||
hasText: instance, | ||
}); | ||
await detailLink.click(); | ||
const instanceDetailTitle = page.locator("css=.instance-detail-title", { | ||
hasText: instance, | ||
}); | ||
await expect(instanceDetailTitle).toBeVisible(TIMEOUT); | ||
}; |
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,36 @@ | ||
import { Page, expect } from "@playwright/test"; | ||
import { TIMEOUT } from "./constants"; | ||
|
||
export const openProfileSummaryPanel = async (page: Page, profile: string) => { | ||
const profileRow = page.locator("css=tr[role=row]", { hasText: profile }); | ||
await profileRow.waitFor({ state: "visible" }); | ||
const cells = await profileRow.locator("css=td").all(); | ||
await cells[1].click(); | ||
const profileSummaryPanel = page.locator("css=.detail-panel", { | ||
hasText: "profile summary", | ||
}); | ||
await expect(profileSummaryPanel).toBeVisible(TIMEOUT); | ||
}; | ||
|
||
export const closeProfileSummaryPanel = async (page: Page) => { | ||
const closeButton = page.locator("css=button[aria-label=Close]"); | ||
await closeButton.click(); | ||
const profileSummaryPanel = page.locator("css=.detail-panel", { | ||
hasText: "profile summary", | ||
}); | ||
await expect(profileSummaryPanel).toHaveCount(0, TIMEOUT); | ||
}; | ||
|
||
export const navigateToProfileDetails = async (page: Page, profile: string) => { | ||
const profileSummaryPanel = page.locator("css=.detail-panel", { | ||
hasText: "profile summary", | ||
}); | ||
const detailLink = profileSummaryPanel.locator("css=a", { | ||
hasText: profile, | ||
}); | ||
await detailLink.click(); | ||
const profileDetailTitle = page.locator("css=.p-panel__title", { | ||
hasText: profile, | ||
}); | ||
await expect(profileDetailTitle).toBeVisible(TIMEOUT); | ||
}; |
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,40 @@ | ||
import { test } from "@playwright/test"; | ||
import { | ||
createInstance, | ||
deleteInstance, | ||
randomInstanceName, | ||
} from "./helpers/instances"; | ||
// eslint-disable-next-line prettier/prettier | ||
import { | ||
closeInstancePanel, | ||
navigateToInstanceDetails, | ||
openInstancePanel, | ||
startInstanceFromPanel, | ||
stopInstanceFromPanel, | ||
} from "./helpers/instancePanel"; | ||
|
||
test("instance panel open and close", async ({ page }) => { | ||
const instance = randomInstanceName(); | ||
await createInstance(page, instance); | ||
await openInstancePanel(page, instance); | ||
await closeInstancePanel(page); | ||
await deleteInstance(page, instance); | ||
}); | ||
|
||
test("start and stop instance from panel", async ({ page }) => { | ||
const instance = randomInstanceName(); | ||
await createInstance(page, instance); | ||
await openInstancePanel(page, instance); | ||
await startInstanceFromPanel(page, instance); | ||
await stopInstanceFromPanel(page, instance); | ||
await closeInstancePanel(page); | ||
await deleteInstance(page, instance); | ||
}); | ||
|
||
test("navigate to instance details from panel", async ({ page }) => { | ||
const instance = randomInstanceName(); | ||
await createInstance(page, instance); | ||
await openInstancePanel(page, instance); | ||
await navigateToInstanceDetails(page, instance); | ||
await deleteInstance(page, instance); | ||
}); |
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,27 @@ | ||
import { test } from "@playwright/test"; | ||
import { | ||
createProfile, | ||
deleteProfile, | ||
randomProfileName, | ||
} from "./helpers/profile"; | ||
import { | ||
openProfileSummaryPanel, | ||
closeProfileSummaryPanel, | ||
navigateToProfileDetails, | ||
} from "./helpers/profileSummaryPanel"; | ||
|
||
test("profile summary panel open and close", async ({ page }) => { | ||
const profile = randomProfileName(); | ||
await createProfile(page, profile); | ||
await openProfileSummaryPanel(page, profile); | ||
await closeProfileSummaryPanel(page); | ||
await deleteProfile(page, profile); | ||
}); | ||
|
||
test("navigate to profile detail from panel", async ({ page }) => { | ||
const profile = randomProfileName(); | ||
await createProfile(page, profile); | ||
await openProfileSummaryPanel(page, profile); | ||
await navigateToProfileDetails(page, profile); | ||
await deleteProfile(page, profile); | ||
}); |