Restore Ultracite + fix sidebar (#1233)

This commit is contained in:
Hayden Bleasel 2025-09-21 11:02:31 -07:00 committed by GitHub
parent 8fbfc253fa
commit 947ed094a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
177 changed files with 6908 additions and 8306 deletions

View file

@ -1,8 +1,8 @@
import { expect, test } from '../fixtures';
import { ChatPage } from '../pages/chat';
import { ArtifactPage } from '../pages/artifact';
import { expect, test } from "../fixtures";
import { ArtifactPage } from "../pages/artifact";
import { ChatPage } from "../pages/chat";
test.describe('Artifacts activity', () => {
test.describe("Artifacts activity", () => {
let chatPage: ChatPage;
let artifactPage: ArtifactPage;
@ -13,12 +13,12 @@ test.describe('Artifacts activity', () => {
await chatPage.createNewChat();
});
test('Create a text artifact', async () => {
test("Create a text artifact", async () => {
test.fixme();
await chatPage.createNewChat();
await chatPage.sendUserMessage(
'Help me write an essay about Silicon Valley',
"Help me write an essay about Silicon Valley"
);
await artifactPage.isGenerationComplete();
@ -26,18 +26,18 @@ test.describe('Artifacts activity', () => {
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toBe(
'A document was created and is now visible to the user.',
"A document was created and is now visible to the user."
);
await chatPage.hasChatIdInUrl();
});
test('Toggle artifact visibility', async () => {
test("Toggle artifact visibility", async () => {
test.fixme();
await chatPage.createNewChat();
await chatPage.sendUserMessage(
'Help me write an essay about Silicon Valley',
"Help me write an essay about Silicon Valley"
);
await artifactPage.isGenerationComplete();
@ -45,19 +45,19 @@ test.describe('Artifacts activity', () => {
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toBe(
'A document was created and is now visible to the user.',
"A document was created and is now visible to the user."
);
await artifactPage.closeArtifact();
await chatPage.isElementNotVisible('artifact');
await chatPage.isElementNotVisible("artifact");
});
test('Send follow up message after generation', async () => {
test("Send follow up message after generation", async () => {
test.fixme();
await chatPage.createNewChat();
await chatPage.sendUserMessage(
'Help me write an essay about Silicon Valley',
"Help me write an essay about Silicon Valley"
);
await artifactPage.isGenerationComplete();
@ -65,10 +65,10 @@ test.describe('Artifacts activity', () => {
const assistantMessage = await artifactPage.getRecentAssistantMessage();
expect(assistantMessage.content).toBe(
'A document was created and is now visible to the user.',
"A document was created and is now visible to the user."
);
await artifactPage.sendUserMessage('Thanks!');
await artifactPage.sendUserMessage("Thanks!");
await artifactPage.isGenerationComplete();
const secondAssistantMessage = await chatPage.getRecentAssistantMessage();

View file

@ -1,7 +1,7 @@
import { ChatPage } from '../pages/chat';
import { test, expect } from '../fixtures';
import { expect, test } from "../fixtures";
import { ChatPage } from "../pages/chat";
test.describe('Chat activity', () => {
test.describe("Chat activity", () => {
let chatPage: ChatPage;
test.beforeEach(async ({ page }) => {
@ -9,16 +9,16 @@ test.describe('Chat activity', () => {
await chatPage.createNewChat();
});
test('Send a user message and receive response', async () => {
await chatPage.sendUserMessage('Why is grass green?');
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('Redirect to /chat/:id after submitting message', async () => {
await chatPage.sendUserMessage('Why is grass green?');
test("Redirect to /chat/:id after submitting message", async () => {
await chatPage.sendUserMessage("Why is grass green?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
@ -26,21 +26,21 @@ test.describe('Chat activity', () => {
await chatPage.hasChatIdInUrl();
});
test('Send a user message from suggestion', async () => {
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!',
"With Next.js, you can ship fast!"
);
});
test('Toggle between send/stop button based on activity', async () => {
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 chatPage.sendUserMessage("Why is grass green?");
await expect(chatPage.sendButton).not.toBeVisible();
await expect(chatPage.stopButton).toBeVisible();
@ -51,22 +51,22 @@ test.describe('Chat activity', () => {
await expect(chatPage.sendButton).toBeVisible();
});
test('Stop generation during submission', async () => {
await chatPage.sendUserMessage('Why is grass green?');
test("Stop generation during submission", async () => {
await chatPage.sendUserMessage("Why is grass green?");
await expect(chatPage.stopButton).toBeVisible();
await chatPage.stopButton.click();
await expect(chatPage.sendButton).toBeVisible();
});
test('Edit user message and resubmit', async () => {
await chatPage.sendUserMessage('Why is grass green?');
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 userMessage.edit("Why is the sky blue?");
await chatPage.isGenerationComplete();
@ -74,20 +74,20 @@ test.describe('Chat activity', () => {
expect(updatedAssistantMessage.content).toContain("It's just blue duh!");
});
test('Hide suggested actions after sending message', async () => {
await chatPage.isElementVisible('suggested-actions');
test("Hide suggested actions after sending message", async () => {
await chatPage.isElementVisible("suggested-actions");
await chatPage.sendUserMessageFromSuggestion();
await chatPage.isElementNotVisible('suggested-actions');
await chatPage.isElementNotVisible("suggested-actions");
});
test('Upload file and send image attachment with message', async () => {
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.isElementVisible("attachments-preview");
await chatPage.isElementVisible("input-attachment-loader");
await chatPage.isElementNotVisible("input-attachment-loader");
await chatPage.sendUserMessage('Who painted this?');
await chatPage.sendUserMessage("Who painted this?");
const userMessage = await chatPage.getRecentUserMessage();
expect(userMessage.attachments).toHaveLength(1);
@ -95,22 +95,22 @@ test.describe('Chat activity', () => {
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toBe('This painting is by Monet!');
expect(assistantMessage.content).toBe("This painting is by Monet!");
});
test('Call weather tool', async () => {
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.',
"The current temperature in San Francisco is 17°C."
);
});
test('Upvote message', async () => {
await chatPage.sendUserMessage('Why is the sky blue?');
test("Upvote message", async () => {
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
@ -118,8 +118,8 @@ test.describe('Chat activity', () => {
await chatPage.isVoteComplete();
});
test('Downvote message', async () => {
await chatPage.sendUserMessage('Why is the sky blue?');
test("Downvote message", async () => {
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
@ -127,8 +127,8 @@ test.describe('Chat activity', () => {
await chatPage.isVoteComplete();
});
test('Update vote', async () => {
await chatPage.sendUserMessage('Why is the sky blue?');
test("Update vote", async () => {
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
@ -139,25 +139,25 @@ test.describe('Chat activity', () => {
await chatPage.isVoteComplete();
});
test('Create message from url query', async ({ page }) => {
await page.goto('/?query=Why is the sky blue?');
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?');
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("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("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();

View file

@ -1,7 +1,7 @@
import { ChatPage } from '../pages/chat';
import { test, expect } from '../fixtures';
import { expect, test } from "../fixtures";
import { ChatPage } from "../pages/chat";
test.describe('chat activity with reasoning', () => {
test.describe("chat activity with reasoning", () => {
let chatPage: ChatPage;
test.beforeEach(async ({ curieContext }) => {
@ -9,25 +9,25 @@ test.describe('chat activity with reasoning', () => {
await chatPage.createNewChat();
});
test('Curie can send message and generate response with reasoning', async () => {
await chatPage.sendUserMessage('Why is the sky blue?');
test("Curie can send message and generate response with reasoning", async () => {
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
expect(assistantMessage.content).toBe("It's just blue duh!");
expect(assistantMessage.reasoning).toBe(
'The sky is blue because of rayleigh scattering!',
"The sky is blue because of rayleigh scattering!"
);
});
test('Curie can toggle reasoning visibility', async () => {
await chatPage.sendUserMessage('Why is the sky blue?');
test("Curie can toggle reasoning visibility", async () => {
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
const reasoningElement =
assistantMessage.element.getByTestId('message-reasoning');
assistantMessage.element.getByTestId("message-reasoning");
expect(reasoningElement).toBeVisible();
await assistantMessage.toggleReasoningVisibility();
@ -37,18 +37,18 @@ test.describe('chat activity with reasoning', () => {
await expect(reasoningElement).toBeVisible();
});
test('Curie can edit message and resubmit', async () => {
await chatPage.sendUserMessage('Why is the sky blue?');
test("Curie can edit message and resubmit", async () => {
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
const assistantMessage = await chatPage.getRecentAssistantMessage();
const reasoningElement =
assistantMessage.element.getByTestId('message-reasoning');
assistantMessage.element.getByTestId("message-reasoning");
expect(reasoningElement).toBeVisible();
const userMessage = await chatPage.getRecentUserMessage();
await userMessage.edit('Why is grass green?');
await userMessage.edit("Why is grass green?");
await chatPage.isGenerationComplete();
const updatedAssistantMessage = await chatPage.getRecentAssistantMessage();
@ -56,7 +56,7 @@ test.describe('chat activity with reasoning', () => {
expect(updatedAssistantMessage.content).toBe("It's just green duh!");
expect(updatedAssistantMessage.reasoning).toBe(
'Grass is green because of chlorophyll absorption!',
"Grass is green because of chlorophyll absorption!"
);
});
});

View file

@ -1,23 +1,23 @@
import { expect, test } from '../fixtures';
import { AuthPage } from '../pages/auth';
import { generateRandomTestUser } from '../helpers';
import { ChatPage } from '../pages/chat';
import { getMessageByErrorCode } from '@/lib/errors';
import { getMessageByErrorCode } from "@/lib/errors";
import { expect, test } from "../fixtures";
import { generateRandomTestUser } from "../helpers";
import { AuthPage } from "../pages/auth";
import { ChatPage } from "../pages/chat";
test.describe
.serial('Guest Session', () => {
test('Authenticate as guest user when a new session is loaded', async ({
.serial("Guest Session", () => {
test("Authenticate as guest user when a new session is loaded", async ({
page,
}) => {
const response = await page.goto('/');
const response = await page.goto("/");
if (!response) {
throw new Error('Failed to load page');
throw new Error("Failed to load page");
}
let request = response.request();
const chain = [];
const chain: string[] = [];
while (request) {
chain.unshift(request.url());
@ -25,185 +25,185 @@ test.describe
}
expect(chain).toEqual([
'http://localhost:3000/',
'http://localhost:3000/api/auth/guest?redirectUrl=http%3A%2F%2Flocalhost%3A3000%2F',
'http://localhost:3000/',
"http://localhost:3000/",
"http://localhost:3000/api/auth/guest?redirectUrl=http%3A%2F%2Flocalhost%3A3000%2F",
"http://localhost:3000/",
]);
});
test('Log out is not available for guest users', async ({ page }) => {
await page.goto('/');
test("Log out is not available for guest users", async ({ page }) => {
await page.goto("/");
const sidebarToggleButton = page.getByTestId('sidebar-toggle-button');
const sidebarToggleButton = page.getByTestId("sidebar-toggle-button");
await sidebarToggleButton.click();
const userNavButton = page.getByTestId('user-nav-button');
const userNavButton = page.getByTestId("user-nav-button");
await expect(userNavButton).toBeVisible();
await userNavButton.click();
const userNavMenu = page.getByTestId('user-nav-menu');
const userNavMenu = page.getByTestId("user-nav-menu");
await expect(userNavMenu).toBeVisible();
const authMenuItem = page.getByTestId('user-nav-item-auth');
await expect(authMenuItem).toContainText('Login to your account');
const authMenuItem = page.getByTestId("user-nav-item-auth");
await expect(authMenuItem).toContainText("Login to your account");
});
test('Do not authenticate as guest user when an existing non-guest session is active', async ({
test("Do not authenticate as guest user when an existing non-guest session is active", async ({
adaContext,
}) => {
const response = await adaContext.page.goto('/');
const response = await adaContext.page.goto("/");
if (!response) {
throw new Error('Failed to load page');
throw new Error("Failed to load page");
}
let request = response.request();
const chain = [];
const chain: string[] = [];
while (request) {
chain.unshift(request.url());
request = request.redirectedFrom();
}
expect(chain).toEqual(['http://localhost:3000/']);
expect(chain).toEqual(["http://localhost:3000/"]);
});
test('Allow navigating to /login as guest user', async ({ page }) => {
await page.goto('/login');
await page.waitForURL('/login');
await expect(page).toHaveURL('/login');
test("Allow navigating to /login as guest user", async ({ page }) => {
await page.goto("/login");
await page.waitForURL("/login");
await expect(page).toHaveURL("/login");
});
test('Allow navigating to /register as guest user', async ({ page }) => {
await page.goto('/register');
await page.waitForURL('/register');
await expect(page).toHaveURL('/register');
test("Allow navigating to /register as guest user", async ({ page }) => {
await page.goto("/register");
await page.waitForURL("/register");
await expect(page).toHaveURL("/register");
});
test('Do not show email in user menu for guest user', async ({ page }) => {
await page.goto('/');
test("Do not show email in user menu for guest user", async ({ page }) => {
await page.goto("/");
const sidebarToggleButton = page.getByTestId('sidebar-toggle-button');
const sidebarToggleButton = page.getByTestId("sidebar-toggle-button");
await sidebarToggleButton.click();
const userEmail = page.getByTestId('user-email');
await expect(userEmail).toContainText('Guest');
const userEmail = page.getByTestId("user-email");
await expect(userEmail).toContainText("Guest");
});
});
test.describe
.serial('Login and Registration', () => {
.serial("Login and Registration", () => {
let authPage: AuthPage;
const testUser = generateRandomTestUser();
test.beforeEach(async ({ page }) => {
test.beforeEach(({ page }) => {
authPage = new AuthPage(page);
});
test('Register new account', async () => {
test("Register new account", async () => {
await authPage.register(testUser.email, testUser.password);
await authPage.expectToastToContain('Account created successfully!');
await authPage.expectToastToContain("Account created successfully!");
});
test('Register new account with existing email', async () => {
test("Register new account with existing email", async () => {
await authPage.register(testUser.email, testUser.password);
await authPage.expectToastToContain('Account already exists!');
await authPage.expectToastToContain("Account already exists!");
});
test('Log into account that exists', async ({ page }) => {
test("Log into account that exists", async ({ page }) => {
await authPage.login(testUser.email, testUser.password);
await page.waitForURL('/');
await expect(page.getByPlaceholder('Send a message...')).toBeVisible();
await page.waitForURL("/");
await expect(page.getByPlaceholder("Send a message...")).toBeVisible();
});
test('Display user email in user menu', async ({ page }) => {
test("Display user email in user menu", async ({ page }) => {
await authPage.login(testUser.email, testUser.password);
await page.waitForURL('/');
await expect(page.getByPlaceholder('Send a message...')).toBeVisible();
await page.waitForURL("/");
await expect(page.getByPlaceholder("Send a message...")).toBeVisible();
const userEmail = await page.getByTestId('user-email');
const userEmail = await page.getByTestId("user-email");
await expect(userEmail).toHaveText(testUser.email);
});
test('Log out as non-guest user', async () => {
test("Log out as non-guest user", async () => {
await authPage.logout(testUser.email, testUser.password);
});
test('Do not force create a guest session if non-guest session already exists', async ({
test("Do not force create a guest session if non-guest session already exists", async ({
page,
}) => {
await authPage.login(testUser.email, testUser.password);
await page.waitForURL('/');
await page.waitForURL("/");
const userEmail = await page.getByTestId('user-email');
const userEmail = await page.getByTestId("user-email");
await expect(userEmail).toHaveText(testUser.email);
await page.goto('/api/auth/guest');
await page.waitForURL('/');
await page.goto("/api/auth/guest");
await page.waitForURL("/");
const updatedUserEmail = await page.getByTestId('user-email');
const updatedUserEmail = await page.getByTestId("user-email");
await expect(updatedUserEmail).toHaveText(testUser.email);
});
test('Log out is available for non-guest users', async ({ page }) => {
test("Log out is available for non-guest users", async ({ page }) => {
await authPage.login(testUser.email, testUser.password);
await page.waitForURL('/');
await page.waitForURL("/");
authPage.openSidebar();
const userNavButton = page.getByTestId('user-nav-button');
const userNavButton = page.getByTestId("user-nav-button");
await expect(userNavButton).toBeVisible();
await userNavButton.click();
const userNavMenu = page.getByTestId('user-nav-menu');
const userNavMenu = page.getByTestId("user-nav-menu");
await expect(userNavMenu).toBeVisible();
const authMenuItem = page.getByTestId('user-nav-item-auth');
await expect(authMenuItem).toContainText('Sign out');
const authMenuItem = page.getByTestId("user-nav-item-auth");
await expect(authMenuItem).toContainText("Sign out");
});
test('Do not navigate to /register for non-guest users', async ({
test("Do not navigate to /register for non-guest users", async ({
page,
}) => {
await authPage.login(testUser.email, testUser.password);
await page.waitForURL('/');
await page.waitForURL("/");
await page.goto('/register');
await expect(page).toHaveURL('/');
await page.goto("/register");
await expect(page).toHaveURL("/");
});
test('Do not navigate to /login for non-guest users', async ({ page }) => {
test("Do not navigate to /login for non-guest users", async ({ page }) => {
await authPage.login(testUser.email, testUser.password);
await page.waitForURL('/');
await page.waitForURL("/");
await page.goto('/login');
await expect(page).toHaveURL('/');
await page.goto("/login");
await expect(page).toHaveURL("/");
});
});
test.describe('Entitlements', () => {
test.describe("Entitlements", () => {
let chatPage: ChatPage;
test.beforeEach(async ({ page }) => {
test.beforeEach(({ page }) => {
chatPage = new ChatPage(page);
});
test('Guest user cannot send more than 20 messages/day', async () => {
test("Guest user cannot send more than 20 messages/day", async () => {
test.fixme();
await chatPage.createNewChat();
for (let i = 0; i <= 20; i++) {
await chatPage.sendUserMessage('Why is the sky blue?');
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.isGenerationComplete();
}
await chatPage.sendUserMessage('Why is the sky blue?');
await chatPage.sendUserMessage("Why is the sky blue?");
await chatPage.expectToastToContain(
getMessageByErrorCode('rate_limit:chat'),
getMessageByErrorCode("rate_limit:chat")
);
});
});