From e10773ab7b89a04d1f8d364691db236d9d65009b Mon Sep 17 00:00:00 2001 From: rodrigo rodriguez de luna Date: Tue, 21 Nov 2023 21:12:28 -0600 Subject: [PATCH 01/21] =?UTF-8?q?test:=20=F0=9F=92=8D=20basic=20test=20for?= =?UTF-8?q?=20conversation=20with=20playwright?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit making and delete conversation of each of the ia model --- .github/workflows/playwright.yml | 27 +++++++ .gitignore | 4 + .../atoms/conversation-title-controls.tsx | 1 + .../molecules/conversation-card.tsx | 2 +- package.json | 6 +- playwright.config.ts | 80 +++++++++++++++++++ pnpm-lock.yaml | 69 ++++++++++++---- tests/auth0.spec.ts | 15 ++++ tests/model-dalle.spec.ts | 33 ++++++++ tests/model-gpt-3.5-16k.spec.ts | 26 ++++++ tests/model-gpt-3.5.spec.ts | 26 ++++++ 11 files changed, 270 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/playwright.yml create mode 100644 playwright.config.ts create mode 100644 tests/auth0.spec.ts create mode 100644 tests/model-dalle.spec.ts create mode 100644 tests/model-gpt-3.5-16k.spec.ts create mode 100644 tests/model-gpt-3.5.spec.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..0404c10 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,27 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm install -g pnpm && pnpm install + - name: Install Playwright Browsers + run: pnpm exec playwright install --with-deps + - name: Run Playwright tests + run: pnpm exec playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index d1595af..9cda64e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ yarn-error.log* # vercel .vercel +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/apps/web/components/user/conversationSidebar/atoms/conversation-title-controls.tsx b/apps/web/components/user/conversationSidebar/atoms/conversation-title-controls.tsx index 02abdb7..1cd4569 100644 --- a/apps/web/components/user/conversationSidebar/atoms/conversation-title-controls.tsx +++ b/apps/web/components/user/conversationSidebar/atoms/conversation-title-controls.tsx @@ -24,6 +24,7 @@ export default function ConversationTitleControls({disableConfirmButton, onConfi + diff --git a/apps/web/components/user/conversationSidebar/molecules/conversation-card.tsx b/apps/web/components/user/conversationSidebar/molecules/conversation-card.tsx index 1098886..5f564aa 100644 --- a/apps/web/components/user/conversationSidebar/molecules/conversation-card.tsx +++ b/apps/web/components/user/conversationSidebar/molecules/conversation-card.tsx @@ -245,7 +245,7 @@ export function ConversationCard({userTags, conversation, isSelected, onClick}: dropdownItems={singleSelectionListItems} placement="right" > - diff --git a/package.json b/package.json index aad2b4a..35c9f86 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,15 @@ "lint": "turbo run lint", "format": "prettier --write \"**/*.{ts,tsx,md}\"", "commit": "git-cz", - "prepare": "husky install" + "prepare": "husky install", + "test:ci": "playwright test", + "test": "playwright test --ui" }, "devDependencies": { + "@playwright/test": "^1.40.0", "@semantic-release/git": "^10.0.1", "@semantic-release/github": "^9.0.6", + "@types/node": "^20.9.3", "cz-conventional-changelog": "^3.3.0", "eslint": "^8.48.0", "husky": "^8.0.0", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..78b5b94 --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,80 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './tests', + /* 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: 'http://127.0.0.1:3000', + + /* 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'] }, + }, + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] }, + }, + { + name: 'Microsoft Edge', + use: { ...devices['Desktop Edge'], channel: 'msedge' }, + }, + { + name: 'Google Chrome', + use: { ...devices['Desktop Chrome'], channel: '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: 'npm run start', + // url: 'http://127.0.0.1:3000', + // reuseExistingServer: !process.env.CI, + // }, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 39ae180..91624ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,12 +18,18 @@ importers: specifier: ^1.2.2 version: 1.2.2 devDependencies: + '@playwright/test': + specifier: ^1.40.0 + version: 1.40.0 '@semantic-release/git': specifier: ^10.0.1 version: 10.0.1(semantic-release@22.0.0) '@semantic-release/github': specifier: ^9.0.6 version: 9.0.6(semantic-release@22.0.0) + '@types/node': + specifier: ^20.9.3 + version: 20.9.3 cz-conventional-changelog: specifier: ^3.3.0 version: 3.3.0(typescript@4.9.5) @@ -1188,10 +1194,10 @@ packages: '@commitlint/execute-rule': 18.4.0 '@commitlint/resolve-extends': 18.4.0 '@commitlint/types': 18.4.0 - '@types/node': 18.18.9 + '@types/node': 18.11.10 chalk: 4.1.2 cosmiconfig: 8.3.6(typescript@4.9.5) - cosmiconfig-typescript-loader: 5.0.0(@types/node@18.18.9)(cosmiconfig@8.3.6)(typescript@4.9.5) + cosmiconfig-typescript-loader: 5.0.0(@types/node@18.11.10)(cosmiconfig@8.3.6)(typescript@4.9.5) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -3201,6 +3207,14 @@ packages: tslib: 2.6.2 dev: true + /@playwright/test@1.40.0: + resolution: {integrity: sha512-PdW+kn4eV99iP5gxWNSDQCbhMaDVej+RXL5xr6t04nbKLCBwYtA046t7ofoczHOm8u6c+45hpDKQVZqtqwkeQg==} + engines: {node: '>=16'} + hasBin: true + dependencies: + playwright: 1.40.0 + dev: true + /@pnpm/config.env-replace@1.1.0: resolution: {integrity: sha512-htyl8TWnKL7K/ESFa1oW2UB5lVDxuF5DpM7tBi6Hu2LNL3mWkIzNLG6N4zoCUP1lCKNxWy/3iu8mS8MvToGd6w==} engines: {node: '>=12.22.0'} @@ -5117,7 +5131,7 @@ packages: resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} dependencies: '@types/minimatch': 5.1.2 - '@types/node': 20.5.2 + '@types/node': 20.5.6 dev: true /@types/hast@2.3.6: @@ -5181,14 +5195,6 @@ packages: resolution: {integrity: sha512-juG3RWMBOqcOuXC643OAdSA525V44cVgGV6dUDuiFtss+8Fk5x1hI93Rsld43VeJVIeqlP9I7Fn9/qaVqoEAuQ==} dev: true - /@types/node@18.18.9: - resolution: {integrity: sha512-0f5klcuImLnG4Qreu9hPj/rEfFq6YRc5n2mAjSsH+ec/mJL+3voBH0+8T7o8RpFjH7ovc+TRsL/c7OYIQsPTfQ==} - requiresBuild: true - dependencies: - undici-types: 5.26.5 - dev: true - optional: true - /@types/node@20.5.2: resolution: {integrity: sha512-5j/lXt7unfPOUlrKC34HIaedONleyLtwkKggiD/0uuMfT8gg2EOpg0dz4lCD15Ga7muC+1WzJZAjIB9simWd6Q==} dev: true @@ -5196,6 +5202,12 @@ packages: /@types/node@20.5.6: resolution: {integrity: sha512-Gi5wRGPbbyOTX+4Y2iULQ27oUPrefaB0PxGQJnfyWN3kvEDGM3mIB5M/gQLmitZf7A9FmLeaqxD3L1CXpm3VKQ==} + /@types/node@20.9.3: + resolution: {integrity: sha512-nk5wXLAXGBKfrhLB0cyHGbSqopS+nz0BUgZkUQqSHSSgdee0kssp1IAqlQOu333bW+gMNs2QREx7iynm19Abxw==} + dependencies: + undici-types: 5.26.5 + dev: true + /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} dev: true @@ -5274,7 +5286,7 @@ packages: /@types/through@0.0.30: resolution: {integrity: sha512-FvnCJljyxhPM3gkRgWmxmDZyAQSiBQQWLI0A0VFL0K7W1oRUrPJSqNO0NvTnLkBcotdlp3lKvaT0JrnyRDkzOg==} dependencies: - '@types/node': 20.5.2 + '@types/node': 20.5.6 dev: true /@types/unist@2.0.8: @@ -5682,7 +5694,7 @@ packages: dependencies: '@vue/compiler-ssr': 3.3.8 '@vue/shared': 3.3.8 - vue: 3.3.8(typescript@5.1.3) + vue: 3.3.8(typescript@4.9.5) dev: false /@vue/shared@3.3.8: @@ -6707,7 +6719,7 @@ packages: layout-base: 2.0.1 dev: false - /cosmiconfig-typescript-loader@5.0.0(@types/node@18.18.9)(cosmiconfig@8.3.6)(typescript@4.9.5): + /cosmiconfig-typescript-loader@5.0.0(@types/node@18.11.10)(cosmiconfig@8.3.6)(typescript@4.9.5): resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} engines: {node: '>=v16'} requiresBuild: true @@ -6716,7 +6728,7 @@ packages: cosmiconfig: '>=8.2' typescript: '>=4' dependencies: - '@types/node': 18.18.9 + '@types/node': 18.11.10 cosmiconfig: 8.3.6(typescript@4.9.5) jiti: 1.21.0 typescript: 4.9.5 @@ -8557,6 +8569,14 @@ packages: /fs.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] + requiresBuild: true + dev: true + optional: true + /fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -12056,6 +12076,22 @@ packages: load-json-file: 4.0.0 dev: true + /playwright-core@1.40.0: + resolution: {integrity: sha512-fvKewVJpGeca8t0ipM56jkVSU6Eo0RmFvQ/MaCQNDYm+sdvKkMBBWTE1FdeMqIdumRaXXjZChWHvIzCGM/tA/Q==} + engines: {node: '>=16'} + hasBin: true + dev: true + + /playwright@1.40.0: + resolution: {integrity: sha512-gyHAgQjiDf1m34Xpwzaqb76KgfzYrhK7iih+2IzcOCoZWr/8ZqmdBw+t0RU85ZmfJMgtgAiNtBQ/KS2325INXw==} + engines: {node: '>=16'} + hasBin: true + dependencies: + playwright-core: 1.40.0 + optionalDependencies: + fsevents: 2.3.2 + dev: true + /pluralize@8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} @@ -13533,7 +13569,7 @@ packages: peerDependencies: vue: '>=3.2.26 < 4' dependencies: - vue: 3.3.8(typescript@5.1.3) + vue: 3.3.8(typescript@4.9.5) dev: false /synckit@0.8.5: @@ -13992,7 +14028,6 @@ packages: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} requiresBuild: true dev: true - optional: true /unified@10.1.2: resolution: {integrity: sha512-pUSWAi/RAnVy1Pif2kAoeWNBa3JVrx0MId2LASj8G+7AiHWoKZNTomq6LG326T68U7/e263X6fTdcXIy7XnF7Q==} diff --git a/tests/auth0.spec.ts b/tests/auth0.spec.ts new file mode 100644 index 0000000..dfa974c --- /dev/null +++ b/tests/auth0.spec.ts @@ -0,0 +1,15 @@ +import { test, expect } from '@playwright/test'; + +test('test', async ({ page }) => { + await page.goto('http://localhost:3000/'); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.getByLabel('Email address').fill('prueba@gmail.com'); + await page.getByLabel('Password').click(); + await page.getByLabel('Password').press('CapsLock'); + await page.getByLabel('Password').fill('H'); + await page.getByLabel('Password').press('CapsLock'); + await page.getByLabel('Password').fill('Holamundo:1'); + await page.getByRole('button', { name: 'Continue', exact: true }).click(); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.goto('http://localhost:3000/conversation/new'); +}); diff --git a/tests/model-dalle.spec.ts b/tests/model-dalle.spec.ts new file mode 100644 index 0000000..78733a2 --- /dev/null +++ b/tests/model-dalle.spec.ts @@ -0,0 +1,33 @@ +import { test, expect } from '@playwright/test'; + +test('test', async ({ page }) => { + await page.goto('http://localhost:3000/'); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.getByLabel('Email address').fill('prueba@gmail.com'); + await page.getByLabel('Password').click(); + await page.getByLabel('Password').press('CapsLock'); + await page.getByLabel('Password').fill('H'); + await page.getByLabel('Password').press('CapsLock'); + await page.getByLabel('Password').fill('Holamundo:1'); + await page.getByRole('button', { name: 'Continue', exact: true }).click(); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.goto('http://localhost:3000/conversation/new'); + await page.getByRole('button', { name: 'New Chat' }).click(); + await page.getByPlaceholder('Chat name').fill('test 2'); + await page.getByLabel('Select a Model', { exact: true }).click(); + await page.getByLabel('DALLE2 Tokens').getByText('DALLE').click(); + await page.getByRole('button', { name: 'Create' }).click(); + await page.getByPlaceholder('Send Message').fill('christmas cat'); + await page.getByText('3', { exact: true }).click(); + await page.getByRole('button', { name: 'Size' }).click(); + await page.getByText('512x512').click(); + await page.getByRole('button', { name: 'Save' }).click(); + await page.locator('form').getByRole('button').click(); + await page.getByText('christmas cat'); + await page.locator('.pb-32 > div:nth-child(2) > div > div'); + + await page.locator('[id="edit-chat"]').click(); + await page.getByText('Delete').click(); + await page.getByRole('button', { name: 'Confirm' }).click(); + await page.getByText('No items to display').click(); +}); \ No newline at end of file diff --git a/tests/model-gpt-3.5-16k.spec.ts b/tests/model-gpt-3.5-16k.spec.ts new file mode 100644 index 0000000..299aec3 --- /dev/null +++ b/tests/model-gpt-3.5-16k.spec.ts @@ -0,0 +1,26 @@ +import { test, expect } from '@playwright/test'; + +test('test', async ({ page }) => { + await page.goto('http://localhost:3000/'); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.getByLabel('Email address').fill('prueba@gmail.com'); + await page.getByLabel('Password').fill('Holamundo:1'); + await page.getByRole('button', { name: 'Continue', exact: true }).click(); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.goto('http://localhost:3000/conversation/new'); + await page.getByRole('button', { name: 'New Chat' }).click(); + await page.getByPlaceholder('Chat name').fill('test 3'); + await page.getByLabel('Select a Model', { exact: true }).click(); + await page.getByLabel('GPT-3.5-TURBO-16K2 Tokens').getByText('GPT-3.5-TURBO-16K').click(); + await page.getByRole('button', { name: 'Create' }).click(); + await page.getByPlaceholder('Send Message').click(); + await page.getByPlaceholder('Send Message').fill('¿Cuál es la capital de Francia?'); + await page.getByText('10').click(); + await page.locator('form').getByRole('button').click(); + await page.getByText('¿Cuál es la capital de Francia?').click(); + await page.getByText('La capital de Francia es París').click(); + await page.locator('[id="edit-chat"]').click(); + await page.getByText('Delete').click(); + await page.getByRole('button', { name: 'Confirm' }).click(); + await page.getByText('No items to display').click(); +}); \ No newline at end of file diff --git a/tests/model-gpt-3.5.spec.ts b/tests/model-gpt-3.5.spec.ts new file mode 100644 index 0000000..cd2a472 --- /dev/null +++ b/tests/model-gpt-3.5.spec.ts @@ -0,0 +1,26 @@ +import { test, expect } from '@playwright/test'; + +test('test', async ({ page }) => { + await page.goto('http://localhost:3000/'); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.getByLabel('Email address').fill('prueba@gmail.com'); + await page.getByLabel('Password').fill('Holamundo:1'); + await page.getByRole('button', { name: 'Continue', exact: true }).click(); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.goto('http://localhost:3000/conversation/new'); + + await page.getByRole('button', { name: 'New Chat' }).click(); + await page.getByPlaceholder('Chat name').fill('test 1'); + await page.getByLabel('Select a Model', { exact: true }).click(); + await page.getByLabel('GPT-3.5-TURBO2 Tokens').getByText('GPT-3.5-TURBO').click(); + await page.getByRole('button', { name: 'Create' }).click(); + await page.getByPlaceholder('Send Message').fill('¿Cuál es la capital de Francia?"'); + await page.getByText('10', { exact: true }).click(); + await page.locator('form').getByRole('button').click(); + await page.getByText('¿Cuál es la capital de Francia?"', { exact: true }); + await page.getByText('La capital de Francia es París.'); + await page.locator('[id="edit-chat"]').click(); + await page.getByText('Delete').click(); + await page.getByRole('button', { name: 'Confirm' }).click(); + await page.getByText('No items to display').click(); +}); \ No newline at end of file From 0c1fefc8cfe695ac2ebd5cca0e24d890e01cf15f Mon Sep 17 00:00:00 2001 From: rodrigo rodriguez de luna Date: Thu, 23 Nov 2023 18:39:18 -0600 Subject: [PATCH 02/21] =?UTF-8?q?test:=20=F0=9F=92=8D=20test=20for=20the?= =?UTF-8?q?=20sidebar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test for tags and search bar on the sidebar --- .../molecules/message-list.tsx | 2 +- .../molecules/prompt-text-input.tsx | 2 +- .../molecules/conversation-card.tsx | 1 + .../molecules/conversation-list.tsx | 2 +- .../organisms/conversation-sidebar.tsx | 2 +- .../user/tagMenu/molecules/tag-editor.tsx | 2 +- package.json | 2 +- playwright.config.ts | 24 +++--- tests/auth0.spec.ts | 4 - tests/conversations.spec.ts | 74 ++++++++++++++++ tests/model-dalle.spec.ts | 33 ------- tests/model-gpt-3.5-16k.spec.ts | 26 ------ tests/model-gpt-3.5.spec.ts | 26 ------ tests/sidebarCon.spec.ts | 42 +++++++++ tests/sidebarTag.spec.ts | 85 +++++++++++++++++++ 15 files changed, 220 insertions(+), 107 deletions(-) create mode 100644 tests/conversations.spec.ts delete mode 100644 tests/model-dalle.spec.ts delete mode 100644 tests/model-gpt-3.5-16k.spec.ts delete mode 100644 tests/model-gpt-3.5.spec.ts create mode 100644 tests/sidebarCon.spec.ts create mode 100644 tests/sidebarTag.spec.ts diff --git a/apps/web/components/user/conversationBody/molecules/message-list.tsx b/apps/web/components/user/conversationBody/molecules/message-list.tsx index 64000e8..899788f 100644 --- a/apps/web/components/user/conversationBody/molecules/message-list.tsx +++ b/apps/web/components/user/conversationBody/molecules/message-list.tsx @@ -40,7 +40,7 @@ export default function MessageList({ }, [autoScroll, messages]); return ( -
+
{/* Messages display */} {messages.map((message, index) => (
diff --git a/apps/web/components/user/conversationBody/molecules/prompt-text-input.tsx b/apps/web/components/user/conversationBody/molecules/prompt-text-input.tsx index f65e469..87fb8a9 100644 --- a/apps/web/components/user/conversationBody/molecules/prompt-text-input.tsx +++ b/apps/web/components/user/conversationBody/molecules/prompt-text-input.tsx @@ -74,7 +74,7 @@ export default function PromptTextInput({
{/* Tokens Placeholder */} -
+
diff --git a/apps/web/components/user/conversationSidebar/molecules/conversation-card.tsx b/apps/web/components/user/conversationSidebar/molecules/conversation-card.tsx index 5f564aa..ab448e2 100644 --- a/apps/web/components/user/conversationSidebar/molecules/conversation-card.tsx +++ b/apps/web/components/user/conversationSidebar/molecules/conversation-card.tsx @@ -184,6 +184,7 @@ export function ConversationCard({userTags, conversation, isSelected, onClick}: size="sm" value={title} variant="bordered" + id="edit-name" /> ); diff --git a/apps/web/components/user/conversationSidebar/molecules/conversation-list.tsx b/apps/web/components/user/conversationSidebar/molecules/conversation-list.tsx index 0db145e..53552c1 100644 --- a/apps/web/components/user/conversationSidebar/molecules/conversation-list.tsx +++ b/apps/web/components/user/conversationSidebar/molecules/conversation-list.tsx @@ -17,7 +17,7 @@ export function ConversationList({selectedConversation, userTags, userConversati if (userConversations.length === 0){ return (
-

No items to display

+

No items to display

); } diff --git a/apps/web/components/user/conversationSidebar/organisms/conversation-sidebar.tsx b/apps/web/components/user/conversationSidebar/organisms/conversation-sidebar.tsx index 2731f02..5cf91ec 100644 --- a/apps/web/components/user/conversationSidebar/organisms/conversation-sidebar.tsx +++ b/apps/web/components/user/conversationSidebar/organisms/conversation-sidebar.tsx @@ -183,7 +183,7 @@ export default function ConversationSidebar({userTags, models}: ConversationSide content={selectedTags.size} isInvisible={selectedTags.size === 0} > - diff --git a/apps/web/components/user/tagMenu/molecules/tag-editor.tsx b/apps/web/components/user/tagMenu/molecules/tag-editor.tsx index 25a6d33..51b36a8 100644 --- a/apps/web/components/user/tagMenu/molecules/tag-editor.tsx +++ b/apps/web/components/user/tagMenu/molecules/tag-editor.tsx @@ -22,7 +22,7 @@ export function TagEditor({tagName, tagColor, onTagNameChange, onTagColorChange}

Name

- +
diff --git a/package.json b/package.json index 35c9f86..aec88a3 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "commit": "git-cz", "prepare": "husky install", "test:ci": "playwright test", - "test": "playwright test --ui" + "test": "playwright test --ui " }, "devDependencies": { "@playwright/test": "^1.40.0", diff --git a/playwright.config.ts b/playwright.config.ts index 78b5b94..ece2441 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -32,18 +32,6 @@ export default defineConfig({ /* Configure projects for major browsers */ projects: [ - { - name: 'chromium', - use: { ...devices['Desktop Chrome'] }, - }, - { - name: 'firefox', - use: { ...devices['Desktop Firefox'] }, - }, - { - name: 'Microsoft Edge', - use: { ...devices['Desktop Edge'], channel: 'msedge' }, - }, { name: 'Google Chrome', use: { ...devices['Desktop Chrome'], channel: 'chrome' }, @@ -61,6 +49,14 @@ export default defineConfig({ // }, /* Test against branded browsers. */ + //{ + // name: 'firefox', + // use: { ...devices['Desktop Firefox'] }, + //}, + //{ + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + //}, // { // name: 'Microsoft Edge', // use: { ...devices['Desktop Edge'], channel: 'msedge' }, @@ -69,6 +65,10 @@ export default defineConfig({ // name: 'Google Chrome', // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, // }, + //{ + // name: 'chromium', + // use: { ...devices['Desktop Chrome'] }, + //}, ], /* Run your local dev server before starting the tests */ diff --git a/tests/auth0.spec.ts b/tests/auth0.spec.ts index dfa974c..1c95832 100644 --- a/tests/auth0.spec.ts +++ b/tests/auth0.spec.ts @@ -4,10 +4,6 @@ test('test', async ({ page }) => { await page.goto('http://localhost:3000/'); await page.getByRole('button', { name: 'Get Started' }).click(); await page.getByLabel('Email address').fill('prueba@gmail.com'); - await page.getByLabel('Password').click(); - await page.getByLabel('Password').press('CapsLock'); - await page.getByLabel('Password').fill('H'); - await page.getByLabel('Password').press('CapsLock'); await page.getByLabel('Password').fill('Holamundo:1'); await page.getByRole('button', { name: 'Continue', exact: true }).click(); await page.getByRole('button', { name: 'Get Started' }).click(); diff --git a/tests/conversations.spec.ts b/tests/conversations.spec.ts new file mode 100644 index 0000000..d44ea7b --- /dev/null +++ b/tests/conversations.spec.ts @@ -0,0 +1,74 @@ +import { test, expect } from '@playwright/test'; + +test.describe('conversations', () => { + test.beforeEach(async ({ page }) => { + await page.goto('http://localhost:3000/'); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.getByLabel('Email address').fill('prueba@gmail.com'); + await page.getByLabel('Password').fill('Holamundo:1'); + await page.getByRole('button', { name: 'Continue', exact: true }).click(); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.goto('http://localhost:3000/conversation/new'); + }); + + test.afterEach(async({page})=>{ + await page.locator('[id="edit-chat"]').click(); + await page.getByText('Delete').click(); + await page.getByRole('button', { name: 'Confirm' }).click(); + }); + + test('Model ChatGPT-3.5', async ({ page }) => { + await page.getByRole('button', { name: 'New Chat' }).click(); + await page.getByPlaceholder('Chat name').fill('test 1'); + await page.getByLabel('Select a Model', { exact: true }).click(); + await page.getByLabel('GPT-3.5-TURBO2 Tokens').getByText('GPT-3.5-TURBO').click(); + await page.getByRole('button', { name: 'Create' }).click(); + await page.getByPlaceholder('Send Message').fill('what is the capital of france?'); + await expect(page.locator('[id="token-count"]')).toContainText('7'); + await page.locator('form').getByRole('button').click(); + await expect(page.getByText('what is the capital of france?', { exact: true })).toBeVisible({timeout: 120000}); + await expect(page.getByText('The capital of France is Paris.')).toBeVisible({timeout: 120000}); + }); + + test('Model Dalle', async ({ page }) => { + await page.getByRole('button', { name: 'New Chat' }).click(); + await page.getByPlaceholder('Chat name').fill('test 2'); + await page.getByLabel('Select a Model', { exact: true }).click(); + await page.getByLabel('DALLE2 Tokens').getByText('DALLE').click(); + await page.getByRole('button', { name: 'Create' }).click(); + await page.getByRole('button', { name: 'Size' }).click(); + await page.getByText('256x256').click(); + await page.getByRole('button', { name: 'Save' }).click(); + await page.getByPlaceholder('Send Message').fill('cat in a suit'); + await page.locator('form').getByRole('button').click(); + await expect(page.getByText('cat in a suit', { exact: true })).toBeVisible({timeout: 120000}); + await expect(page.getByRole('img', { name: 'Generated image' })).toBeVisible({timeout: 200000}); + }); + + test('Model ChatGPT-3.5-16k', async ({ page }) => { + await page.getByRole('button', { name: 'New Chat' }).click(); + await page.getByPlaceholder('Chat name').fill('test 3'); + await page.getByLabel('Select a Model', { exact: true }).click(); + await page.getByLabel('GPT-3.5-TURBO-16K2 Tokens').getByText('GPT-3.5-TURBO-16K').click(); + await page.getByRole('button', { name: 'Create' }).click(); + await page.getByPlaceholder('Send Message').fill('what is the capital of france?'); + await expect(page.locator('#token-count')).toContainText('7'); + await page.locator('form').getByRole('button').click(); + await expect(page.getByText('what is the capital of france?', { exact: true })).toBeVisible({timeout: 120000}); + await expect(page.getByText('The capital of France is Paris.')).toBeVisible({timeout: 120000}); + }); +/* + test('Model ChatGPT-4', async ({ page }) => { + await page.getByRole('button', { name: 'New Chat' }).click(); + await page.getByPlaceholder('Chat name').fill('test 4'); + await page.getByLabel('Select a Model', { exact: true }).click(); + await page.getByLabel('GPT-42 Tokens').getByText('GPT-').click(); + await page.getByRole('button', { name: 'Create' }).click(); + await page.getByPlaceholder('Send Message').fill('what is the capital of france?'); + await expect(page.locator('#token-count')).toContainText('7'); + await page.locator('form').getByRole('button').click(); + await expect(page.getByText('what is the capital of france?', { exact: true })).toBeVisible({timeout: 120000}); + await expect(page.getByText('The capital of France is Paris.')).toBeVisible({timeout: 120000}); + }); +*/ + }); \ No newline at end of file diff --git a/tests/model-dalle.spec.ts b/tests/model-dalle.spec.ts deleted file mode 100644 index 78733a2..0000000 --- a/tests/model-dalle.spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('test', async ({ page }) => { - await page.goto('http://localhost:3000/'); - await page.getByRole('button', { name: 'Get Started' }).click(); - await page.getByLabel('Email address').fill('prueba@gmail.com'); - await page.getByLabel('Password').click(); - await page.getByLabel('Password').press('CapsLock'); - await page.getByLabel('Password').fill('H'); - await page.getByLabel('Password').press('CapsLock'); - await page.getByLabel('Password').fill('Holamundo:1'); - await page.getByRole('button', { name: 'Continue', exact: true }).click(); - await page.getByRole('button', { name: 'Get Started' }).click(); - await page.goto('http://localhost:3000/conversation/new'); - await page.getByRole('button', { name: 'New Chat' }).click(); - await page.getByPlaceholder('Chat name').fill('test 2'); - await page.getByLabel('Select a Model', { exact: true }).click(); - await page.getByLabel('DALLE2 Tokens').getByText('DALLE').click(); - await page.getByRole('button', { name: 'Create' }).click(); - await page.getByPlaceholder('Send Message').fill('christmas cat'); - await page.getByText('3', { exact: true }).click(); - await page.getByRole('button', { name: 'Size' }).click(); - await page.getByText('512x512').click(); - await page.getByRole('button', { name: 'Save' }).click(); - await page.locator('form').getByRole('button').click(); - await page.getByText('christmas cat'); - await page.locator('.pb-32 > div:nth-child(2) > div > div'); - - await page.locator('[id="edit-chat"]').click(); - await page.getByText('Delete').click(); - await page.getByRole('button', { name: 'Confirm' }).click(); - await page.getByText('No items to display').click(); -}); \ No newline at end of file diff --git a/tests/model-gpt-3.5-16k.spec.ts b/tests/model-gpt-3.5-16k.spec.ts deleted file mode 100644 index 299aec3..0000000 --- a/tests/model-gpt-3.5-16k.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('test', async ({ page }) => { - await page.goto('http://localhost:3000/'); - await page.getByRole('button', { name: 'Get Started' }).click(); - await page.getByLabel('Email address').fill('prueba@gmail.com'); - await page.getByLabel('Password').fill('Holamundo:1'); - await page.getByRole('button', { name: 'Continue', exact: true }).click(); - await page.getByRole('button', { name: 'Get Started' }).click(); - await page.goto('http://localhost:3000/conversation/new'); - await page.getByRole('button', { name: 'New Chat' }).click(); - await page.getByPlaceholder('Chat name').fill('test 3'); - await page.getByLabel('Select a Model', { exact: true }).click(); - await page.getByLabel('GPT-3.5-TURBO-16K2 Tokens').getByText('GPT-3.5-TURBO-16K').click(); - await page.getByRole('button', { name: 'Create' }).click(); - await page.getByPlaceholder('Send Message').click(); - await page.getByPlaceholder('Send Message').fill('¿Cuál es la capital de Francia?'); - await page.getByText('10').click(); - await page.locator('form').getByRole('button').click(); - await page.getByText('¿Cuál es la capital de Francia?').click(); - await page.getByText('La capital de Francia es París').click(); - await page.locator('[id="edit-chat"]').click(); - await page.getByText('Delete').click(); - await page.getByRole('button', { name: 'Confirm' }).click(); - await page.getByText('No items to display').click(); -}); \ No newline at end of file diff --git a/tests/model-gpt-3.5.spec.ts b/tests/model-gpt-3.5.spec.ts deleted file mode 100644 index cd2a472..0000000 --- a/tests/model-gpt-3.5.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('test', async ({ page }) => { - await page.goto('http://localhost:3000/'); - await page.getByRole('button', { name: 'Get Started' }).click(); - await page.getByLabel('Email address').fill('prueba@gmail.com'); - await page.getByLabel('Password').fill('Holamundo:1'); - await page.getByRole('button', { name: 'Continue', exact: true }).click(); - await page.getByRole('button', { name: 'Get Started' }).click(); - await page.goto('http://localhost:3000/conversation/new'); - - await page.getByRole('button', { name: 'New Chat' }).click(); - await page.getByPlaceholder('Chat name').fill('test 1'); - await page.getByLabel('Select a Model', { exact: true }).click(); - await page.getByLabel('GPT-3.5-TURBO2 Tokens').getByText('GPT-3.5-TURBO').click(); - await page.getByRole('button', { name: 'Create' }).click(); - await page.getByPlaceholder('Send Message').fill('¿Cuál es la capital de Francia?"'); - await page.getByText('10', { exact: true }).click(); - await page.locator('form').getByRole('button').click(); - await page.getByText('¿Cuál es la capital de Francia?"', { exact: true }); - await page.getByText('La capital de Francia es París.'); - await page.locator('[id="edit-chat"]').click(); - await page.getByText('Delete').click(); - await page.getByRole('button', { name: 'Confirm' }).click(); - await page.getByText('No items to display').click(); -}); \ No newline at end of file diff --git a/tests/sidebarCon.spec.ts b/tests/sidebarCon.spec.ts new file mode 100644 index 0000000..5338718 --- /dev/null +++ b/tests/sidebarCon.spec.ts @@ -0,0 +1,42 @@ +import { test, expect } from '@playwright/test'; + +test.describe('Sidebar conversations', () => { + test.beforeEach(async ({ page }) => { + await page.goto('http://localhost:3000/'); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.getByLabel('Email address').fill('prueba@gmail.com'); + await page.getByLabel('Password').fill('Holamundo:1'); + await page.getByRole('button', { name: 'Continue', exact: true }).click(); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.goto('http://localhost:3000/conversation/new'); + }); + + test('Search and rename conversation', async({page})=>{ + await page.getByRole('button', { name: 'New Chat' }).click(); + await page.getByPlaceholder('Chat name').fill('search test'); + await page.getByLabel('Select a Model', { exact: true }).click(); + await page.getByLabel('GPT-3.5-TURBO2 Tokens').getByText('GPT-3.5-TURBO').click(); + await page.getByRole('button', { name: 'Create' }).click(); + await page.getByPlaceholder('Search Chat').fill('random'); + await expect(page.locator('#no-items')).toContainText('No items to display'); + await page.locator('.p-2').first().click(); + await page.getByPlaceholder('Search Chat').fill('test'); + await expect(page.getByRole('button', { name: 'avatar search test' })).toBeVisible(); + await page.locator('#edit-chat').click(); + await page.getByText('Rename').click(); + await page.locator('#edit-name').fill('hello world'); + await page.getByRole('button', { name: 'avatar' }).getByRole('button').first().click(); + await page.getByPlaceholder('Search Chat').fill('test'); + await expect(page.locator('#no-items')).toContainText('No items to display'); + await page.locator('.p-2').first().click(); + await page.getByPlaceholder('Search Chat').fill('world'); + await expect(page.getByRole('button', { name: 'avatar hello world' })).toBeVisible(); + + + await page.locator('[id="edit-chat"]').click(); + await page.getByText('Delete').click(); + await page.getByRole('button', { name: 'Confirm' }).click(); + }); + + + }); \ No newline at end of file diff --git a/tests/sidebarTag.spec.ts b/tests/sidebarTag.spec.ts new file mode 100644 index 0000000..f6c301b --- /dev/null +++ b/tests/sidebarTag.spec.ts @@ -0,0 +1,85 @@ +import { test, expect } from '@playwright/test'; + +test.describe('sidebar tag', () => { + test.beforeEach(async ({ page }) => { + await page.goto('http://localhost:3000/'); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.getByLabel('Email address').fill('prueba@gmail.com'); + await page.getByLabel('Password').fill('Holamundo:1'); + await page.getByRole('button', { name: 'Continue', exact: true }).click(); + await page.getByRole('button', { name: 'Get Started' }).click(); + await page.goto('http://localhost:3000/conversation/new'); + }); + + + test('Create tag', async ({ page }) => { + await page.locator('#tag-search').click(); + await page.getByRole('button', { name: 'Edit tags' }).click(); + await page.getByRole('button', { name: 'New tag +' }).click(); + await page.locator('#tag-name').fill('test'); + await page.locator('div:nth-child(2) > div > div:nth-child(3) > div').click(); + await page.getByRole('button', { name: 'Save' }).click(); + await expect(page.getByText('test', { exact: true })).toBeVisible({timeout: 120000}); + await page.getByRole('button', { name: 'Close' }).click(); + }); + + + test('Edit tag', async ({ page }) => { + await page.locator('#tag-search').click(); + await page.getByRole('button', { name: 'Edit tags' }).click(); + await page.getByRole('button', { name: 'test' }).nth(1).click(); + await page.locator('#tag-name').fill('test tag'); + await page.locator('.hue-horizontal').click(); + await page.locator('.slider-picker > div:nth-child(2) > div > div:nth-child(2) > div').click(); + await page.getByRole('button', { name: 'Save' }).click(); + await expect(page.getByText('test tag', { exact: true })).toBeVisible({timeout: 120000}); + await page.getByRole('button', { name: 'Close' }).click(); + }); + + + test('Search tag', async ({ page }) => { + await page.locator('#tag-search').click(); + await page.getByPlaceholder('Search tags').fill('tag'); + await expect(page.getByText('test tag', { exact: true })).toBeVisible({timeout: 120000}); + await page.getByPlaceholder('Search tags').fill('random'); + await expect(page.getByText('No tags to display')).toContainText('No tags to display'); + await page.getByRole('button', { name: 'Close' }).click(); + }); + + + test('Search by tag', async({page})=>{ + await page.getByRole('button', { name: 'New Chat' }).click(); + await page.getByPlaceholder('Chat name').fill('tag test'); + await page.getByLabel('Select a Model', { exact: true }).click(); + await page.getByLabel('GPT-3.5-TURBO2 Tokens').getByText('GPT-3.5-TURBO').click(); + await page.getByRole('button', { name: 'Create' }).click(); + await page.locator('#tag-search').click(); + await page.getByRole('button', { name: 'test tag' }).click(); + await page.getByRole('button', { name: 'Close' }).click(); + await expect(page.locator('#no-items')).toContainText('No items to display'); + await page.locator('#tag-search').click(); + await page.getByRole('button', { name: 'test tag' }).click(); + await page.getByRole('button', { name: 'Close' }).click(); + await page.locator('#edit-chat').click(); + await page.getByText('Edit Tags').click(); + await page.getByRole('button', { name: 'test tag' }).click(); + await page.getByRole('button', { name: 'Close' }).click(); + await page.locator('#tag-search').click(); + await page.getByRole('button', { name: 'test tag' }).click(); + await page.getByRole('button', { name: 'Close' }).click(); + await expect(page.getByRole('button', { name: 'avatar tag test' })).toBeVisible(); + await page.locator('[id="edit-chat"]').click(); + await page.getByText('Delete').click(); + await page.getByRole('button', { name: 'Confirm' }).click(); + }) + + + test('Delete tag', async ({ page }) => { + await page.locator('#tag-search').click(); + await page.getByRole('button', { name: 'Edit tags' }).click(); + await page.getByRole('button', { name: 'test tag' }).nth(1).click(); + await page.locator('div').filter({ hasText: /^Edit tag$/ }).getByRole('button').click(); + await page.getByRole('button', { name: 'Close' }).click(); + }); + +}); \ No newline at end of file From b2ef735a4ed0c90a2c0ef229194c0abdb827767c Mon Sep 17 00:00:00 2001 From: rodrigo rodriguez de luna Date: Fri, 24 Nov 2023 12:50:39 -0600 Subject: [PATCH 03/21] =?UTF-8?q?test:=20=F0=9F=92=8D=20test=20admin=20das?= =?UTF-8?q?hboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit create new group, search group, and delete a group --- .../molecules/prompt-text-input.tsx | 1 + .../user/tagMenu/molecules/tag-editor.tsx | 2 +- playwright.config.ts | 4 +- tests/admin.spec.ts | 62 +++++++++++++++++++ tests/conversations.spec.ts | 24 +++---- tests/sidebarCon.spec.ts | 6 +- tests/sidebarTag.spec.ts | 2 +- 7 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 tests/admin.spec.ts diff --git a/apps/web/components/user/conversationBody/molecules/prompt-text-input.tsx b/apps/web/components/user/conversationBody/molecules/prompt-text-input.tsx index 87fb8a9..62c4c61 100644 --- a/apps/web/components/user/conversationBody/molecules/prompt-text-input.tsx +++ b/apps/web/components/user/conversationBody/molecules/prompt-text-input.tsx @@ -96,6 +96,7 @@ export default function PromptTextInput({ ) : (