Skip to content

Commit

Permalink
Fix create from AI e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-gordon committed Oct 2, 2023
1 parent 233ac90 commit 0040a14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
26 changes: 4 additions & 22 deletions app/e2e/pro.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,12 @@ test("Go to Sandbox. Save Sandbox Chart", async () => {
await expect(page).toHaveURL(new RegExp(`${BASE_URL}/u/\\d+`));
});

test("Create chart from prompt by instruction", async () => {
test("Create chart from ai", async () => {
await page.getByRole("link", { name: "New" }).click();
await page.getByRole("radio", { name: "AI Prompt" }).click();

await page.getByTestId("instruct").click();
await page.getByTestId("prompt-entry-textarea").click();
await page.getByTestId("Use AI").click();
await page.locator('textarea[name="subject"]').click();
await page
.getByTestId("prompt-entry-textarea")
.locator('textarea[name="subject"]')
.fill("the stages of the water cycle");
await page.getByRole("button", { name: "Create" }).click();
// expect url to be regex BASE_URL + /u/\d+
Expand All @@ -207,22 +205,6 @@ test("Create chart from prompt by instruction", async () => {
});
});

test("Create chart from prompt by extraction", async () => {
await page.getByRole("link", { name: "New" }).click();
await page.getByRole("radio", { name: "AI Prompt" }).click();

await page.getByTestId("extract").click();
await page.getByTestId("prompt-entry-textarea").click();
await page
.getByTestId("prompt-entry-textarea")
.fill("a is greater than b but less than a");
await page.getByRole("button", { name: "Create" }).click();
// expect url to be regex BASE_URL + /u/\d+
await expect(page).toHaveURL(new RegExp(`${BASE_URL}/u/\\d+`), {
timeout: 12000,
});
});

test("Create chart from imported data", async () => {
try {
await page.getByRole("link", { name: "New" }).click();
Expand Down
6 changes: 5 additions & 1 deletion app/src/pages/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ export default function New2() {
<Article size={16} />
<Trans>Use Default Content</Trans>
</Trigger>
<Trigger value="ai" disabled={createChartMutation.isLoading}>
<Trigger
value="ai"
disabled={createChartMutation.isLoading}
data-testid="Use AI"
>
<MagicWand size={16} />
<Trans>Use AI</Trans>
</Trigger>
Expand Down

0 comments on commit 0040a14

Please sign in to comment.