basic opey integration tests

This commit is contained in:
Nemo Godebski-Pedersen 2025-03-26 17:44:25 +00:00
parent 64fc4566c2
commit 0504ff206e
4 changed files with 28 additions and 9 deletions

View File

@ -36,7 +36,8 @@ export default defineConfig({
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
...devices['Desktop Chrome'],
storageState: 'src/test/integration/playwright/.auth/user.json',
},
dependencies: ['setup'],
},

View File

@ -86,7 +86,7 @@ export default {
<el-icon color="#00ff18"><Check /></el-icon>
</div>
</div>
<div class="name">{{ toolCall.toolCall.name }}</div>
<div class="tool-name">{{ toolCall.toolCall.name }}</div>
</div>
</div>

View File

@ -129,7 +129,7 @@ export default {
<div class="user-input">
<textarea v-model="input" type="textarea" placeholder="Type your message..." :disabled="(chat.status !== 'ready') || (!chat.userIsAuthenticated)" @keypress.enter="onSubmit" />
</div>
<el-button type="primary" @click="onSubmit" color="#253047" :icon="ElTop" circle></el-button>
<el-button type="primary" name="send" @click="onSubmit" color="#253047" :icon="ElTop" circle></el-button>
</div>
</el-footer>
</el-container>

View File

@ -1,21 +1,39 @@
import { describe,beforeAll, beforeEach, afterAll, afterEach } from 'vitest';
import { chromium, Browser, Page, BrowserContext } from 'playwright';
import {test, expect} from '@playwright/test';
test.describe('Opey Integration Tests in API Explorer', () => {
test.beforeAll(async ({ page }) => {
const openAndSendMessage = async (page: Page, message: string) => {
// Open the chat widget
await page.goto('/');
const chatButton = await page.waitForSelector('.chat-widget-button');
const chatButton = await page.waitForSelector('.chat-widget-button')
await chatButton.click();
await page.getByRole('textbox', { name: 'Type your message...' }).click();
await page.getByRole('textbox', { name: 'Type your message...' }).fill(message);
await page.locator('button[name="send"]').click();
}
})
test('Send a basic message', async ({ page }) => {
test('Opey is running', async ({ page }) => {
await page.goto('/');
await openAndSendMessage(page, 'Hi there');
const assistantMessage = await page.locator('.assistant > .message-container > .content')
console.log(assistantMessage.textContent())
await expect(assistantMessage).not.toBeEmpty();
})
test.fixme('Send a message that would require a tool call to retrieve_endpoints', async ({page}) => {
await openAndSendMessage(page, 'What endpoints are avaliable to manage users?');
await page.locator('.assistant > .tool-calls-container').locator('tool-call').waitFor({state:"attached"})
const toolCallMessages = await page.locator('.assistant > .tool-calls-container').locator('.tool-call').all()
console.log(toolCallMessages.length)
await expect(toolCallMessages.length).toBeGreaterThan(0);
await expect(toolCallMessages[0].locator('.status + .tool-name')).toContainText('retrieve_endpoints');
})
})