Skip to content

feat: Virtual Routes Support #1799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ba998e8
add first test
illBeRoy May 14, 2022
7c92837
new VirtualRoutes mixin that handles routes. fetch tries to use Virtu…
illBeRoy May 14, 2022
7a2d0d0
cover all basic use cases
illBeRoy May 14, 2022
3f359ed
regex matching in routes
illBeRoy May 14, 2022
53c507f
covered all virtual routes tests
illBeRoy May 14, 2022
9d816bc
added hack to fix config test on firefox
illBeRoy May 15, 2022
fb084f8
removed formatting regex matches into string routes
illBeRoy May 17, 2022
1866fa2
added support for "next" function
illBeRoy May 17, 2022
8bf6890
added docs
illBeRoy May 17, 2022
a022b3d
navigate now supports both hash and history routerModes
illBeRoy May 18, 2022
1447898
waiting for networkidle in navigateToRoute helper
illBeRoy May 18, 2022
e8a12c0
promiseless implementation
illBeRoy May 18, 2022
e81429d
remove firefox workaround from catchPluginErrors test, since we no lo…
illBeRoy May 18, 2022
f0be4ca
updated docs
illBeRoy May 18, 2022
dbf45d4
updated docs for "alias" as well
illBeRoy May 18, 2022
dfbf77f
minor rephrasing
illBeRoy May 18, 2022
a245a2b
removed non-legacy code from exact-match; updated navigateToRoute hel…
illBeRoy May 19, 2022
4277cc5
moved endsWith from router utils to general utils; added startsWith u…
illBeRoy May 19, 2022
4bd7ac8
updated docs per feedback
illBeRoy May 19, 2022
ebfc235
moved navigateToRoute helper into the virtual-routes test file
illBeRoy May 19, 2022
bea7308
moved navigateToRoute to top of file
illBeRoy May 19, 2022
c748b33
updated docs per pr comments
illBeRoy May 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add first test
  • Loading branch information
illBeRoy committed May 15, 2022
commit ba998e8831e886e8b77a4535ad3f85c4e510b58f
24 changes: 24 additions & 0 deletions test/e2e/virtual-routes.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const docsifyInit = require('../helpers/docsify-init');
const { navigateToRoute } = require('../helpers/navigate');
const { test, expect } = require('./fixtures/docsify-init-fixture');

test.describe('Virtual Routes - Generate Dynamic Content via Config', () => {
test.only('rendering virtual routes specified in the configuration', async ({
page,
}) => {
const routes = {
'/my-awesome-route': '# My Awesome Route',
};

await docsifyInit({
config: {
routes,
},
});

await navigateToRoute(page, '/my-awesome-route');

const titleElm = page.locator('#main h1');
await expect(titleElm).toContainText('My Awesome Route');
});
});
12 changes: 12 additions & 0 deletions test/helpers/navigate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Navigate to a specific hashtag route in the page, and wait for docsify to handle navigation.
* @param {import('playwright-core').Page} page
* @param {string} route
*/
async function navigateToRoute(page, route) {
await page.evaluate(r => (window.location.hash = r), route);
const mainElm = await page.waitForSelector('#main');
await mainElm.waitForElementState('stable');
}

module.exports.navigateToRoute = navigateToRoute;