Skip to content

Commit 9aa28a4

Browse files
authored
Augment main E2E test to verify prompt creation and open in ZDS (#194)
* Augment main E2E test to verify prompt creation and open in ZDS Towards #184. Extend the current primary E2E test to not just load the dashboard after logging in, but also to create a prompt, redirect to its page, wait for it to successfully generate, and open it in a Zoo Design Studio temporary workspace. * Fix up test to account for creating a new tab * Fix up test to pass more reliably, remove extra cond * fmt
1 parent ad11cdc commit 9aa28a4

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

tests/e2e.playwright.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
11
import { ITEMS_PER_PAGE, PAGES_AHEAD_TO_FETCH } from '../src/lib/consts'
22
import { expect, test } from '@playwright/test'
33

4-
test('Redirects to the dashboard from home when logged-in', async ({ page }) => {
4+
test('User can generate from prompt and open in Zoo Design Studio', async ({ page }) => {
5+
test.setTimeout(120_000)
56
// Go to the home page
67
await page.goto('http://localhost:3000')
78

8-
// Assert that we are now on the dashboard
9-
await page.waitForURL('**/dashboard', { waitUntil: 'domcontentloaded' })
10-
await expect(page.locator('h1')).toHaveText('Text-to-CAD')
11-
await expect(page.locator('textarea')).toBeFocused()
9+
// locators and constants
10+
const prompt = `A shepherd's hook bolt`
11+
const promptInput = page.locator('textarea')
12+
const submitButton = page.locator('button[type="submit"]')
13+
const downloadLink = page.getByRole('link', { name: 'download' })
14+
const openInDesignStudioLink = page.getByRole('link', { name: 'open in zoo design studio' })
15+
16+
await test.step('Setup', async () => {
17+
// Assert that we are now on the dashboard
18+
await page.waitForURL('**/dashboard', { waitUntil: 'networkidle' })
19+
await expect(page.locator('h1')).toHaveText('Text-to-CAD')
20+
await expect(promptInput).toBeFocused()
21+
})
22+
23+
await test.step('Submit prompt and view successful generation', async () => {
24+
await promptInput.fill(prompt)
25+
await submitButton.click()
26+
27+
await page.waitForURL('**/view/*')
28+
await expect(page.getByRole('heading', { name: prompt })).toBeVisible()
29+
30+
// Sometimes generation can take a while
31+
await expect(downloadLink).toBeEnabled({ timeout: 90_000 })
32+
})
33+
34+
await test.step('Open the result in Zoo Design Studio temporary workspace', async () => {
35+
const newTabPromise = page.waitForEvent('popup')
36+
await openInDesignStudioLink.click()
37+
const newTab = await newTabPromise
38+
await newTab.waitForURL('https://app.zoo.dev/?ask-open-desktop=true&create-file=true*')
39+
await newTab.getByRole('button', { name: 'continue to web' }).click()
40+
})
1241
})
1342

1443
test('Prompt input is visible and usable on mobile', async ({ page }) => {

0 commit comments

Comments
 (0)