forked from GitHubMirrors/silverbullet-icalendar
78 lines
2.8 KiB
TypeScript
78 lines
2.8 KiB
TypeScript
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);
|
|
});
|
|
});
|