-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix operator prompt hidden for executing, output, and error (#4445)
* fix operator prompt hidden for executing, output, and error * add e2e tests for operators prompt * operator drawer prompt tweaks * mv to asserter * lint --------- Co-authored-by: Benjamin Kane <[email protected]>
- Loading branch information
1 parent
8471d1f
commit d2ca5f7
Showing
10 changed files
with
328 additions
and
30 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
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,79 @@ | ||
import { Locator, Page, expect } from "src/oss/fixtures"; | ||
|
||
export class OperatorsPromptPom { | ||
readonly page: Page; | ||
readonly locator: Locator; | ||
readonly assert: OperatorsPromptAsserter; | ||
readonly selectionCount: Locator; | ||
readonly type: PromptType; | ||
|
||
constructor(page: Page, type: PromptType = "modal") { | ||
this.page = page; | ||
this.assert = new OperatorsPromptAsserter(this); | ||
this.locator = this.page.getByTestId(`operators-prompt-${type}`); | ||
this.type = type; | ||
} | ||
|
||
get content() { | ||
if (this.type === "drawer") { | ||
return this.locator.getByTestId("operators-prompt-drawer-content"); | ||
} | ||
return this.locator.locator(".MuiDialogContent-root").first(); | ||
} | ||
|
||
get footer() { | ||
if (this.type === "drawer") { | ||
return this.locator.getByTestId("operators-prompt-drawer-footer"); | ||
} | ||
return this.locator.locator(".MuiDialogActions-root").first(); | ||
} | ||
|
||
get executeButton() { | ||
return this.footer.locator('button:text("Execute")'); | ||
} | ||
|
||
async execute() { | ||
await this.assert.canExecute(); | ||
return this.executeButton.click(); | ||
} | ||
|
||
cancel() { | ||
return this.footer.locator('button:text("Cancel")').click(); | ||
} | ||
|
||
close() { | ||
return this.footer.locator('button:text("Close")').click(); | ||
} | ||
|
||
done() { | ||
return this.footer.locator('button:text("Done")').click(); | ||
} | ||
} | ||
|
||
class OperatorsPromptAsserter { | ||
constructor(private readonly panelPom: OperatorsPromptPom) {} | ||
|
||
async isOpen() { | ||
await expect(this.panelPom.locator).toBeVisible(); | ||
} | ||
async isClosed() { | ||
await expect(this.panelPom.locator).not.toBeVisible(); | ||
} | ||
async isExecuting() { | ||
await expect(this.panelPom.locator).toContainText("Executing..."); | ||
} | ||
async canExecute() { | ||
await expect(this.panelPom.executeButton).toBeEnabled(); | ||
} | ||
|
||
async isValidated() { | ||
await expect( | ||
this.panelPom.footer.locator(".MuiCircularProgress-root") | ||
).toBeHidden(); | ||
await expect( | ||
this.panelPom.footer.locator(".MuiCircularProgress-root") | ||
).toBeHidden(); | ||
} | ||
} | ||
|
||
type PromptType = "modal" | "drawer" | "view-modal"; |
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,138 @@ | ||
import { test as base, expect } from "src/oss/fixtures"; | ||
import { OperatorsBrowserPom } from "src/oss/poms/operators/operators-browser"; | ||
import { OperatorsPromptPom } from "src/oss/poms/operators/operators-prompt"; | ||
import { getUniqueDatasetNameWithPrefix } from "src/oss/utils"; | ||
|
||
const datasetName = getUniqueDatasetNameWithPrefix("operators-prompt"); | ||
const test = base.extend<{ | ||
operatorsBrowser: OperatorsBrowserPom; | ||
operatorsPrompt: OperatorsPromptPom; | ||
operatorsPromptViewModal: OperatorsPromptPom; | ||
operatorsPromptDrawer: OperatorsPromptPom; | ||
}>({ | ||
operatorsBrowser: async ({ page }, use) => { | ||
await use(new OperatorsBrowserPom(page)); | ||
}, | ||
operatorsPrompt: async ({ page }, use) => { | ||
await use(new OperatorsPromptPom(page)); | ||
}, | ||
operatorsPromptViewModal: async ({ page }, use) => { | ||
await use(new OperatorsPromptPom(page, "view-modal")); | ||
}, | ||
operatorsPromptDrawer: async ({ page }, use) => { | ||
await use(new OperatorsPromptPom(page, "drawer")); | ||
}, | ||
}); | ||
|
||
test.beforeAll(async ({ fiftyoneLoader }) => { | ||
await fiftyoneLoader.executePythonCode(` | ||
import fiftyone as fo | ||
dataset = fo.Dataset("${datasetName}") | ||
dataset.persistent = True | ||
samples = [] | ||
for i in range(0, 10): | ||
sample = fo.Sample( | ||
filepath=f"{i}.png", | ||
detections=fo.Detections(detections=[fo.Detection(label=f"label-{i}")]), | ||
classification=fo.Classification(label=f"label-{i}"), | ||
bool=i % 2 == 0, | ||
str=f"{i}", | ||
int=i % 2, | ||
float=i / 2, | ||
list_str=[f"{i}"], | ||
list_int=[i % 2], | ||
list_float=[i / 2], | ||
list_bool=[i % 2 == 0], | ||
) | ||
samples.append(sample) | ||
dataset.add_samples(samples)`); | ||
}); | ||
|
||
test.beforeEach(async ({ page, fiftyoneLoader }) => { | ||
await fiftyoneLoader.waitUntilGridVisible(page, datasetName); | ||
}); | ||
|
||
test("Prompt: Cancel modal", async ({ operatorsBrowser, operatorsPrompt }) => { | ||
await operatorsBrowser.show(); | ||
await operatorsBrowser.search("E2E"); | ||
await operatorsBrowser.choose("E2E: Say hello in modal"); | ||
await operatorsPrompt.locator.locator("input").first().fill("E2E"); | ||
await operatorsPrompt.assert.isOpen(); | ||
await operatorsPrompt.cancel(); | ||
await operatorsPrompt.assert.isClosed(); | ||
}); | ||
|
||
test("Prompt: Say hello in modal", async ({ | ||
operatorsBrowser, | ||
operatorsPrompt, | ||
}) => { | ||
await operatorsBrowser.show(); | ||
await operatorsBrowser.search("E2E"); | ||
await operatorsBrowser.choose("E2E: Say hello in modal"); | ||
await operatorsPrompt.assert.isOpen(); | ||
await operatorsPrompt.locator | ||
.locator("input") | ||
.first() | ||
.pressSequentially("E2E"); | ||
await operatorsPrompt.assert.isValidated(); | ||
await operatorsPrompt.execute(); | ||
await operatorsPrompt.assert.isExecuting(); | ||
await expect(operatorsPrompt.content).toContainText("Message:Hi E2E!"); | ||
await operatorsPrompt.close(); | ||
await operatorsPrompt.assert.isClosed(); | ||
}); | ||
|
||
test("Prompt: Cancel drawer", async ({ | ||
operatorsBrowser, | ||
operatorsPromptDrawer, | ||
}) => { | ||
await operatorsBrowser.show(); | ||
await operatorsBrowser.search("E2E"); | ||
await operatorsBrowser.choose("E2E: Say hello in drawer"); | ||
await operatorsPromptDrawer.locator.locator("input").first().fill("E2E"); | ||
await operatorsPromptDrawer.assert.isOpen(); | ||
await operatorsPromptDrawer.cancel(); | ||
await operatorsPromptDrawer.assert.isClosed(); | ||
}); | ||
|
||
test("Prompt: Say hello in drawer", async ({ | ||
operatorsBrowser, | ||
operatorsPromptDrawer, | ||
}) => { | ||
await operatorsBrowser.show(); | ||
await operatorsBrowser.search("E2E"); | ||
await operatorsBrowser.choose("E2E: Say hello in drawer"); | ||
await operatorsPromptDrawer.assert.isOpen(); | ||
await operatorsPromptDrawer.locator | ||
.locator("input") | ||
.first() | ||
.pressSequentially("E2E"); | ||
await operatorsPromptDrawer.assert.isValidated(); | ||
await operatorsPromptDrawer.execute(); | ||
await operatorsPromptDrawer.assert.isExecuting(); | ||
await expect(operatorsPromptDrawer.content).toContainText("Message:Hi E2E!"); | ||
await operatorsPromptDrawer.close(); | ||
await operatorsPromptDrawer.assert.isClosed(); | ||
}); | ||
|
||
test("Prompt: Progress", async ({ | ||
operatorsBrowser, | ||
operatorsPrompt, | ||
operatorsPromptViewModal, | ||
}) => { | ||
await operatorsBrowser.show(); | ||
await operatorsBrowser.search("E2E"); | ||
await operatorsBrowser.choose("E2E: Progress"); | ||
await operatorsPrompt.assert.isExecuting(); | ||
await expect(operatorsPromptViewModal.content).toContainText( | ||
"Loading 1 of 2" | ||
); | ||
await expect(operatorsPromptViewModal.content).toContainText( | ||
"Loading 2 of 2" | ||
); | ||
await operatorsPromptViewModal.done(); | ||
await operatorsPrompt.assert.isClosed(); | ||
await operatorsPromptViewModal.assert.isClosed(); | ||
}); |
Oops, something went wrong.