Get existing web text-to-cad playwright tests back to green (#3496)
* Get text-to-cad playwright tests back to green * fmt
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import { test, expect, Page } from '@playwright/test'
|
import { test, expect, Page } from '@playwright/test'
|
||||||
|
import * as fsp from 'fs/promises'
|
||||||
import { getUtils, setup, tearDown } from './test-utils'
|
import { getUtils, setup, setupElectron, tearDown } from './test-utils'
|
||||||
|
import { join } from 'path'
|
||||||
|
|
||||||
test.beforeEach(async ({ context, page }) => {
|
test.beforeEach(async ({ context, page }) => {
|
||||||
await setup(context, page)
|
await setup(context, page)
|
||||||
@ -12,13 +13,14 @@ test.afterEach(async ({ page }, testInfo) => {
|
|||||||
|
|
||||||
const CtrlKey = process.platform === 'darwin' ? 'Meta' : 'Control'
|
const CtrlKey = process.platform === 'darwin' ? 'Meta' : 'Control'
|
||||||
|
|
||||||
test.fixme('Text-to-CAD tests', () => {
|
test.describe('Text-to-CAD tests', () => {
|
||||||
test('basic lego happy case', async ({ page }) => {
|
test('basic lego happy case', async ({ page }) => {
|
||||||
const u = await getUtils(page)
|
const u = await getUtils(page)
|
||||||
|
|
||||||
await page.setViewportSize({ width: 1000, height: 500 })
|
await test.step('Set up', async () => {
|
||||||
|
await page.setViewportSize({ width: 1000, height: 500 })
|
||||||
await u.waitForAuthSkipAppStart()
|
await u.waitForAuthSkipAppStart()
|
||||||
|
})
|
||||||
|
|
||||||
await sendPromptFromCommandBar(page, 'a 2x4 lego')
|
await sendPromptFromCommandBar(page, 'a 2x4 lego')
|
||||||
|
|
||||||
@ -56,9 +58,7 @@ test.fixme('Text-to-CAD tests', () => {
|
|||||||
await page.locator('.cm-content').click()
|
await page.locator('.cm-content').click()
|
||||||
|
|
||||||
// Paste the code.
|
// Paste the code.
|
||||||
await page.keyboard.down(CtrlKey)
|
await page.keyboard.press('ControlOrMeta+KeyV')
|
||||||
await page.keyboard.press('KeyV')
|
|
||||||
await page.keyboard.up(CtrlKey)
|
|
||||||
|
|
||||||
// Expect the code to be pasted.
|
// Expect the code to be pasted.
|
||||||
await expect(page.locator('.cm-content')).toContainText(`const`)
|
await expect(page.locator('.cm-content')).toContainText(`const`)
|
||||||
@ -70,7 +70,12 @@ test.fixme('Text-to-CAD tests', () => {
|
|||||||
await u.closeDebugPanel()
|
await u.closeDebugPanel()
|
||||||
|
|
||||||
// Find the toast close button.
|
// Find the toast close button.
|
||||||
const closeButton = page.getByRole('button', { name: 'Close' })
|
const closeButton = page
|
||||||
|
.getByRole('status')
|
||||||
|
.locator('div')
|
||||||
|
.filter({ hasText: 'Text-to-CAD successfulPrompt' })
|
||||||
|
.first()
|
||||||
|
.getByRole('button', { name: 'Close' })
|
||||||
await expect(closeButton).toBeVisible()
|
await expect(closeButton).toBeVisible()
|
||||||
await closeButton.click()
|
await closeButton.click()
|
||||||
|
|
||||||
@ -194,9 +199,7 @@ test.fixme('Text-to-CAD tests', () => {
|
|||||||
await expect(prompt.first()).toBeVisible()
|
await expect(prompt.first()).toBeVisible()
|
||||||
|
|
||||||
// Type the prompt.
|
// Type the prompt.
|
||||||
await page.keyboard.type(
|
await page.keyboard.type('akjsndladf ghgsssswefiuwq22262664')
|
||||||
'akjsndladf lajbhflauweyfa;wieufjn;wieJNUF;.wjdfn weh Fwhefb'
|
|
||||||
)
|
|
||||||
await page.waitForTimeout(1000)
|
await page.waitForTimeout(1000)
|
||||||
await page.keyboard.press('Enter')
|
await page.keyboard.press('Enter')
|
||||||
|
|
||||||
@ -260,8 +263,7 @@ test.fixme('Text-to-CAD tests', () => {
|
|||||||
const prompt = page.getByText('Prompt')
|
const prompt = page.getByText('Prompt')
|
||||||
await expect(prompt.first()).toBeVisible()
|
await expect(prompt.first()).toBeVisible()
|
||||||
|
|
||||||
const badPrompt =
|
const badPrompt = 'akjsndladf lajbhflauweyfaaaljhr472iouafyvsssssss'
|
||||||
'akjsndladf lajbhflauweyfa;wieufjn;wieJNUF;.wjdfn weh Fwhefb'
|
|
||||||
|
|
||||||
// Type the prompt.
|
// Type the prompt.
|
||||||
await page.keyboard.type(badPrompt)
|
await page.keyboard.type(badPrompt)
|
||||||
@ -351,8 +353,7 @@ test.fixme('Text-to-CAD tests', () => {
|
|||||||
const prompt = page.getByText('Prompt')
|
const prompt = page.getByText('Prompt')
|
||||||
await expect(prompt.first()).toBeVisible()
|
await expect(prompt.first()).toBeVisible()
|
||||||
|
|
||||||
const badPrompt =
|
const badPrompt = 'akjsndladf lajbhflauweyfa;wieufjn---4;'
|
||||||
'akjsndladf lajbhflauweyfa;wieufjn;wieJNUF;.wjdfn weh Fwhefb'
|
|
||||||
|
|
||||||
// Type the prompt.
|
// Type the prompt.
|
||||||
await page.keyboard.type(badPrompt)
|
await page.keyboard.type(badPrompt)
|
||||||
@ -532,7 +533,12 @@ test.fixme('Text-to-CAD tests', () => {
|
|||||||
await expect(page.locator('.cm-content')).toContainText(`2x8`)
|
await expect(page.locator('.cm-content')).toContainText(`2x8`)
|
||||||
|
|
||||||
// Find the toast close button.
|
// Find the toast close button.
|
||||||
const closeButton = page.getByRole('button', { name: 'Close' })
|
const closeButton = page
|
||||||
|
.getByRole('status')
|
||||||
|
.locator('div')
|
||||||
|
.filter({ hasText: 'Text-to-CAD successfulPrompt' })
|
||||||
|
.first()
|
||||||
|
.getByRole('button', { name: 'Close' })
|
||||||
await expect(closeButton).toBeVisible()
|
await expect(closeButton).toBeVisible()
|
||||||
await closeButton.click()
|
await closeButton.click()
|
||||||
|
|
||||||
@ -578,10 +584,7 @@ test.fixme('Text-to-CAD tests', () => {
|
|||||||
|
|
||||||
await sendPromptFromCommandBar(page, 'a 2x4 lego')
|
await sendPromptFromCommandBar(page, 'a 2x4 lego')
|
||||||
|
|
||||||
await sendPromptFromCommandBar(
|
await sendPromptFromCommandBar(page, 'alkjsdnlajshdbfjlhsbdf a;askjdnf')
|
||||||
page,
|
|
||||||
'alkjsdnlajshdbfjlhsbdf a;skjdnf;askjdnf'
|
|
||||||
)
|
|
||||||
|
|
||||||
// Find the toast.
|
// Find the toast.
|
||||||
// Look out for the toast message
|
// Look out for the toast message
|
||||||
@ -647,7 +650,12 @@ test.fixme('Text-to-CAD tests', () => {
|
|||||||
await expect(page.locator('.cm-content')).toContainText(`2x4`)
|
await expect(page.locator('.cm-content')).toContainText(`2x4`)
|
||||||
|
|
||||||
// Find the toast close button.
|
// Find the toast close button.
|
||||||
const closeButton = page.getByRole('button', { name: 'Close' })
|
const closeButton = page
|
||||||
|
.getByRole('status')
|
||||||
|
.locator('div')
|
||||||
|
.filter({ hasText: 'Text-to-CAD successfulPrompt' })
|
||||||
|
.first()
|
||||||
|
.getByRole('button', { name: 'Close' })
|
||||||
await expect(closeButton).toBeVisible()
|
await expect(closeButton).toBeVisible()
|
||||||
await closeButton.click()
|
await closeButton.click()
|
||||||
|
|
||||||
@ -658,26 +666,28 @@ test.fixme('Text-to-CAD tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function sendPromptFromCommandBar(page: Page, promptStr: string) {
|
async function sendPromptFromCommandBar(page: Page, promptStr: string) {
|
||||||
const commandBarButton = page.getByRole('button', { name: 'Commands' })
|
await test.step(`Send prompt from command bar: ${promptStr}`, async () => {
|
||||||
await expect(commandBarButton).toBeVisible()
|
const commandBarButton = page.getByRole('button', { name: 'Commands' })
|
||||||
// Click the command bar button
|
await expect(commandBarButton).toBeVisible()
|
||||||
await commandBarButton.click()
|
// Click the command bar button
|
||||||
|
await commandBarButton.click()
|
||||||
|
|
||||||
// Wait for the command bar to appear
|
// Wait for the command bar to appear
|
||||||
const cmdSearchBar = page.getByPlaceholder('Search commands')
|
const cmdSearchBar = page.getByPlaceholder('Search commands')
|
||||||
await expect(cmdSearchBar).toBeVisible()
|
await expect(cmdSearchBar).toBeVisible()
|
||||||
|
|
||||||
const textToCadCommand = page.getByText('Use the Zoo Text-to-CAD API ')
|
const textToCadCommand = page.getByText('Use the Zoo Text-to-CAD API ')
|
||||||
await expect(textToCadCommand.first()).toBeVisible()
|
await expect(textToCadCommand.first()).toBeVisible()
|
||||||
// Click the Text-to-CAD command
|
// Click the Text-to-CAD command
|
||||||
await textToCadCommand.first().click()
|
await textToCadCommand.first().click()
|
||||||
|
|
||||||
// Enter the prompt.
|
// Enter the prompt.
|
||||||
const prompt = page.getByText('Prompt')
|
const prompt = page.getByText('Prompt')
|
||||||
await expect(prompt.first()).toBeVisible()
|
await expect(prompt.first()).toBeVisible()
|
||||||
|
|
||||||
// Type the prompt.
|
// Type the prompt.
|
||||||
await page.keyboard.type(promptStr)
|
await page.keyboard.type(promptStr)
|
||||||
await page.waitForTimeout(1000)
|
await page.waitForTimeout(1000)
|
||||||
await page.keyboard.press('Enter')
|
await page.keyboard.press('Enter')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user