Skip to content

Commit

Permalink
Blueprints: Support a landingPage value without the initial slash (#1227
Browse files Browse the repository at this point in the history
)

Without this PR, a Blueprint like `{ "landingPage":
"wp-admin/plugins.php" }` won't work as there is no initial slash. This
PR adjusts the Playground API to prepend that slash as URLs without one
should be relative to the document root anyway.

 ## Testing instructions

Confirm the E2E tests passed

cc @bph  @dmsnell
  • Loading branch information
adamziel authored Apr 11, 2024
1 parent 581da69 commit 5896219
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/playground/remote/src/lib/boot-playground-remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export async function bootPlaygroundRemote() {
});
},
async goTo(requestedPath: string) {
if (!requestedPath.startsWith('/')) {
requestedPath = '/' + requestedPath;
}
/**
* People often forget to type the trailing slash at the end of
* /wp-admin/ URL and end up with wrong relative hrefs. Let's
Expand Down
9 changes: 9 additions & 0 deletions packages/playground/website/cypress/e2e/blueprints.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ describe('Blueprints', () => {
cy.wordPressDocument().its('body').should('contain', 'Sample Page');
});

it('Landing page without the initial slash should work', () => {
const blueprint: Blueprint = {
landingPage: 'wp-admin/plugins.php',
login: true,
};
cy.visit('/#' + JSON.stringify(blueprint));
cy.wordPressDocument().its('body').should('contain.text', 'Plugins');
});

it('enableMultisite step should enable a multisite', () => {
const blueprint: Blueprint = {
landingPage: '/',
Expand Down

0 comments on commit 5896219

Please sign in to comment.