diff --git a/e2e/.gitignore b/e2e/.gitignore new file mode 100644 index 0000000..69fc4ad --- /dev/null +++ b/e2e/.gitignore @@ -0,0 +1 @@ +.e2e_test_vault/ diff --git a/e2e/constants.ts b/e2e/constants.ts new file mode 100644 index 0000000..f9c85d8 --- /dev/null +++ b/e2e/constants.ts @@ -0,0 +1,2 @@ +export const TIMECODES_PLUGIN_ID = 'timecodes-plugin' +export const TEST_VAULT_DIR = '.e2e_test_vault' diff --git a/e2e/package.json b/e2e/package.json new file mode 100644 index 0000000..29cf02f --- /dev/null +++ b/e2e/package.json @@ -0,0 +1,21 @@ +{ + "name": "obsidian-timecodes-plugin-e2e-tests", + "type": "module", + "private": true, + "scripts": { + "pretest": "pnpm --dir .. run build", + "test": "wdio run wdio.conf.ts" + }, + "devDependencies": { + "@wdio/cli": "9.5.7", + "@wdio/globals": "9.5.7", + "@wdio/local-runner": "9.5.7", + "@wdio/mocha-framework": "9.5.0", + "@wdio/spec-reporter": "9.5.0", + "electron": "32.2.5", + "expect-webdriverio": "5.0.5", + "obsidian": "1.7.2", + "wdio-electron-service": "7.3.1", + "webdriverio": "9.5.7" + } +} diff --git a/e2e/specs/markdown-view_post-processor.e2e.ts b/e2e/specs/markdown-view_post-processor.e2e.ts new file mode 100644 index 0000000..950c588 --- /dev/null +++ b/e2e/specs/markdown-view_post-processor.e2e.ts @@ -0,0 +1,183 @@ +import ObsidianApp from './pageobjects/obsidian-app.page' + +describe('Markdown view post-processor', () => { + context('Link to video and timecode are within the same
aragraph in Markdown view', () => { + it('renders timecode with expected clickable link', async () => { + const noteContent = `https://youtu.be/k_ItB5btREU +22:53 - effectiveness characteristics of e2e tests` + await ObsidianApp.createNewNoteWithContent(noteContent) + + await ObsidianApp.toggleReadingView() + + const link = $('//div[contains(@class, "markdown-preview-section")]//a[text()="22:53"]') + await expect(link).toBePresent() + const href = await link.getAttribute('href') + await expect(href).toBe('https://youtu.be/k_ItB5btREU?t=1373') + }) + }) + + context('Link to video and timecode are in different
aragraphs in Markdown view', () => { + it('renders timecode with expected clickable link', async () => { + const noteContent = `https://youtu.be/k_ItB5btREU + +22:53 - effectiveness characteristics of e2e tests` + await ObsidianApp.createNewNoteWithContent(noteContent) + + await ObsidianApp.toggleReadingView() + + const link = $('//div[contains(@class, "markdown-preview-section")]//a[text()="22:53"]') + await expect(link).toBePresent() + const href = await link.getAttribute('href') + await expect(href).toBe('https://youtu.be/k_ItB5btREU?t=1373') + }) + }) + + context('Timecode is on the same line as video link', () => { + it('renders timecode with expected clickable link', async () => { + const noteContent = `https://youtu.be/k_ItB5btREU 22:53 - effectiveness characteristics of e2e tests` + await ObsidianApp.createNewNoteWithContent(noteContent) + + await ObsidianApp.toggleReadingView() + + const link = $('//div[contains(@class, "markdown-preview-section")]//a[text()="22:53"]') + await expect(link).toBePresent() + const href = await link.getAttribute('href') + await expect(href).toBe('https://youtu.be/k_ItB5btREU?t=1373') + }) + }) + + context('There is a markdown link to YouTube video instead of a plain text link', () => { + it('renders timecode with expected clickable link', async () => { + const noteContent = `[Here](https://youtu.be/k_ItB5btREU) is a great talk about software testing + +22:53 - effectiveness characteristics of e2e tests` + await ObsidianApp.createNewNoteWithContent(noteContent) + + await ObsidianApp.toggleReadingView() + + const link = $('//div[contains(@class, "markdown-preview-section")]//a[text()="22:53"]') + await expect(link).toBePresent() + const href = await link.getAttribute('href') + await expect(href).toBe('https://youtu.be/k_ItB5btREU?t=1373') + }) + }) + + context('The video is embedded with