Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/components/app-shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export default function AppShell() {
<>
<Routes>
<Route path="/" element={<App showExample={false} />} />
<Route path="/view" element={<App showExample={false} />} />
<Route path="/reset" element={<Reset />} />
<Route path="/edited" element={<App showExample={false} />} />
<Route path="/edited/view" element={<App showExample={false} />} />
<Route path="/gist/:id/:filename" element={<App showExample={false} />} />
<Route path="/gist/:id/:filename/view" element={<App showExample={false} />} />
<Route path="/gist/:id/:revision/:filename" element={<App showExample={false} />} />
Expand Down
11 changes: 4 additions & 7 deletions src/components/renderer/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,14 @@ export default function Renderer(props: RendererProps) {

const openPortal = useCallback(() => {
const pathname = location.pathname;
if (pathname !== '/' && pathname !== '/edited' && !pathname.endsWith('/view')) {
navigate(pathname + '/view', {replace: false});
if (!pathname.endsWith('/view')) {
navigate(pathname === '/' ? '/view' : pathname + '/view', {replace: false});
}
}, [location.pathname, navigate]);

const closePortal = useCallback(() => {
const pathname = location.pathname
.split('/')
.filter((e) => e !== 'view')
.join('/');
if (pathname !== '/' && pathname !== '/edited') {
const pathname = location.pathname.replace(/\/view$/, '') || '/';
if (pathname !== location.pathname) {
navigate(pathname, {replace: false});
}
}, [location.pathname, navigate]);
Expand Down
35 changes: 22 additions & 13 deletions tests/e2e/test-runtime/urls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,30 @@ test.describe('URL behavior', () => {
expect(page.url()).toMatch(/#\/custom\/vega-lite$/);
});

// Need to implement this in the editor first: https://github.com/vega/editor/issues/1508
// test('fullscreen appends /view to the current route and is removed on exit', async ({page}) => {
// await homePage.typeInEditor(vlSpec);
// await homePage.waitForVisualizationUpdate();
test('fullscreen appends /view to the root route and removes it on exit', async ({page}) => {
await page.locator('.fullscreen-open').click();
await homePage.waitForStableUI();

expect(page.url()).toMatch(/#\/view$/);

await page.getByRole('button', {name: 'Edit Visualization'}).click();
await homePage.waitForStableUI();

expect(page.url()).toMatch(/#\/$/);
});

// await page.locator('.fullscreen-open').click();
// await homePage.waitForStableUI();
test('fullscreen appends /view to the edited route and removes it on exit', async ({page}) => {
await homePage.typeInEditor(vlSpec);
await homePage.waitForVisualizationUpdate();

await page.locator('.fullscreen-open').click();
await homePage.waitForStableUI();

// const urlAfterOpen = page.url();
// expect(urlAfterOpen).toMatch(/\/view$/);
expect(page.url()).toMatch(/#\/edited\/view$/);

// await page.getByRole('button', {name: 'Edit Visualization'}).click();
// await homePage.waitForStableUI();
await page.getByRole('button', {name: 'Edit Visualization'}).click();
await homePage.waitForStableUI();

// const urlAfterClose = page.url();
// expect(urlAfterClose).not.toMatch(/\/view$/);
// });
expect(page.url()).toMatch(/#\/edited$/);
});
});
Loading