Spaces:
Sleeping
Sleeping
wuyiqunLu commited on
feat: add playwright e2e test for chat page with new and old data structure (#99)
Browse filesYou can run npx playwright test --ui locally to check the test
<img width="1582" alt="image"
src="https://github.com/landing-ai/vision-agent-ui/assets/132986242/3f6d2db5-c2d4-4190-92e9-b152894788bc">
<img width="1264" alt="image"
src="https://github.com/landing-ai/vision-agent-ui/assets/132986242/2429efe1-56e0-4f3f-9694-599475097f83">
Files changed (11)
- .github/workflows/playwright.ymlAdded+34
- .gitignore+5-1
- app/page.tsx+2-18
- components/CodeResultDisplay.tsx+21-5
- components/chat/ChatMessage.tsx+40-6
- components/ui/Dialog.tsx+2-1
- lib/constants.ts+23-1
- package.json+6-4
- playwright.config.tsAdded+69
- pnpm-lock.yaml+83-45
- tests/e2e/index.spec.tsAdded+85
12345678910111213141516171819202122232425262728293031323334name: Playwright Testson: deployment_status:jobs: run-e2es: timeout-minutes: 5 runs-on: ubuntu-latest if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' steps: - uses: actions/checkout@v4 - name: Setup pnpm uses: pnpm/action-setup@v4 with: version: 9.1.1 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: 'pnpm' - name: Install dependencies run: pnpm i --frozen-lockfile - name: Install Playwright Browsers run: pnpm exec playwright install --with-deps - name: Run Playwright tests run: pnpm exec playwright test env: BASE_URL: ${{ github.event.deployment_status.environment_url }} VERCEL_AUTOMATION_BYPASS_SECRET: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }} - uses: actions/upload-artifact@v4 if: always() with: name: playwright-report path: playwright-report/ retention-days: 738 unmodified lines3940414238 unmodified lines# tstsconfig.tsbuildinfocertificates38 unmodified lines394041424344454638 unmodified lines# tstsconfig.tsbuildinfocertificates/test-results//playwright-report//blob-report//playwright/.cache/
1 unmodified line234567891011121314151617181920212223242526272829301 unmodified lineimport { useRouter } from 'next/navigation';import { useRef, useState } from 'react';import Composer, { ComposerRef } from '@/components/chat/Composer';import { dbPostCreateChat } from '@/lib/db/functions';import { nanoid } from '@/lib/utils';import Chip from '@/components/ui/Chip';import { IconArrowUpRight } from '@/components/ui/Icons';const EXAMPLES = [{title: 'Counting flowers in image',mediaUrl:'https://vision-agent-dev.s3.us-east-2.amazonaws.com/examples/flower.png',prompt:'Detect flowers in this image, draw boxes and output the image, also return total number of flowers',},{title: 'Detecting sharks in video',mediaUrl:'https://vision-agent-dev.s3.us-east-2.amazonaws.com/examples/shark3_short.mp4',prompt:'Can you detect any surfboards or sharks in the video, draw a green line between the shark and the nearest surfboard and add the distance between them in meters assuming 30 pixels is 1 meter. Make the line red if the shark is within 10 meters of a surfboard. Sample the video at 1 frames per second and save the output video as output.mp4.',},];export default function Page() {const router = useRouter();1 unmodified line2345678910111213141 unmodified lineimport { useRouter } from 'next/navigation';import { useRef } from 'react';import Composer, { ComposerRef } from '@/components/chat/Composer';import { dbPostCreateChat } from '@/lib/db/functions';import { nanoid } from '@/lib/utils';import Chip from '@/components/ui/Chip';import { IconArrowUpRight } from '@/components/ui/Icons';import { EXAMPLES } from '@/lib/constants';export default function Page() {const router = useRouter();
52 unmodified lines5354555657585960616263646545 unmodified lines1111121131141151161172 unmodified lines1201211221231241251269 unmodified lines13613713813914014114252 unmodified linesconst finalResult = results?.find(_ => _.is_main_result)?.text;return (<div className="rounded-lg overflow-hidden relative max-w-5xl"><CodeBlock language="python" value={code} /><div className="rounded-lg relative"><div className="absolute left-1/2 -translate-x-1/2 -top-4 z-10"><Dialog><DialogTrigger asChild><Button variant="ghost" size="icon" className="size-8"><IconTerminalWindow className="text-teal-500 size-4" /></Button></DialogTrigger>45 unmodified lines<p>image output</p><Dialog><DialogTrigger asChild><Button variant="outline" size="sm">View all</Button></DialogTrigger>2 unmodified lines<CarouselContent>{imageResults.map((png, index) => (<CarouselItem key={'png' + index}><Img src={png!} width={1200} alt="result-image" /></CarouselItem>))}</CarouselContent>9 unmodified lineskey={'png' + index}src={png!}width={200}alt="result-image"/>))}</div>52 unmodified lines53545556575859606162636465666768697071727345 unmodified lines1191201211221231241251261271281292 unmodified lines1321331341351361371381391401411429 unmodified lines15215315415515615715852 unmodified linesconst finalResult = results?.find(_ => _.is_main_result)?.text;return (<divclassName="rounded-lg overflow-hidden relative max-w-5xl"data-testid="code-result-display-container"><CodeBlock language="python" value={code} /><div className="rounded-lg relative"><div className="absolute left-1/2 -translate-x-1/2 -top-4 z-10"><Dialog><DialogTrigger asChild><Buttondata-testid="open-final-test-code-dialog-button"variant="ghost"size="icon"className="size-8"><IconTerminalWindow className="text-teal-500 size-4" /></Button></DialogTrigger>45 unmodified lines<p>image output</p><Dialog><DialogTrigger asChild><Buttonvariant="outline"size="sm"data-testid="view-all-result-images-button">View all</Button></DialogTrigger>2 unmodified lines<CarouselContent>{imageResults.map((png, index) => (<CarouselItem key={'png' + index}><Imgsrc={png!}width={1200}alt={`detail-result-image-${index}`}/></CarouselItem>))}</CarouselContent>9 unmodified lineskey={'png' + index}src={png!}width={200}alt={`result-image-${index}`}/>))}</div>
28 unmodified lines293031323334183 unmodified lines21821922022122222322422522622722822923023123223328 unmodified linesimport { Separator } from '../ui/Separator';import { cn } from '@/lib/utils';import toast from 'react-hot-toast';export interface ChatMessageProps {message: Message;183 unmodified lines? `(${Math.round(displayMs / 100) / 10}s)`: '';if (type === 'plans') return <p>Creating instructions {durationDisplay}</p>;if (type === 'tools') return <p>Retrieving tools {durationDisplay}</p>;if (type === 'code' && status === 'started')return <p>Generating code {durationDisplay}</p>;if (type === 'code' && status === 'running')return <p>Executing code {durationDisplay}</p>;if (type === 'code' && status === 'completed')return <p>Code execution success {durationDisplay}</p>;if (type === 'code' && status === 'failed')return <p>Code execution failure {durationDisplay}</p>;return null;};28 unmodified lines2930313233343536373839404142183 unmodified lines22622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626728 unmodified linesimport { Separator } from '../ui/Separator';import { cn } from '@/lib/utils';import toast from 'react-hot-toast';import {EXECUTE_CODE_FAILURE_TITLE,EXECUTE_CODE_SUCCESS_TITLE,EXECUTE_CODE_TITLE,GENERATE_CODE_TITLE,PLAN_TITLE,TOOLS_TITLE,} from '@/lib/constants';export interface ChatMessageProps {message: Message;183 unmodified lines? `(${Math.round(displayMs / 100) / 10}s)`: '';if (type === 'plans')return (<p>{PLAN_TITLE} {durationDisplay}</p>);if (type === 'tools')return (<p>{TOOLS_TITLE} {durationDisplay}</p>);if (type === 'code' && status === 'started')return (<p>{GENERATE_CODE_TITLE} {durationDisplay}</p>);if (type === 'code' && status === 'running')return (<p>{EXECUTE_CODE_TITLE} {durationDisplay}</p>);if (type === 'code' && status === 'completed')return (<p>{EXECUTE_CODE_SUCCESS_TITLE} {durationDisplay}</p>);if (type === 'code' && status === 'failed')return (<p>{EXECUTE_CODE_FAILURE_TITLE} {durationDisplay}</p>);return null;};
37 unmodified lines38394041424344454637 unmodified lines<DialogPrimitive.Contentref={ref}className={cn('fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg max-h-[1000px] overflow-auto -translate-x-1/2 -translate-y-1/2 gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',className,)}{...props}>{children}37 unmodified lines3839404142434445464737 unmodified lines<DialogPrimitive.Contentref={ref}className={cn('fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg overflow-auto -translate-x-1/2 -translate-y-1/2 gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',className,)}style={{ maxHeight: '100vh' }}{...props}>{children}
1export const CLEANED_SEPARATOR = '|CLEANED|';1234567891011121314151617181920212223export const EXAMPLES = [{title: 'Counting flowers in image',mediaUrl:'https://vision-agent-dev.s3.us-east-2.amazonaws.com/examples/flower.png',prompt:'Detect flowers in this image, draw boxes and output the image, also return total number of flowers',},{title: 'Detecting sharks in video',mediaUrl:'https://vision-agent-dev.s3.us-east-2.amazonaws.com/examples/shark3_short.mp4',prompt:'Can you detect any surfboards or sharks in the video, draw a green line between the shark and the nearest surfboard and add the distance between them in meters assuming 30 pixels is 1 meter. Make the line red if the shark is within 10 meters of a surfboard. Sample the video at 1 frames per second and save the output video as output.mp4.',},];export const PLAN_TITLE = 'Creating instructions';export const TOOLS_TITLE = 'Retrieving tools';export const GENERATE_CODE_TITLE = 'Generating code';export const EXECUTE_CODE_TITLE = 'Executing code';export const EXECUTE_CODE_SUCCESS_TITLE = 'Code execution success';export const EXECUTE_CODE_FAILURE_TITLE = 'Code execution failure';
10 unmodified lines1112131415161747 unmodified lines6566676869709 unmodified lines8081828384858687888910 unmodified lines"preview": "next build && next start","type-check": "tsc --noEmit","format:write": "prettier --write \"{app,lib,components}/**/*.{ts,tsx,mdx}\" --cache","format:check": "prettier --check \"{app,lib,components}**/*.{ts,tsx,mdx}\" --cache"},"dependencies": {"@aws-sdk/client-s3": "^3.556.0",47 unmodified lines"uuid": "^9.0.1"},"devDependencies": {"@tailwindcss/typography": "^0.5.10","@types/node": "^20.11.5","@types/react": "^18.2.48",9 unmodified lines"eslint-plugin-tailwindcss": "^3.14.0","postcss": "^8.4.33","prettier": "^3.2.4","tailwind-merge": "^2.2.2","tailwindcss": "^3.4.1","tailwindcss-animate": "^1.0.7","typescript": "^5.3.3"},"packageManager": "pnpm@9.1.1"}10 unmodified lines111213141516171847 unmodified lines666768697071729 unmodified lines8283848586878889909110 unmodified lines"preview": "next build && next start","type-check": "tsc --noEmit","format:write": "prettier --write \"{app,lib,components}/**/*.{ts,tsx,mdx}\" --cache","format:check": "prettier --check \"{app,lib,components}**/*.{ts,tsx,mdx}\" --cache","test:e2e": "playwright test"},"dependencies": {"@aws-sdk/client-s3": "^3.556.0",47 unmodified lines"uuid": "^9.0.1"},"devDependencies": {"@playwright/test": "^1.44.1","@tailwindcss/typography": "^0.5.10","@types/node": "^20.11.5","@types/react": "^18.2.48",9 unmodified lines"eslint-plugin-tailwindcss": "^3.14.0","postcss": "^8.4.33","prettier": "^3.2.4","tailwind-merge": "^2.3.0","tailwindcss": "^3.4.4","tailwindcss-animate": "^1.0.7","typescript": "^5.3.3"},"packageManager": "pnpm@9.1.1"}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869import { defineConfig, devices } from '@playwright/test';
/** * Read environment variables from file. * https://github.com/motdotla/dotenv */// require('dotenv').config();
const BASE_URL = process.env.BASE_URL || `http://localhost:3000`;
/** * See https://playwright.dev/docs/test-configuration. */export default defineConfig({ testDir: './tests/e2e', /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI, /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ baseURL: BASE_URL,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', },
/* Configure projects for major browsers */ projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, },
/* Test against mobile viewports. */ // { // name: 'Mobile Chrome', // use: { ...devices['Pixel 5'] }, // }, // { // name: 'Mobile Safari', // use: { ...devices['iPhone 12'] }, // },
/* Test against branded browsers. */ // { // name: 'Microsoft Edge', // use: { ...devices['Desktop Edge'], channel: 'msedge' }, // }, { name: 'Google Chrome', use: { ...devices['Desktop Chrome'], channel: 'chrome' }, }, ],
/* Run your local dev server before starting the tests */ webServer: { command: 'pnpm dev', url: BASE_URL, reuseExistingServer: true, },});155 unmodified lines15615715815916016116216316429 unmodified lines1941951961971981992001 unmodified line202203204205206207208209210211212213214215226 unmodified lines4424434444454464474484494504514524534544554564571 unmodified line459460461462463464465466263 unmodified lines7307317327337347351473 unmodified lines220922102211221222132214893 unmodified lines310831093110311131123113328 unmodified lines34423443344434453446344734483449345034513452345334543455165 unmodified lines3621362236233624362536263627362836293630363136323633363436353636923 unmodified lines4560456145624563456445654566456745684569457045714572457345744575457645774578457945804581212 unmodified lines479447954796479747984799736 unmodified lines5536553755385539554055415542554355445545554655475548134 unmodified lines56835684568556865687568856896 unmodified lines5696569756985699570057015702723 unmodified lines64266427642864296430643164326433643464356436178 unmodified lines6615661666176618661966201096 unmodified lines771777187719772077217722361 unmodified lines8084808580868087808880898090809180928093809461 unmodified lines81568157815881598160816181628163142 unmodified lines830683078308830983108311831283138314831583168317831883198320155 unmodified linesspecifier: ^9.0.1version: 9.0.1devDependencies:'@tailwindcss/typography':specifier: ^0.5.10version: 0.5.12(tailwindcss@3.4.3)'@types/node':specifier: ^20.11.5version: 20.12.729 unmodified linesversion: 9.1.0(eslint@8.57.0)eslint-plugin-tailwindcss:specifier: ^3.14.0version: 3.15.1(tailwindcss@3.4.3)postcss:specifier: ^8.4.33version: 8.4.381 unmodified linespecifier: ^3.2.4version: 3.2.5tailwind-merge:specifier: ^2.2.2version: 2.2.2tailwindcss:specifier: ^3.4.1version: 3.4.3tailwindcss-animate:specifier: ^1.0.7version: 1.0.7(tailwindcss@3.4.3)typescript:specifier: ^5.3.3version: 5.4.5226 unmodified linesresolution: {integrity: sha512-VXAq/Jz8KIrU84+HqsOJhIKZqG0PNTdi6n6PFQ4xJf44ZQHD/5C7ouH4qCFX5XgZXcgbRIcMVVYGC6Jye0dRng==}engines: {node: '>=14.0.0'}'@babel/helper-string-parser@7.24.1':resolution: {integrity: sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ==}engines: {node: '>=6.9.0'}'@babel/helper-validator-identifier@7.22.20':resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==}engines: {node: '>=6.9.0'}'@babel/parser@7.24.4':resolution: {integrity: sha512-zTvEBcghmeBma9QIGunWevvBAp4/Qu9Bdq+2k0Ot4fVMD6v3dsC9WOcRSKk7tRRyBM/53yKMJko9xOatGQAwSg==}engines: {node: '>=6.0.0'}hasBin: true1 unmodified lineresolution: {integrity: sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==}engines: {node: '>=6.9.0'}'@babel/types@7.24.0':resolution: {integrity: sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==}engines: {node: '>=6.9.0'}'@emnapi/runtime@1.1.1':263 unmodified linesresolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}engines: {node: '>=14'}'@prisma/client@5.14.0':resolution: {integrity: sha512-akMSuyvLKeoU4LeyBAUdThP/uhVP3GuLygFE3MlYzaCb3/J8SfsYBE5PkaFuLuVpLyA6sFoW+16z/aPhNAESqg==}engines: {node: '>=16.13'}1473 unmodified linesfs.realpath@1.0.0:resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}fsevents@2.3.3:resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}893 unmodified linesresolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==}engines: {node: '>= 6'}possible-typed-array-names@1.0.0:resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==}engines: {node: '>= 0.4'}328 unmodified linesengines: {node: '>=10'}hasBin: trueseroval-plugins@1.0.5:resolution: {integrity: sha512-8+pDC1vOedPXjKG7oz8o+iiHrtF2WswaMQJ7CKFpccvSYfrzmvKY9zOJWCg+881722wIHfwkdnRmiiDm9ym+zQ==}engines: {node: '>=10'}peerDependencies:seroval: ^1.0seroval@1.0.5:resolution: {integrity: sha512-TM+Z11tHHvQVQKeNlOUonOWnsNM+2IBwZ4vwoi4j3zKzIpc5IDw8WPwCfcc8F17wy6cBcJGbZbFOR0UCuTZHQA==}engines: {node: '>=10'}set-function-length@1.2.2:165 unmodified linestabbable@6.2.0:resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==}tailwind-merge@2.2.2:resolution: {integrity: sha512-tWANXsnmJzgw6mQ07nE3aCDkCK4QdT3ThPMCzawoYA2Pws7vSTCvz3Vrjg61jVUGfFZPJzxEP+NimbcW+EdaDw==}tailwindcss-animate@1.0.7:resolution: {integrity: sha512-bl6mpH3T7I3UFxuvDEXLxy/VuFxBk5bbzplh7tXI68mwMokNYd1t9qPBHlnyTwfa4JGC4zP516I1hYYtQ/vspA==}peerDependencies:tailwindcss: '>=3.0.0 || insiders'tailwindcss@3.4.3:resolution: {integrity: sha512-U7sxQk/n397Bmx4JHbJx/iSOOv5G+II3f1kpLpY2QeUv5DcPdcTsYLlusZfq1NthHS1c1cZoyFmmkex1rzke0A==}engines: {node: '>=14.0.0'}hasBin: true923 unmodified lines'@smithy/types': 2.12.0tslib: 2.6.2'@babel/helper-string-parser@7.24.1': {}'@babel/helper-validator-identifier@7.22.20': {}'@babel/parser@7.24.4':dependencies:'@babel/types': 7.24.0'@babel/runtime@7.24.4':dependencies:regenerator-runtime: 0.14.1'@babel/types@7.24.0':dependencies:'@babel/helper-string-parser': 7.24.1'@babel/helper-validator-identifier': 7.22.20to-fast-properties: 2.0.0'@emnapi/runtime@1.1.1':212 unmodified lines'@pkgjs/parseargs@0.11.0':optional: true'@prisma/client@5.14.0(prisma@5.14.0)':optionalDependencies:prisma: 5.14.0736 unmodified linesdependencies:defer-to-connect: 2.0.1'@tailwindcss/typography@0.5.12(tailwindcss@3.4.3)':dependencies:lodash.castarray: 4.4.0lodash.isplainobject: 4.0.6lodash.merge: 4.6.2postcss-selector-parser: 6.0.10tailwindcss: 3.4.3'@types/cacheable-request@6.0.3':dependencies:134 unmodified lines'@vue/compiler-core@3.4.23':dependencies:'@babel/parser': 7.24.4'@vue/shared': 3.4.23entities: 4.5.0estree-walker: 2.0.26 unmodified lines'@vue/compiler-sfc@3.4.23':dependencies:'@babel/parser': 7.24.4'@vue/compiler-core': 3.4.23'@vue/compiler-dom': 3.4.23'@vue/compiler-ssr': 3.4.23723 unmodified linessemver: 6.3.1string.prototype.matchall: 4.0.11eslint-plugin-tailwindcss@3.15.1(tailwindcss@3.4.3):dependencies:fast-glob: 3.3.2postcss: 8.4.38tailwindcss: 3.4.3eslint-scope@7.2.2:dependencies:178 unmodified linesfs.realpath@1.0.0: {}fsevents@2.3.3:optional: true1096 unmodified linespirates@4.0.6: {}possible-typed-array-names@1.0.0: {}postcss-import@15.1.0(postcss@8.4.38):361 unmodified linesdependencies:lru-cache: 6.0.0seroval-plugins@1.0.5(seroval@1.0.5):dependencies:seroval: 1.0.5seroval@1.0.5: {}set-function-length@1.2.2:dependencies:61 unmodified linessolid-js@1.8.16:dependencies:csstype: 3.1.3seroval: 1.0.5seroval-plugins: 1.0.5(seroval@1.0.5)solid-swr-store@0.10.7(solid-js@1.8.16)(swr-store@0.10.6):dependencies:142 unmodified linestabbable@6.2.0: {}tailwind-merge@2.2.2:dependencies:'@babel/runtime': 7.24.4tailwindcss-animate@1.0.7(tailwindcss@3.4.3):dependencies:tailwindcss: 3.4.3tailwindcss@3.4.3:dependencies:'@alloc/quick-lru': 5.2.0arg: 5.0.2155 unmodified lines15615715815916016116216316416516616729 unmodified lines1971981992002012022031 unmodified line205206207208209210211212213214215216217218226 unmodified lines4454464474484494504514524534544554564574584594601 unmodified line462463464465466467468469263 unmodified lines7337347357367377387397407417427431473 unmodified lines22172218221922202221222222232224222522262227893 unmodified lines3121312231233124312531263127312831293130313131323133313431353136328 unmodified lines34653466346734683469347034713472347334743475347634773478165 unmodified lines3644364536463647364836493650365136523653365436553656365736583659923 unmodified lines4583458445854586458745884589459045914592459345944595459645974598459946004601460246034604212 unmodified lines4817481848194820482148224823482448254826736 unmodified lines5563556455655566556755685569557055715572557355745575134 unmodified lines57105711571257135714571557166 unmodified lines5723572457255726572757285729723 unmodified lines64536454645564566457645864596460646164626463178 unmodified lines6642664366446645664666476648664966501096 unmodified lines77477748774977507751775277537754775577567757775877597760361 unmodified lines8122812381248125812681278128812981308131813261 unmodified lines81948195819681978198819982008201142 unmodified lines834483458346834783488349835083518352835383548355835683578358155 unmodified linesspecifier: ^9.0.1version: 9.0.1devDependencies:'@playwright/test':specifier: ^1.44.1version: 1.44.1'@tailwindcss/typography':specifier: ^0.5.10version: 0.5.12(tailwindcss@3.4.4)'@types/node':specifier: ^20.11.5version: 20.12.729 unmodified linesversion: 9.1.0(eslint@8.57.0)eslint-plugin-tailwindcss:specifier: ^3.14.0version: 3.15.1(tailwindcss@3.4.4)postcss:specifier: ^8.4.33version: 8.4.381 unmodified linespecifier: ^3.2.4version: 3.2.5tailwind-merge:specifier: ^2.3.0version: 2.3.0tailwindcss:specifier: ^3.4.4version: 3.4.4tailwindcss-animate:specifier: ^1.0.7version: 1.0.7(tailwindcss@3.4.4)typescript:specifier: ^5.3.3version: 5.4.5226 unmodified linesresolution: {integrity: sha512-VXAq/Jz8KIrU84+HqsOJhIKZqG0PNTdi6n6PFQ4xJf44ZQHD/5C7ouH4qCFX5XgZXcgbRIcMVVYGC6Jye0dRng==}engines: {node: '>=14.0.0'}'@babel/helper-string-parser@7.24.7':resolution: {integrity: sha512-7MbVt6xrwFQbunH2DNQsAP5sTGxfqQtErvBIvIMi6EQnbgUOuVYanvREcmFrOPhoXBrTtjhhP+lW+o5UfK+tDg==}engines: {node: '>=6.9.0'}'@babel/helper-validator-identifier@7.24.7':resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==}engines: {node: '>=6.9.0'}'@babel/parser@7.24.7':resolution: {integrity: sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw==}engines: {node: '>=6.0.0'}hasBin: true1 unmodified lineresolution: {integrity: sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==}engines: {node: '>=6.9.0'}'@babel/types@7.24.7':resolution: {integrity: sha512-XEFXSlxiG5td2EJRe8vOmRbaXVgfcBlszKujvVmWIK/UpywWljQCfzAv3RQCGujWQ1RD4YYWEAqDXfuJiy8f5Q==}engines: {node: '>=6.9.0'}'@emnapi/runtime@1.1.1':263 unmodified linesresolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}engines: {node: '>=14'}'@playwright/test@1.44.1':resolution: {integrity: sha512-1hZ4TNvD5z9VuhNJ/walIjvMVvYkZKf71axoF/uiAqpntQJXpG64dlXhoDXE3OczPuTuvjf/M5KWFg5VAVUS3Q==}engines: {node: '>=16'}hasBin: true'@prisma/client@5.14.0':resolution: {integrity: sha512-akMSuyvLKeoU4LeyBAUdThP/uhVP3GuLygFE3MlYzaCb3/J8SfsYBE5PkaFuLuVpLyA6sFoW+16z/aPhNAESqg==}engines: {node: '>=16.13'}1473 unmodified linesfs.realpath@1.0.0:resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}fsevents@2.3.2:resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}os: [darwin]fsevents@2.3.3:resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}893 unmodified linesresolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==}engines: {node: '>= 6'}playwright-core@1.44.1:resolution: {integrity: sha512-wh0JWtYTrhv1+OSsLPgFzGzt67Y7BE/ZS3jEqgGBlp2ppp1ZDj8c+9IARNW4dwf1poq5MgHreEM2KV/GuR4cFA==}engines: {node: '>=16'}hasBin: trueplaywright@1.44.1:resolution: {integrity: sha512-qr/0UJ5CFAtloI3avF95Y0L1xQo6r3LQArLIg/z/PoGJ6xa+EwzrwO5lpNr/09STxdHuUoP2mvuELJS+hLdtgg==}engines: {node: '>=16'}hasBin: truepossible-typed-array-names@1.0.0:resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==}engines: {node: '>= 0.4'}328 unmodified linesengines: {node: '>=10'}hasBin: trueseroval-plugins@1.0.7:resolution: {integrity: sha512-GO7TkWvodGp6buMEX9p7tNyIkbwlyuAWbI6G9Ec5bhcm7mQdu3JOK1IXbEUwb3FVzSc363GraG/wLW23NSavIw==}engines: {node: '>=10'}peerDependencies:seroval: ^1.0seroval@1.0.7:resolution: {integrity: sha512-n6ZMQX5q0Vn19Zq7CIKNIo7E75gPkGCFUEqDpa8jgwpYr/vScjqnQ6H09t1uIiZ0ZSK0ypEGvrYK2bhBGWsGdw==}engines: {node: '>=10'}set-function-length@1.2.2:165 unmodified linestabbable@6.2.0:resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==}tailwind-merge@2.3.0:resolution: {integrity: sha512-vkYrLpIP+lgR0tQCG6AP7zZXCTLc1Lnv/CCRT3BqJ9CZ3ui2++GPaGb1x/ILsINIMSYqqvrpqjUFsMNLlW99EA==}tailwindcss-animate@1.0.7:resolution: {integrity: sha512-bl6mpH3T7I3UFxuvDEXLxy/VuFxBk5bbzplh7tXI68mwMokNYd1t9qPBHlnyTwfa4JGC4zP516I1hYYtQ/vspA==}peerDependencies:tailwindcss: '>=3.0.0 || insiders'tailwindcss@3.4.4:resolution: {integrity: sha512-ZoyXOdJjISB7/BcLTR6SEsLgKtDStYyYZVLsUtWChO4Ps20CBad7lfJKVDiejocV4ME1hLmyY0WJE3hSDcmQ2A==}engines: {node: '>=14.0.0'}hasBin: true923 unmodified lines'@smithy/types': 2.12.0tslib: 2.6.2'@babel/helper-string-parser@7.24.7': {}'@babel/helper-validator-identifier@7.24.7': {}'@babel/parser@7.24.7':dependencies:'@babel/types': 7.24.7'@babel/runtime@7.24.4':dependencies:regenerator-runtime: 0.14.1'@babel/types@7.24.7':dependencies:'@babel/helper-string-parser': 7.24.7'@babel/helper-validator-identifier': 7.24.7to-fast-properties: 2.0.0'@emnapi/runtime@1.1.1':212 unmodified lines'@pkgjs/parseargs@0.11.0':optional: true'@playwright/test@1.44.1':dependencies:playwright: 1.44.1'@prisma/client@5.14.0(prisma@5.14.0)':optionalDependencies:prisma: 5.14.0736 unmodified linesdependencies:defer-to-connect: 2.0.1'@tailwindcss/typography@0.5.12(tailwindcss@3.4.4)':dependencies:lodash.castarray: 4.4.0lodash.isplainobject: 4.0.6lodash.merge: 4.6.2postcss-selector-parser: 6.0.10tailwindcss: 3.4.4'@types/cacheable-request@6.0.3':dependencies:134 unmodified lines'@vue/compiler-core@3.4.23':dependencies:'@babel/parser': 7.24.7'@vue/shared': 3.4.23entities: 4.5.0estree-walker: 2.0.26 unmodified lines'@vue/compiler-sfc@3.4.23':dependencies:'@babel/parser': 7.24.7'@vue/compiler-core': 3.4.23'@vue/compiler-dom': 3.4.23'@vue/compiler-ssr': 3.4.23723 unmodified linessemver: 6.3.1string.prototype.matchall: 4.0.11eslint-plugin-tailwindcss@3.15.1(tailwindcss@3.4.4):dependencies:fast-glob: 3.3.2postcss: 8.4.38tailwindcss: 3.4.4eslint-scope@7.2.2:dependencies:178 unmodified linesfs.realpath@1.0.0: {}fsevents@2.3.2:optional: truefsevents@2.3.3:optional: true1096 unmodified linespirates@4.0.6: {}playwright-core@1.44.1: {}playwright@1.44.1:dependencies:playwright-core: 1.44.1optionalDependencies:fsevents: 2.3.2possible-typed-array-names@1.0.0: {}postcss-import@15.1.0(postcss@8.4.38):361 unmodified linesdependencies:lru-cache: 6.0.0seroval-plugins@1.0.7(seroval@1.0.7):dependencies:seroval: 1.0.7seroval@1.0.7: {}set-function-length@1.2.2:dependencies:61 unmodified linessolid-js@1.8.16:dependencies:csstype: 3.1.3seroval: 1.0.7seroval-plugins: 1.0.7(seroval@1.0.7)solid-swr-store@0.10.7(solid-js@1.8.16)(swr-store@0.10.6):dependencies:142 unmodified linestabbable@6.2.0: {}tailwind-merge@2.3.0:dependencies:'@babel/runtime': 7.24.4tailwindcss-animate@1.0.7(tailwindcss@3.4.4):dependencies:tailwindcss: 3.4.4tailwindcss@3.4.4:dependencies:'@alloc/quick-lru': 5.2.0arg: 5.0.2
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485import { EXAMPLES, EXECUTE_CODE_FAILURE_TITLE, EXECUTE_CODE_SUCCESS_TITLE, PLAN_TITLE, TOOLS_TITLE,} from '@/lib/constants';import { test, expect, type Page } from '@playwright/test';
test.beforeEach(async ({ page }) => { // https://vercel.com/docs/security/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation await page.setExtraHTTPHeaders({ 'x-vercel-protection-bypass': process.env.VERCEL_AUTOMATION_BYPASS_SECRET ?? 'unknown', });});
test('Main page can be opened', async ({ page }) => { await page.goto('/');
await expect( page.getByRole('heading', { name: 'Vision Agent' }), ).toBeVisible();
await page.getByText(EXAMPLES[0].title).click(); await expect(page.getByPlaceholder('Message Vision Agent')).toHaveText( EXAMPLES[0].prompt, );});
const TEST_EXAMPLE_1_CHAT_ID_1 = 'jN6q4YK';const TEST_EXAMPLE_1_CHAT_ID_2 = 'w5ad73s';
const checkMainElementVisible = async (page: Page, hasFailingCase = false) => { await expect(page.getByText(EXAMPLES[0].prompt)).toBeVisible(); await expect( page.locator(`img[alt*="${EXAMPLES[0].mediaUrl}"]`), ).toBeVisible();
await expect(page.getByText(PLAN_TITLE)).toBeVisible(); await expect(page.getByText(TOOLS_TITLE)).toBeVisible(); if (hasFailingCase) { await expect(page.getByText(EXECUTE_CODE_FAILURE_TITLE)).toBeVisible(); } await expect(page.getByText(EXECUTE_CODE_SUCCESS_TITLE)).toBeVisible();
await expect(page.locator(`img[alt="result-image-0"]`).first()).toBeVisible();
const resultDisplayContainer = await page .getByTestId('code-result-display-container') .locator('visible=true'); await expect(resultDisplayContainer).toBeVisible();
await resultDisplayContainer .getByTestId('open-final-test-code-dialog-button') .click(); const dialog = await page.getByRole('dialog'); await expect( dialog.getByRole('heading', { name: 'Test code' }), ).toBeVisible(); await dialog .getByRole('button') .filter({ hasText: 'Close', }) .click(); await resultDisplayContainer .getByTestId('view-all-result-images-button') .click(); await expect(page.locator(`img[alt="detail-result-image-0"]`)).toBeVisible();};
test.describe('Page with example 1 can be opened', () => { test('Page with old data structiure can be opened', async ({ page }) => { await page.goto(`/chat/${TEST_EXAMPLE_1_CHAT_ID_1}`);
await checkMainElementVisible(page, true); });
test('Page with new data structiure can be opened', async ({ page }) => { await page.goto(`/chat/${TEST_EXAMPLE_1_CHAT_ID_2}`);
await checkMainElementVisible(page); });});.github/workflows/playwright.ymlAdded+34
.gitignore+5-1
app/page.tsx+2-18
components/CodeResultDisplay.tsx+21-5
components/chat/ChatMessage.tsx+40-6
components/ui/Dialog.tsx+2-1
lib/constants.ts+23-1
package.json+6-4
playwright.config.tsAdded+69
pnpm-lock.yaml+83-45
tests/e2e/index.spec.tsAdded+85