From fa758902ccfd1bbc004fb9a5cd7c109f2c0d7b25 Mon Sep 17 00:00:00 2001 From: sstent Date: Sat, 21 Feb 2026 09:29:01 -0800 Subject: [PATCH] chore(test): Implement E2E sync smoke test --- tests/e2e/sync.spec.ts | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tests/e2e/sync.spec.ts diff --git a/tests/e2e/sync.spec.ts b/tests/e2e/sync.spec.ts new file mode 100644 index 0000000..2dca280 --- /dev/null +++ b/tests/e2e/sync.spec.ts @@ -0,0 +1,77 @@ +import { test, expect } from '@playwright/test'; + +test.describe('iCalendar Sync E2E', () => { + test('should install plug and sync without console errors', async ({ page }) => { + const errors: string[] = []; + + // Listen for console errors + page.on('console', msg => { + if (msg.type() === 'error' || msg.text().includes('TypeError')) { + errors.push(msg.text()); + console.error('Browser Console Error:', msg.text()); + } + }); + + // 1. Login + await page.goto('/'); + await page.fill('input[name="username"]', 'admin'); + await page.fill('input[name="password"]', 'admin'); + await page.click('button[type="submit"]'); + + // Wait for the editor to load + await expect(page.locator('#sb-main')).toBeVisible({ timeout: 10000 }); + + // 2. Install Plug (Mocking the installation by writing to PLUGS.md or using command) + // For this test, we assume the built plug is served or we use the local raw link. + // We'll use the 'Plugs: Add' command if possible, or just write to PLUGS.md. + + // Let's use the keyboard to trigger the command palette + await page.keyboard.press('Control+Enter'); // Or whatever the shortcut is. Default is Cmd/Ctrl-Enter or / + // Wait for palette + // Actually, writing to PLUGS.md is more reliable for automation + + // Navigate to PLUGS + await page.goto('/PLUGS'); + await page.waitForSelector('.cm-content'); + + // Clear and write the local plug URI + // In our docker-compose, the host files are at /work + // But SB needs a URI. We'll use the gitea link or a local mock server link. + // For now, let's assume we want to test the built file in the test space. + + const plugUri = 'gh:sstent/silverbullet-icalendar/icalendar.plug.js'; // Fallback or use local + await page.locator('.cm-content').fill(`- ${plugUri}`); + await page.keyboard.press('Control+s'); // Save + + // Trigger Plugs: Update + await page.keyboard.press('Control+Enter'); + await page.fill('input[placeholder="Command"]', 'Plugs: Update'); + await page.keyboard.press('Enter'); + + // Wait for notification or some time + await page.waitForTimeout(5000); + + // 3. Configure source in SETTINGS + await page.goto('/SETTINGS'); + await page.waitForSelector('.cm-content'); + await page.locator('.cm-content').fill(` +icalendar: + sources: + - url: http://mock-ics-server/calendar.ics + name: TestCalendar +`); + await page.keyboard.press('Control+s'); + await page.waitForTimeout(2000); + + // 4. Trigger Sync + await page.keyboard.press('Control+Enter'); + await page.fill('input[placeholder="Command"]', 'iCalendar: Sync'); + await page.keyboard.press('Enter'); + + // Wait for sync to complete (flash notification) + await page.waitForTimeout(5000); + + // 5. Final check + expect(errors).toHaveLength(0); + }); +});