Skip to content

Commit fddea5d

Browse files
committed
test(e2e): add mobile mode test suite
Tests core functionality with Obsidian's mobile emulation enabled and a narrow viewport (390x844). Verifies commands, calendar view, task modal, and kanban board work correctly in mobile mode.
1 parent 4202947 commit fddea5d

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

e2e/tasknotes.spec.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,3 +2414,123 @@ test.describe('Hierarchical Tag Coloring', () => {
24142414
}
24152415
});
24162416
});
2417+
2418+
test.describe('Mobile Mode', () => {
2419+
let originalViewportSize: { width: number; height: number } | null = null;
2420+
2421+
test.beforeAll(async () => {
2422+
const page = getPage();
2423+
2424+
// Save original viewport size
2425+
originalViewportSize = page.viewportSize();
2426+
2427+
// Set mobile viewport (iPhone 14 / modern phone dimensions)
2428+
await page.setViewportSize({ width: 390, height: 844 });
2429+
2430+
// Enable mobile emulation
2431+
await page.evaluate(() => {
2432+
(window as any).app.emulateMobile(true);
2433+
});
2434+
await page.waitForTimeout(1000);
2435+
});
2436+
2437+
test.afterAll(async () => {
2438+
const page = getPage();
2439+
2440+
// Disable mobile emulation
2441+
await page.evaluate(() => {
2442+
(window as any).app.emulateMobile(false);
2443+
});
2444+
2445+
// Restore original viewport size
2446+
if (originalViewportSize) {
2447+
await page.setViewportSize(originalViewportSize);
2448+
}
2449+
await page.waitForTimeout(500);
2450+
});
2451+
2452+
test('should detect mobile mode via Platform API', async () => {
2453+
const page = getPage();
2454+
2455+
const isMobile = await page.evaluate(() => {
2456+
return (window as any).app.isMobile;
2457+
});
2458+
2459+
expect(isMobile).toBe(true);
2460+
});
2461+
2462+
test('should show TaskNotes commands in mobile mode', async () => {
2463+
const page = getPage();
2464+
2465+
await openCommandPalette(page);
2466+
await page.keyboard.type('tasknotes', { delay: 30 });
2467+
await page.waitForTimeout(500);
2468+
2469+
const suggestions = page.locator('.suggestion-item');
2470+
await expect(suggestions.first()).toBeVisible({ timeout: 5000 });
2471+
2472+
const count = await suggestions.count();
2473+
expect(count).toBeGreaterThan(0);
2474+
2475+
await page.keyboard.press('Escape');
2476+
});
2477+
2478+
test('should open calendar view in mobile mode', async () => {
2479+
const page = getPage();
2480+
2481+
await runCommand(page, 'Open calendar');
2482+
await page.waitForTimeout(1500);
2483+
2484+
// Verify calendar view is visible
2485+
const calendarView = page.locator('.tasknotes-calendar-view, .fc, .fc-view');
2486+
await expect(calendarView.first()).toBeVisible({ timeout: 10000 });
2487+
2488+
await page.screenshot({ path: 'test-results/screenshots/mobile-calendar-view.png' });
2489+
});
2490+
2491+
test('should open task creation modal in mobile mode', async () => {
2492+
const page = getPage();
2493+
2494+
await runCommand(page, 'Create new task');
2495+
await page.waitForTimeout(1000);
2496+
2497+
// Verify modal is visible
2498+
const modal = page.locator('.modal, .tasknotes-task-modal');
2499+
await expect(modal.first()).toBeVisible({ timeout: 5000 });
2500+
2501+
await page.screenshot({ path: 'test-results/screenshots/mobile-task-modal.png' });
2502+
2503+
// Close the modal
2504+
await page.keyboard.press('Escape');
2505+
await page.waitForTimeout(500);
2506+
});
2507+
2508+
test('should open kanban board in mobile mode', async () => {
2509+
const page = getPage();
2510+
2511+
await runCommand(page, 'Open kanban board');
2512+
await page.waitForTimeout(1500);
2513+
2514+
// Verify kanban view is visible (uses kanban-view__column class)
2515+
const kanbanView = page.locator('.kanban-view__column, .bases-view');
2516+
await expect(kanbanView.first()).toBeVisible({ timeout: 10000 });
2517+
2518+
await page.screenshot({ path: 'test-results/screenshots/mobile-kanban-view.png' });
2519+
});
2520+
2521+
test('should display mobile-specific UI elements', async () => {
2522+
const page = getPage();
2523+
2524+
// Take a screenshot to document mobile UI state
2525+
await page.screenshot({ path: 'test-results/screenshots/mobile-ui-overview.png', fullPage: true });
2526+
2527+
// Check for mobile-specific body class or attribute
2528+
const hasMobileClass = await page.evaluate(() => {
2529+
return document.body.classList.contains('is-mobile') ||
2530+
document.body.hasAttribute('data-mobile');
2531+
});
2532+
2533+
// Log the result (may or may not have specific class depending on Obsidian version)
2534+
console.log('Has mobile-specific class/attribute:', hasMobileClass);
2535+
});
2536+
});

0 commit comments

Comments
 (0)