From 18b492103ccdb2863275d73ab00d49abd81aa12a Mon Sep 17 00:00:00 2001 From: linonetwo Date: Thu, 3 Oct 2024 23:36:44 +0800 Subject: [PATCH] test: Engaging the search input, The tiddler should be opened and operational, allow clicking link to navigate to block mark --- editions/test/playwright.spec.js | 33 +++++++++++++++++++ .../tiddlers/tests/data/block-mark/Links.tid | 3 ++ .../tiddlers/tests/data/block-mark/Marks.tid | 5 +++ 3 files changed, 41 insertions(+) create mode 100644 editions/test/tiddlers/tests/data/block-mark/Links.tid create mode 100644 editions/test/tiddlers/tests/data/block-mark/Marks.tid diff --git a/editions/test/playwright.spec.js b/editions/test/playwright.spec.js index 1d8c624c7..569a58bd6 100644 --- a/editions/test/playwright.spec.js +++ b/editions/test/playwright.spec.js @@ -22,4 +22,37 @@ test('get started link', async ({ page }) => { // Assert the tests have passed await expect(page.locator('.jasmine-overall-result.jasmine-failed'), "Expected jasmine tests to not have failed").not.toBeVisible(); await expect(page.locator('.jasmine-overall-result.jasmine-passed'), "Expected jasmine tests to have passed").toBeVisible(); + +test('Search tiddler with link and navigate to block mark', async ({ page }) => { + const timeout = 1000 * 30; + test.setTimeout(timeout); + await page.goto(`file:///${crossPlatformIndexPath}`); + + // Engaging the search input + // Search in default search box + await page.fill('input[type="search"]', 'BlockMark/Links'); + // click on link in search results inside the dropdown + await page.click('div.tc-search-drop-down a:has-text("BlockMark/Links")'); + // wait for link to appear and check its href + const searchResultLink = page.locator('a:has-text("Block Level Links in WikiText")'); + await expect(searchResultLink, "Search result link presented").toBeVisible({timeout}); + await expect(searchResultLink, "Search result link have correct href").toHaveAttribute('href', '#BlockMark%2FMarks-BlockLevelLinksID1'); + // click on this link + await page.click('a:has-text("Block Level Links in WikiText")'); + + // The tiddler should be opened and operational, allow clicking link to navigate to block mark + // wait for tiddler to appear and the block focused, and check its properties + const blockMarkedText = page.locator('p:has-text("A block level mark in WikiText.")'); + await expect(blockMarkedText, "Block marked text presented").toBeVisible({timeout}); + await expect(blockMarkedText, "A highlight animation").toHaveClass('tc-focus-highlight'); + // Check the mark span properties + const markSpan = page.locator('span[data-block-mark-id="BlockLevelLinksID1"]') + await expect(markSpan, "Mark span presented but not visible").not.toBeVisible({timeout}), + await Promise.all([ + expect(markSpan).toHaveAttribute('data-block-mark-title', 'BlockMark/Marks'), + expect(markSpan).toHaveClass('tc-block-mark'), + expect(markSpan).toHaveText(''), + expect(markSpan).toHaveClass('tc-block-mark'), + markSpan.evaluate(e => e.id).then(id => expect(id).toBe('BlockMark/Marks-BlockLevelLinksID1')) + ]) }); diff --git a/editions/test/tiddlers/tests/data/block-mark/Links.tid b/editions/test/tiddlers/tests/data/block-mark/Links.tid new file mode 100644 index 000000000..65c272c99 --- /dev/null +++ b/editions/test/tiddlers/tests/data/block-mark/Links.tid @@ -0,0 +1,3 @@ +title: BlockMark/Links + +[[Block Level Links in WikiText|BlockMark/Marks^BlockLevelLinksID1]]. \ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/block-mark/Marks.tid b/editions/test/tiddlers/tests/data/block-mark/Marks.tid new file mode 100644 index 000000000..b0ab76a8c --- /dev/null +++ b/editions/test/tiddlers/tests/data/block-mark/Marks.tid @@ -0,0 +1,5 @@ +title: BlockMark/Marks + +First normal paragraph. + +A block level mark in WikiText. ^BlockLevelLinksID1