fix last session

This commit is contained in:
2026-01-21 14:26:30 -05:00
parent 3d5ae8efca
commit 051e3dfcb4
28 changed files with 699 additions and 1295 deletions
+74
View File
@@ -1,6 +1,80 @@
import { test, expect } from '@playwright/test';
test.describe('Claude Permissions Workflow', () => {
test('vibrates on mobile when permission request is received', async ({ page }) => {
// Increase timeout for this test since it involves real Claude interaction
test.setTimeout(180000);
// Mock navigator.vibrate and track calls
await page.addInitScript(() => {
(window as unknown as { vibrateCalls: number[][] }).vibrateCalls = [];
navigator.vibrate = (pattern: VibratePattern) => {
const patternArray = Array.isArray(pattern) ? pattern : [pattern];
(window as unknown as { vibrateCalls: number[][] }).vibrateCalls.push(patternArray);
return true;
};
});
// Enable console logging for debugging
page.on('console', (msg) => {
console.log(`[Browser ${msg.type()}]`, msg.text());
});
// 1. Navigate to homepage
await page.goto('/');
await expect(page).toHaveTitle(/Spiceflow/i);
// 2. Click the + button to open new session menu
const createButton = page.locator('button[title="New Session"]');
await expect(createButton).toBeVisible();
await createButton.click();
// 3. Select Claude Code from the dropdown
const claudeOption = page.locator('button:has-text("Claude Code")');
await expect(claudeOption).toBeVisible();
await claudeOption.click();
// 4. Wait for navigation to session page
await page.waitForURL(/\/session\/.+/);
console.log('[Test] Navigated to session page:', page.url());
// 5. Wait for the page to load
await expect(page.locator('text=Loading')).not.toBeVisible({ timeout: 5000 });
await expect(page.locator('text=No messages yet')).toBeVisible();
// 6. Send message asking Claude to create a file (which will trigger permission)
const textarea = page.locator('textarea');
await expect(textarea).toBeVisible();
await textarea.fill(
'Create a file called vibrate-test.md containing just "test". No other commentary.'
);
const sendButton = page.locator('button[type="submit"]');
await expect(sendButton).toBeEnabled();
await sendButton.click();
// 7. Wait for permission request UI to appear
const permissionUI = page.locator('text=Claude needs permission');
await expect(permissionUI).toBeVisible({ timeout: 60000 });
console.log('[Test] Permission request UI appeared');
// 8. Check that vibrate was called with the expected pattern
const vibrateCalls = await page.evaluate(() => {
return (window as unknown as { vibrateCalls: number[][] }).vibrateCalls;
});
console.log('[Test] Vibrate calls:', vibrateCalls);
expect(vibrateCalls.length).toBeGreaterThan(0);
expect(vibrateCalls[0]).toEqual([200, 100, 200]);
console.log('[Test] Vibration triggered correctly with pattern [200, 100, 200]');
// Cleanup: Accept and let Claude finish
const acceptButton = page.locator('button:has-text("Accept")');
await acceptButton.click();
await expect(permissionUI).not.toBeVisible({ timeout: 10000 });
});
test('permission approval allows file creation and reading', async ({ page }) => {
// Increase timeout for this test since it involves real Claude interaction
test.setTimeout(180000);