-
Notifications
You must be signed in to change notification settings - Fork 11
Add sample projects to code editor test page #1294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
5864a9c to
aaae63b
Compare
aaae63b to
b632bf6
Compare
b632bf6 to
68a3f53
Compare
I want to use add more demos to the web-component.html page, but it would be easier if we could load a project directly by providing JSON rather than providing an identifier that has to be loaded through an API. If this was just react I would pass in a loadProject function, but it's harder to pass in behaviour like that to web components. This is only intended to be set when the component is loaded and not changed during the lifecycle of the component.
It's handle to be able to quickly try out different projects, and later when we introduce scratch it would be useful to be able to get a scratch project from the test page without a dependnecy on another app. I've set up json files for the projects and used AI to generate interesting multi-file html and python projects
68a3f53 to
0a08227
Compare
dda89a7 to
47b4bb1
Compare
On this branch this test consistently fails. I'm not sure why this test is failing as there are other similar tests. Try seting test isolation in case other tests are interfering
47b4bb1 to
73a494e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds sample project loading functionality to the code editor test page, enabling quick testing of different project types without external dependencies. It introduces a new initial_project web component attribute that accepts JSON project data, along with a UI bar containing links to load predefined sample projects (blank and "cool" examples for both HTML and Python).
Changes:
- Added
initial_projectattribute support to the web component for loading projects from JSON - Created sample project JSON files with starter templates and demonstration projects
- Updated webpack configuration to serve project files from
src/projectsdirectory - Modified test page HTML to include a project selector bar and improved layout structure
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| webpack.config.js | Added static file serving and copy patterns for project JSON files |
| src/web-component.js | Added initial_project to observed attributes list |
| src/web-component.html | Added sample projects bar UI and fetch logic to load projects dynamically |
| src/projects/*.json | Four sample project files (blank starters and demo projects for HTML/Python) |
| src/hooks/useProject.js | Added logic to parse and load initialProject parameter with priority handling |
| src/hooks/useProject.test.js | Added test coverage for initialProject feature |
| src/containers/WebComponentLoader.jsx | Added initialProject prop forwarding |
| src/containers/WebComponentLoader.test.js | Updated test expectations to include initialProject parameter |
| package.json | Removed JSON files from eslint configuration (appropriate change) |
| cypress.config.mjs | Enabled testIsolation (standard Cypress configuration) |
| CHANGELOG.md | Added entry for this feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Grr, I'm having some problems with an intermittently failing test - it's mostly failing in CI, and occasionally failing locally. I think I must have made some change that makes the failure more likely but I'm not sure what it is. Will look on Monday. |
It's handy to be able to quickly try out different projects, and later when we introduce scratch it would be useful to be able to get a scratch project from the test page without a dependency on another app.
To do this, allow an initialProject to be set in the web component.
I've set up json files for sample projects and used AI to generate interesting multi-file HTML and Python projects.
New project bar at the top: