migrate second
This commit is contained in:
parent
3a8ba54e9b
commit
956a66adac
|
|
@ -61,7 +61,23 @@ test('openai', async ({ runUITest, server }) => {
|
|||
`);
|
||||
});
|
||||
|
||||
test('anthropic', async ({ runUITest }) => {
|
||||
test('anthropic', async ({ runUITest, server }) => {
|
||||
server.setRoute('/v1/messages', async (req, res) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
res.setHeader('Access-Control-Allow-Headers', '*');
|
||||
if (req.method === 'OPTIONS')
|
||||
return res.end();
|
||||
|
||||
expect(req.headers['x-api-key']).toBe('fake-key');
|
||||
expect((await req.postBody).toString()).toContain(`- button \\"Submit\\"`);
|
||||
const event = {
|
||||
type: 'content_block_delta',
|
||||
delta: { text: 'This is a mock response' },
|
||||
};
|
||||
res.setHeader('Content-Type', 'text/event-stream');
|
||||
res.write(`data: ${JSON.stringify(event)}\n\n`);
|
||||
});
|
||||
|
||||
const { page } = await runUITest({
|
||||
'a.test.ts': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
|
@ -71,19 +87,8 @@ test('anthropic', async ({ runUITest }) => {
|
|||
});
|
||||
`,
|
||||
}, {
|
||||
ANTHROPIC_API_KEY: 'fake-key'
|
||||
});
|
||||
|
||||
await page.context().route('https://api.anthropic.com/**', async (route, request) => {
|
||||
expect(await request.headerValue('x-api-key')).toBe('fake-key');
|
||||
expect(request.postData()).toContain(`- button \\"Submit\\"`);
|
||||
const event = {
|
||||
type: 'content_block_delta',
|
||||
delta: { text: 'This is a mock response' },
|
||||
};
|
||||
await route.fulfill({
|
||||
body: `\n\ndata: ${JSON.stringify(event)}\n\n`
|
||||
});
|
||||
ANTHROPIC_API_KEY: 'fake-key',
|
||||
ANTHROPIC_BASE_URL: server.PREFIX,
|
||||
});
|
||||
|
||||
await page.getByTitle('Run all').click();
|
||||
|
|
|
|||
Loading…
Reference in a new issue