Commit dd3a67f
authored
[Website] Prevent Query API defaults from overriding login info provided by the Blueprint (#2871)
## Motivation for the change, related issues
As reported in
#2872 the
Playground website will override the `login` step and shorthand when
applying Query API overrides.
The default behavior of the Query API is to set the `login` shorthand to
`true`, but the override doesn't check if the Blueprint already provides
a `login` step or shorthand. This behavior results in the user being
unable to use the `login` step and shorthand on the Playground website,
except if they explicitly set `?login=no` in the Query API.
## Implementation details
This PR addresses the issue by prepending the default login step to the
steps array instead of appending it to the end. By prepending it, the
login steps provided by the user will override the default login step.
The login step only defines the `PLAYGROUND_AUTO_LOGIN_AS_USER` const,
we can have multiple, because each step overrides the definition of the
previous step. ([login step
code](https://github.com/WordPress/wordpress-playground/blob/15e5181600d6e93db3f3bb73f37b86ead15f51a3/packages/playground/blueprints/src/lib/steps/login.ts#L43)).
On the first page load, a mu-plugin detects the const and logs in the
user defined in that const ([login
code)](https://github.com/WordPress/wordpress-playground/blob/cae150a060f2c6067797186b62140b719cd32e63/packages/playground/wordpress/src/index.ts#L103).
Because of that, it doesn't matter how many times we call the login
step, login will be executed once.
## Testing Instructions (or ideally a Blueprint)
- CI
### Manual testing
- Checkout this branch
- [Open this Playground website
link](http://127.0.0.1:5400/website-server/?blueprint-url=https%3A%2F%2Fraw.githubusercontent.com%2Fyookoala%2Fuser-profile-tabs%2F23cc90db58bf16e656a07503aa95514a27a2a2e3%2F.wordpress-org%2Fblueprints%2Fblueprint.json)
- Once Playground loads you should be logged in as the `Demo User`1 parent 43ea776 commit dd3a67f
File tree
2 files changed
+33
-1
lines changed- packages/playground
- blueprints/src/lib/v1
- website/playwright/e2e
2 files changed
+33
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
233 | 237 | | |
234 | | - | |
| 238 | + | |
235 | 239 | | |
236 | 240 | | |
237 | 241 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
597 | 597 | | |
598 | 598 | | |
599 | 599 | | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
600 | 628 | | |
601 | 629 | | |
602 | 630 | | |
| |||
0 commit comments