Skip to content

Add e2e spec for project remix behaviour in web component#1020

Merged
floehopper merged 6 commits intomainfrom
add-e2e-spec-for-project-remix-behaviour-in-wc
May 24, 2024
Merged

Add e2e spec for project remix behaviour in web component#1020
floehopper merged 6 commits intomainfrom
add-e2e-spec-for-project-remix-behaviour-in-wc

Conversation

@floehopper
Copy link
Copy Markdown
Contributor

@floehopper floehopper commented May 23, 2024

The editor-standalone app will:

This spec checks that the web component provides the relevant behaviour for editor-standalone to use.

I did attempt to add an example for the default behaviour (i.e. when load_remix_disabled is not set). However, without any way to easily reset the state of the projects in the editor-api database, it's hard to come up with a robust way to write such a test.

Note that this PR changes both the editor app itself and the fake "app" wrapping the web component to use https://test-editor-api.raspberrypi.org instead of https://staging-editor-api.raspberrypi.org in CI. The former has BYPASS_AUTH set to true so the apps can make requests as if the user was logged in. The new e2e spec also relies on the projects:create_all rake task having been run - which we've only done manually for now, but needs automating.

I'm planning to add another example with a different `baseUrl` and the
nicest way to do that will be to use a separate `describe` block.
I'm planning to add some query params to the `baseUrl` in another
`describe` block. Renaming the stem of the URL to `origin` will make
that simpler.
@floehopper floehopper force-pushed the add-e2e-spec-for-project-remix-behaviour-in-wc branch from 469c231 to 9e0d3cc Compare May 23, 2024 15:37
@floehopper floehopper temporarily deployed to previews/add-e2e-spec-for-project-remix-behaviour-in-wc May 23, 2024 15:37 — with GitHub Actions Inactive
@floehopper floehopper temporarily deployed to previews/add-e2e-spec-for-project-remix-behaviour-in-wc May 23, 2024 15:38 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

@floehopper floehopper force-pushed the add-e2e-spec-for-project-remix-behaviour-in-wc branch from 6e84b40 to 4430370 Compare May 23, 2024 16:22
@floehopper floehopper temporarily deployed to previews/add-e2e-spec-for-project-remix-behaviour-in-wc May 23, 2024 16:22 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown

@floehopper floehopper temporarily deployed to previews/add-e2e-spec-for-project-remix-behaviour-in-wc May 23, 2024 17:16 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown

@floehopper floehopper temporarily deployed to previews/add-e2e-spec-for-project-remix-behaviour-in-wc May 23, 2024 18:01 — with GitHub Actions Inactive
@floehopper floehopper temporarily deployed to previews/add-e2e-spec-for-project-remix-behaviour-in-wc May 24, 2024 09:35 — with GitHub Actions Inactive
The Electron browser (used by default in the Cypress e2e specs) doesn't
always (ever?) set the "Origin" HTTP header and so the "validation" for
`Project#remix_origin` in `Project::CreateRemix#validate_params` [1]
fails, making it impossible to remix a project.

[1]: https://github.com/RaspberryPiFoundation/editor-api/blob/1bb7e7f74b8021418503bcf3af201844c130aa9a/lib/concepts/project/operations/create_remix.rb#L22-L25
The instance of `editor-api` at test-editor-api.raspberrypi.org has the
`BYPASS_AUTH` environment variable set which will allow us to write e2e
specs which require the `editor-ui` code to make authenticate requests
to `editor-api`.
The editor-standalone app will:

* Listen for "editor-projectIdentifierChanged" custom events from the
  web component and will redirect to the remixed project's URL.
* Set the web component `load_remix_disabled` attribute to `true` so
  that the original project will be loaded in preference to the remixed
  version (unlike the way projects-ui works).

This spec checks that the web component provides the relevant behaviour
for editor-standalone to use.

I did attempt to add an example for the default behaviour (i.e. when
`load_remix_disabled` is not set). However, without any way to easily
reset the state of the projects in the editor-api database, it's hard to
come up with a robust way to write such a test.
@github-actions
Copy link
Copy Markdown

@floehopper floehopper marked this pull request as ready for review May 24, 2024 09:53
Copy link
Copy Markdown

@chrisroos chrisroos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! 👍

@floehopper floehopper merged commit 92b45d5 into main May 24, 2024
@floehopper floehopper deleted the add-e2e-spec-for-project-remix-behaviour-in-wc branch May 24, 2024 12:26
@floehopper floehopper mentioned this pull request Jun 3, 2024
floehopper added a commit that referenced this pull request Jun 4, 2024
### Added

- Add `project_name_editable` attribute to web component (#1009)
- Fires custom event when the theme changes (#1015)
- Add `output_only` attribute to web component (#1019 & originally #782)
- Add `assets_identifier` attribute to web component (#1019 & originally
#901)
- Enhance `code` attribute on web component to override project main
component content (#1019 & originally #901)
- Add `runCode`, `stopCode` & `rerunCode` methods to web component
(#1019 & originally #899)
- Send error details in "editor-runCompleted" event (#1019 & originally
#915)
- Return error details to web component (#1019 & originally #915)
- Add `output_panels` attribute to web component (#1019 & originally
#909)

### Changed

- Remove unused `/embedded/projects/:identifier` route (#1013)

### Fixed

- Remove unused `REACT_APP_LOGIN_ENABLED` env var (#1006)
- Fix infinite remix loop when `BYPASS_AUTH` set in `editor-api` (#1007)
- Fixes for docker-compose.yml (#1008)
- Fix deprecation warnings in GitHub Actions (#1011)
- Removed unused `isEmbedded` param from `useProject` call in
`EmbeddedViewer` (#1016)
- Improvements to Cypress specs in CI (#1017)
- Fix warnings and verbose output when starting Webpack Dev Server
(#1018)
- Add e2e spec for project remix behaviour in web component (#1020)
- Fix initial value of `user` in `WebComponentLoader` (#1021)
- Make `authKey` in e2e web component spec more realistic (#1022)
- Remove unused `ComponentStore` (#1023)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants