Skip to content
Open
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
6 changes: 5 additions & 1 deletion packages/playground/blueprints/src/lib/v1/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
28 changes: 28 additions & 0 deletions packages/playground/website/playwright/e2e/blueprints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading