1241: Cypress test for scratch download and upload#1381
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Cypress coverage for Scratch project upload/download flows in the editor’s “Save & download” panel, including validation of the downloaded .sb3 contents.
Changes:
- Added shared Cypress helpers for interacting with the editor shadow DOM and the Scratch iframe.
- Added an E2E spec that uploads a fixture
.sb3, verifies the editor state, downloads the project, and inspects the downloaded archive. - Extended Cypress node tasks/config to manage downloads and parse
.sb3files (zip) + ignoredcypress/downloads.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
cypress/helpers/scratch.js |
Helper to access Scratch iframe body and assert Scratch is rendered. |
cypress/helpers/editor.js |
Helper to access editor shadow DOM and interact with Save & download panel actions. |
cypress/fixtures/upload-test-project.sb3 |
Fixture Scratch project used for upload testing. |
cypress/e2e/spec-scratch.cy.js |
New/updated spec covering Scratch iframe rendering, settings, and upload/download validation. |
cypress.config.mjs |
Adds downloads folder config plus tasks to reset/download/find/inspect .sb3 files. |
.gitignore |
Ignores cypress/downloads output directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cypress/e2e/spec-scratch.cy.js
Outdated
Comment on lines
+65
to
+81
| cy.wait(1000); | ||
|
|
||
| // assert on the file | ||
| cy.task("getNewestSb3").then((filePath) => { | ||
| expect(filePath).to.be.a("string"); | ||
| expect(filePath).to.match(/\.sb3$/); | ||
|
|
||
| cy.task("readSb3", filePath).then(({ fileNames, projectJson }) => { | ||
| expect(fileNames).to.include("project.json"); | ||
|
|
||
| const spriteNames = projectJson.targets | ||
| .filter((t) => t.isStage === false) | ||
| .map((t) => t.name); | ||
|
|
||
| expect(spriteNames).to.include("test sprite"); | ||
| }); | ||
| }); |
cypress.config.mjs
Outdated
Comment on lines
+62
to
+64
| const projectJson = projectJsonFile | ||
| ? JSON.parse(await projectJsonFile.async("string")) | ||
| : null; |
cypress.config.mjs
Outdated
Comment on lines
+9
to
+18
| const downloadsFolder = path.join(process.cwd(), "cypress", "downloads"); | ||
|
|
||
| export default defineConfig({ | ||
| e2e: { | ||
| chromeWebSecurity: false, | ||
| defaultCommandTimeout: 10000, | ||
| video: false, | ||
| defaultBrowser: "chrome", | ||
| testIsolation: true, | ||
| downloadsFolder: "cypress/downloads", |
e75338f to
7c0e857
Compare
7c0e857 to
8d93373
Compare
8d93373 to
32449c0
Compare
32449c0 to
f2ddf14
Compare
f2ddf14 to
32f5ee1
Compare
32f5ee1 to
c27f8a9
Compare
c27f8a9 to
7281b91
Compare
7281b91 to
c991fe5
Compare
c991fe5 to
c9b7cbf
Compare
c9b7cbf to
ce532f2
Compare
ce532f2 to
353eba4
Compare
353eba4 to
64b7443
Compare
Contributor
Author
|
If you are happy with the helper style of doing things on this branch let me know and I could create a task to do some brief refactoring on the other cypress test as well |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves issue: 1241
These adds in some Cypress test to check the upload and download of projects in the Scratch editor via the save and download panel.
It uses a pre-made .SB3 project in the
cypress/fixturesfolder that we use for upload and we check the downloaded version of that file too.I basically use a sprite with a custom name of
test spritein that project and check for the present of that name in the Scratch editor and the downloaded files.I've also start to adopt use of helpers - there is one set for the editor and one for scratch. The editor ones will have reuse implications elsewhere already I think and will help to centralise some of our selectors.