|
1 | 1 | import { ITEMS_PER_PAGE, PAGES_AHEAD_TO_FETCH } from '../src/lib/consts'
|
2 | 2 | import { expect, test } from '@playwright/test'
|
3 | 3 |
|
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) |
5 | 6 | // Go to the home page
|
6 | 7 | await page.goto('http://localhost:3000')
|
7 | 8 |
|
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 | + }) |
12 | 41 | })
|
13 | 42 |
|
14 | 43 | test('Prompt input is visible and usable on mobile', async ({ page }) => {
|
|
0 commit comments