1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-23 15:36:52 +00:00

test: Engaging the search input, The tiddler should be opened and operational, allow clicking link to navigate to block mark

This commit is contained in:
linonetwo 2024-10-03 23:36:44 +08:00
parent 6557017d4e
commit 18b492103c
3 changed files with 41 additions and 0 deletions

View File

@ -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'))
])
});

View File

@ -0,0 +1,3 @@
title: BlockMark/Links
[[Block Level Links in WikiText|BlockMark/Marks^BlockLevelLinksID1]].

View File

@ -0,0 +1,5 @@
title: BlockMark/Marks
First normal paragraph.
A block level mark in WikiText. ^BlockLevelLinksID1