Something went wrong. Try again.
A local-first note taking app
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677import { test, expect } from '@playwright/test';import { launchApp, resetWorkspace, type LaunchedApp, openNote, scroller,} from './appFixture';
test.describe('heading navigation', () => { let app: LaunchedApp; let window: LaunchedApp['window'];
test.beforeAll(async () => { app = await launchApp(); window = app.window; }); test.afterAll(async () => { await app.close(); }); test.beforeEach(async () => { await resetWorkspace(app); });
test('following [[Note#Heading]] scrolls that heading to the top', async () => { await openNote(window, 'Source.md');
// Display text: the brackets are hidden while the cursor is elsewhere. const link = window .locator('.cm-wikilink', { hasText: 'Target#Middle Section' }) .first(); await expect(link).toBeVisible(); // Edit mode opens on cmd/ctrl-click; a plain click just moves the caret. await link.click({ modifiers: [process.platform === 'darwin' ? 'Meta' : 'Control'], });
// Guards: a scroll dispatched before the view has height is dropped. await expect .poll(() => scroller(window).evaluate((el) => el.scrollTop)) .toBeGreaterThan(0);
const heading = window .locator('.cm-line', { hasText: 'Middle Section' }) .first(); const headingBox = await heading.boundingBox(); const scrollerBox = await scroller(window).boundingBox(); expect(headingBox).not.toBeNull(); expect(scrollerBox).not.toBeNull(); expect(headingBox!.y - scrollerBox!.y).toBeLessThan(80); });
test('a plain [[Note]] link opens at the top', async () => { await openNote(window, 'Source.md'); const link = window .locator('.cm-wikilink', { hasText: /^Target$/ }) .first(); await link.click({ modifiers: [process.platform === 'darwin' ? 'Meta' : 'Control'], }); await expect(window.locator('.cm-content').first()).toContainText( 'intro body line 1', ); expect(await scroller(window).evaluate((el) => el.scrollTop)).toBe(0); });
test('renders a heading link with the `#` separator intact', async () => { await openNote(window, 'Source.md'); // Without the separator this collapsed to `TargetMiddle Section`. await expect( window .locator('.cm-wikilink', { hasText: 'Target#Middle Section' }) .first(), ).toBeVisible(); });});