Skip to content

1241: Cypress test for scratch download and upload#1381

Open
DNR500 wants to merge 7 commits intomainfrom
1241-cypress-test-for-scratch-download-and-upload
Open

1241: Cypress test for scratch download and upload#1381
DNR500 wants to merge 7 commits intomainfrom
1241-cypress-test-for-scratch-download-and-upload

Conversation

@DNR500
Copy link
Contributor

@DNR500 DNR500 commented Mar 13, 2026

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/fixtures folder 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 sprite in 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.

Copilot AI review requested due to automatic review settings March 13, 2026 17:36
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 13, 2026 17:36 — with GitHub Actions Inactive
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 .sb3 files (zip) + ignored cypress/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.

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");
});
});
Comment on lines +62 to +64
const projectJson = projectJsonFile
? JSON.parse(await projectJsonFile.async("string"))
: null;
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",
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 13, 2026 18:26 — with GitHub Actions Inactive
@DNR500 DNR500 marked this pull request as draft March 13, 2026 18:29
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 13, 2026 18:45 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from e75338f to 7c0e857 Compare March 13, 2026 18:52
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 13, 2026 18:52 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from 7c0e857 to 8d93373 Compare March 13, 2026 18:55
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 13, 2026 18:55 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from 8d93373 to 32449c0 Compare March 16, 2026 09:08
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 09:08 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from 32449c0 to f2ddf14 Compare March 16, 2026 09:11
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 09:11 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from f2ddf14 to 32f5ee1 Compare March 16, 2026 09:14
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 09:14 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from 32f5ee1 to c27f8a9 Compare March 16, 2026 14:52
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 14:52 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from c27f8a9 to 7281b91 Compare March 16, 2026 15:31
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 15:31 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from 7281b91 to c991fe5 Compare March 16, 2026 16:59
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 16:59 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from c991fe5 to c9b7cbf Compare March 16, 2026 17:18
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 17:18 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from c9b7cbf to ce532f2 Compare March 16, 2026 17:23
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 17:24 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from ce532f2 to 353eba4 Compare March 16, 2026 17:40
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 17:41 — with GitHub Actions Inactive
@DNR500 DNR500 force-pushed the 1241-cypress-test-for-scratch-download-and-upload branch from 353eba4 to 64b7443 Compare March 16, 2026 17:48
@DNR500 DNR500 temporarily deployed to previews/1381/merge March 16, 2026 17:48 — with GitHub Actions Inactive
@DNR500
Copy link
Contributor Author

DNR500 commented Mar 16, 2026

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

@DNR500 DNR500 marked this pull request as ready for review March 16, 2026 19:02
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