Skip to content

Commit

Permalink
feat: update how we test model detail page (#310)
Browse files Browse the repository at this point in the history
Because

- We need to adapt model-backend long run operation

This commit

- update how we test model detail page
- Make sure we select the right model instance
  • Loading branch information
EiffelFly committed Dec 20, 2022
1 parent f795ce8 commit 04c83a1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
28 changes: 22 additions & 6 deletions integration-test/common/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//import { Nullable } from "@/types/general";
import { Page, expect, Locator } from "@playwright/test";
import { delay, expectToSelectReactSelectOption } from "../helper";

export const expectToDeleteModel = async (page: Page, modelId: string) => {
await page.goto(`/models/${modelId}`, { waitUntil: "networkidle" });
Expand Down Expand Up @@ -111,6 +112,7 @@ export type ExpectCorrectModelDetailsProps = {
modelId: string;
modelDescription: string;
modelInstanceTag: string;
modelInstanceTagOptionLocator: Locator;
modelState:
| "STATE_ONLINE"
| "STATE_OFFLINE"
Expand All @@ -125,10 +127,14 @@ export const expectCorrectModelDetails = async ({
modelId,
modelDescription,
modelInstanceTag,
modelInstanceTagOptionLocator,
modelState,
modelTask,
additionalRules,
}: ExpectCorrectModelDetailsProps) => {
// Mimic the behavior of long running operation
await delay(2000);

await page.goto(`/models/${modelId}`, { waitUntil: "networkidle" });

// Should have proper title
Expand All @@ -139,16 +145,26 @@ export const expectCorrectModelDetails = async ({
const modelDescriptionField = page.locator("#description");
await expect(modelDescriptionField).toHaveValue(modelDescription);

// Should have correct model instance tag
const modelInstanceTagOption = page.locator(
"data-testid=modelInstanceTag-selected-option"
);
await expect(modelInstanceTagOption).toHaveText(modelInstanceTag);

// Should display task fill classification
const modelTaskLabel = page.locator("data-testid=model-task-label");
await expect(modelTaskLabel).toHaveText(modelTask);

const modelInstanceTagOptionInput = page.locator(
"#react-select-modelInstanceTag-input"
);

// Should choose the right model instance
await expectToSelectReactSelectOption(
modelInstanceTagOptionInput,
modelInstanceTagOptionLocator
);

// Should have the target model instance tag
const selectedModelInstanceTag = page.locator(
"data-testid=modelInstanceTag-selected-option"
);
await expect(selectedModelInstanceTag).toHaveText(modelInstanceTag);

// Should display online and have correct toggle button state
const modelStateLabel = page.locator("data-testid=state-label");
const stateToggle = page.locator("#pipelineStateToggleButton");
Expand Down
3 changes: 3 additions & 0 deletions integration-test/model-artivc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ test.describe.serial("Artivc model", () => {
modelId,
modelDescription,
modelInstanceTag: "v1.0-cpu",
modelInstanceTagOptionLocator: page.locator(
"#react-select-modelInstanceTag-option-0"
),
modelState: "STATE_ONLINE",
modelTask: "CLASSIFICATION",
additionalRules: async () => {
Expand Down
7 changes: 5 additions & 2 deletions integration-test/model-github.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ test.describe.serial("GitHub model", () => {
page,
modelId,
modelDescription,
modelInstanceTag: "v1.0-gpu", // Because we don't have a way to indicate which instance just created.
modelState: "STATE_OFFLINE",
modelInstanceTag: "v1.0-cpu",
modelInstanceTagOptionLocator: page.locator(
"#react-select-modelInstanceTag-option-1"
),
modelState: "STATE_ONLINE",
modelTask: "CLASSIFICATION",
});
});
Expand Down
3 changes: 3 additions & 0 deletions integration-test/model-huggingface.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ test.describe.serial("Hugging face model", () => {
modelId,
modelDescription,
modelInstanceTag,
modelInstanceTagOptionLocator: page.locator(
"#react-select-modelInstanceTag-option-0"
),
modelState: "STATE_ONLINE",
modelTask: "CLASSIFICATION",
additionalRules: async () => {
Expand Down
3 changes: 3 additions & 0 deletions integration-test/model-local.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ test.describe.serial("Local model", () => {
modelId,
modelDescription,
modelInstanceTag,
modelInstanceTagOptionLocator: page.locator(
"#react-select-modelInstanceTag-option-0"
),
modelState: "STATE_ONLINE",
modelTask: "CLASSIFICATION",
});
Expand Down

0 comments on commit 04c83a1

Please sign in to comment.