feat: dynamic model discovery from vercel ai gateway (#1353)

This commit is contained in:
josh 2025-12-14 21:26:49 +00:00 committed by GitHub
parent 2b0b42d144
commit b1da86062e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
74 changed files with 7426 additions and 2277 deletions

View file

@ -1,7 +1,7 @@
import { expect, test } from "../fixtures";
import { expect, test } from "@playwright/test";
import { ChatPage } from "../pages/chat";
test.describe("Chat activity", () => {
test.describe("Chat", () => {
let chatPage: ChatPage;
test.beforeEach(async ({ page }) => {
@ -9,164 +9,60 @@ test.describe("Chat activity", () => {
await chatPage.createNewChat();
});
test("Send a user message and receive response", async () => {
await chatPage.sendUserMessage("Why is grass green?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toContain("It's just green duh!");
test("page loads with input ready", async () => {
await chatPage.waitForInputToBeReady();
});
test("Redirect to /chat/:id after submitting message", async () => {
await chatPage.sendUserMessage("Why is grass green?");
test("send button is disabled when input is empty", async () => {
await expect(chatPage.sendButton).toBeDisabled();
});
test("send button is enabled when input has text", async () => {
await chatPage.multimodalInput.fill("Hello");
await expect(chatPage.sendButton).toBeEnabled();
});
test("can send a message and receive a response", async () => {
await chatPage.sendUserMessage("Hello");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toContain("It's just green duh!");
const userContent = await chatPage.getLastUserMessageContent();
expect(userContent).toBe("Hello");
const assistantContent = await chatPage.getLastAssistantMessageContent();
expect(assistantContent).toBeTruthy();
});
test("redirects to /chat/:id after sending message", async () => {
await chatPage.sendUserMessage("Hello");
await chatPage.isGenerationComplete();
await chatPage.hasChatIdInUrl();
});
test("Send a user message from suggestion", async () => {
await chatPage.sendUserMessageFromSuggestion();
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toContain(
"With Next.js, you can ship fast!"
);
test("shows stop button during generation", async () => {
await chatPage.multimodalInput.fill("Hello");
await chatPage.sendButton.click();
await expect(chatPage.stopButton).toBeVisible({ timeout: 5000 });
});
test("Toggle between send/stop button based on activity", async () => {
await expect(chatPage.sendButton).toBeVisible();
await expect(chatPage.sendButton).toBeDisabled();
await chatPage.sendUserMessage("Why is grass green?");
await expect(chatPage.sendButton).not.toBeVisible();
await expect(chatPage.stopButton).toBeVisible();
await chatPage.isGenerationComplete();
await expect(chatPage.stopButton).not.toBeVisible();
await expect(chatPage.sendButton).toBeVisible();
});
test("Stop generation during submission", async () => {
await chatPage.sendUserMessage("Why is grass green?");
await expect(chatPage.stopButton).toBeVisible();
test("can stop generation", async () => {
await chatPage.multimodalInput.fill("Hello");
await chatPage.sendButton.click();
await expect(chatPage.stopButton).toBeVisible({ timeout: 5000 });
await chatPage.stopButton.click();
await expect(chatPage.sendButton).toBeVisible();
});
test("Edit user message and resubmit", async () => {
await chatPage.sendUserMessage("Why is grass green?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toContain("It's just green duh!");
const userMessage = await chatPage.getRecentUserMessage();
await userMessage.edit("Why is the sky blue?");
await chatPage.isGenerationComplete();
const updatedAssistantMessage = await chatPage.getRecentAssistantMessage();
expect(updatedAssistantMessage.content).toContain("It's just blue duh!");
});
test("Hide suggested actions after sending message", async () => {
await chatPage.isElementVisible("suggested-actions");
await chatPage.sendUserMessageFromSuggestion();
await chatPage.isElementNotVisible("suggested-actions");
});
test("Upload file and send image attachment with message", async () => {
await chatPage.addImageAttachment();
await chatPage.isElementVisible("attachments-preview");
await chatPage.isElementVisible("input-attachment-loader");
await chatPage.isElementNotVisible("input-attachment-loader");
await chatPage.sendUserMessage("Who painted this?");
const userMessage = await chatPage.getRecentUserMessage();
expect(userMessage.attachments).toHaveLength(1);
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toBe("This painting is by Monet!");
});
test("Call weather tool", async () => {
await chatPage.sendUserMessage("What's the weather in sf?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toBe(
"The current temperature in San Francisco is 17°C."
);
});
test("Upvote message", async () => {
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
await assistantMessage.upvote();
await chatPage.isVoteComplete();
});
test("Downvote message", async () => {
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
await assistantMessage.downvote();
await chatPage.isVoteComplete();
});
test("Update vote", async () => {
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
await assistantMessage.upvote();
await chatPage.isVoteComplete();
await assistantMessage.downvote();
await chatPage.isVoteComplete();
});
test("Create message from url query", async ({ page }) => {
await page.goto("/?query=Why is the sky blue?");
await chatPage.isGenerationComplete();
const userMessage = await chatPage.getRecentUserMessage();
expect(userMessage.content).toBe("Why is the sky blue?");
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toContain("It's just blue duh!");
});
test("auto-scrolls to bottom after submitting new messages", async () => {
test.fixme();
await chatPage.sendMultipleMessages(5, (i) => `filling message #${i}`);
await chatPage.waitForScrollToBottom();
});
test("scroll button appears when user scrolls up, hides on click", async () => {
test.fixme();
await chatPage.sendMultipleMessages(5, (i) => `filling message #${i}`);
await expect(chatPage.scrollToBottomButton).not.toBeVisible();
await chatPage.scrollToTop();
await expect(chatPage.scrollToBottomButton).toBeVisible();
await chatPage.scrollToBottomButton.click();
await chatPage.waitForScrollToBottom();
await expect(chatPage.scrollToBottomButton).not.toBeVisible();
await expect(chatPage.sendButton).toBeVisible({ timeout: 5000 });
});
});
test.describe("Chat - Guest User", () => {
test("can use chat as guest", async ({ page }) => {
const chatPage = new ChatPage(page);
await chatPage.createNewChat();
await chatPage.waitForInputToBeReady();
await chatPage.sendUserMessage("Hello");
await chatPage.isGenerationComplete();
const content = await chatPage.getLastAssistantMessageContent();
expect(content).toBeTruthy();
});
});