diff --git a/packages/playground/blueprints/src/lib/v1/compile.ts b/packages/playground/blueprints/src/lib/v1/compile.ts index b2b3b7bb89..9539b0b0df 100644 --- a/packages/playground/blueprints/src/lib/v1/compile.ts +++ b/packages/playground/blueprints/src/lib/v1/compile.ts @@ -224,8 +224,12 @@ function compileBlueprintJson( })) as StepDefinition[]; blueprint.steps!.unshift(...steps); } + + /** + * Prepend a login step to enable Blueprints to override the default login step. + */ if (blueprint.login) { - blueprint.steps!.push({ + blueprint.steps!.unshift({ step: 'login', ...(blueprint.login === true ? { username: 'admin' } diff --git a/packages/playground/website/playwright/e2e/blueprints.spec.ts b/packages/playground/website/playwright/e2e/blueprints.spec.ts index 0eab24a074..55921852af 100644 --- a/packages/playground/website/playwright/e2e/blueprints.spec.ts +++ b/packages/playground/website/playwright/e2e/blueprints.spec.ts @@ -597,6 +597,34 @@ test('should login the user in if a login step is provided', async ({ await expect(wordpress.locator('body')).toContainText('Dashboard'); }); +test('should login a non-admin user if a login step with a non-admin username is provided', async ({ + website, + wordpress, +}) => { + const blueprint: Blueprint = { + landingPage: '/wp-admin/profile.php', + extraLibraries: ['wp-cli'], + steps: [ + { + step: 'wp-cli', + command: + "wp user create user user@example.com --user_pass='password'", + }, + { + step: 'login', + username: 'user', + password: 'password', + }, + ], + }; + + const encodedBlueprint = JSON.stringify(blueprint); + await website.goto(`./#${encodedBlueprint}`); + await expect(wordpress.locator('#profile-page #email')).toHaveValue( + 'user@example.com' + ); +}); + ['/wp-admin/', '/wp-admin/post.php?post=1&action=edit'].forEach((path) => { test(`should correctly redirect encoded wp-admin url to ${path}`, async ({ website,