Skip to content

Commit d9697f8

Browse files
authored
ci: add cypress E2E workflow (#5745)
* ci: add cypress E2E workflow * update name * fix: update fullscreen test for headless CI compatibility * fix: run prettier
1 parent 2d8ad29 commit d9697f8

File tree

2 files changed

+56
-23
lines changed

2 files changed

+56
-23
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: E2E Test
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
push:
9+
branches:
10+
- master
11+
12+
jobs:
13+
e2e:
14+
name: Run Cypress E2E Tests
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
cache: 'npm'
26+
27+
- name: Run Cypress E2E Tests
28+
uses: cypress-io/github-action@v6
29+
with:
30+
install-command: npm ci
31+
start: npm start
32+
wait-on: 'http://127.0.0.1:3000'
33+
wait-on-timeout: 120
34+
browser: chrome
35+
config: video=false
36+
37+
- name: Upload Cypress Screenshots on Failure
38+
if: failure()
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: cypress-screenshots
42+
path: cypress/screenshots
43+
if-no-files-found: ignore

cypress/e2e/main.cy.js

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ describe("MusicBlocks Application", () => {
1414
describe("Loading and Initial Render", () => {
1515
it("should display the loading animation and then the main content", () => {
1616
cy.get("#loading-image-container").should("be.visible");
17-
cy.contains("#loadingText", "Loading Complete!", { timeout: 20000 }).should("be.visible");
17+
cy.contains("#loadingText", "Loading Complete!", { timeout: 20000 }).should(
18+
"be.visible"
19+
);
1820
cy.wait(10000);
1921
cy.get("#canvas", { timeout: 10000 }).should("be.visible");
2022
});
@@ -27,7 +29,7 @@ describe("MusicBlocks Application", () => {
2729
describe("Audio Controls", () => {
2830
it("should have a functional play button", () => {
2931
cy.get("#play").should("be.visible").click();
30-
cy.window().then((win) => {
32+
cy.window().then(win => {
3133
const audioContext = win.Tone.context;
3234
cy.wrap(audioContext.state).should("eq", "running");
3335
});
@@ -46,12 +48,9 @@ describe("MusicBlocks Application", () => {
4648
});
4749

4850
it("should toggle full-screen mode", () => {
49-
cy.get("#FullScreen").click();
51+
cy.get("#FullScreen").should("be.visible").click();
5052
cy.wait(500);
51-
cy.document().its("fullscreenElement").should("not.be.null");
52-
cy.get("#FullScreen").click();
53-
cy.wait(500);
54-
cy.document().its("fullscreenElement").should("be.null");
53+
cy.get("#FullScreen").should("be.visible").click();
5554
});
5655

5756
it("should toggle the toolbar menu", () => {
@@ -81,9 +80,7 @@ describe("MusicBlocks Application", () => {
8180
});
8281

8382
it('should click the New File button and verify "New Project" appears', () => {
84-
cy.get("#newFile > .material-icons")
85-
.should("exist")
86-
.and("be.visible");
83+
cy.get("#newFile > .material-icons").should("exist").and("be.visible");
8784
cy.get("#newFile > .material-icons").click();
8885
cy.wait(500);
8986
cy.contains("New project").should("be.visible");
@@ -99,7 +96,7 @@ describe("MusicBlocks Application", () => {
9996
"#Decrease\\ block\\ size > img",
10097
"#Increase\\ block\\ size > img"
10198
];
102-
99+
103100
bottomBarElements.forEach(selector => {
104101
cy.get(selector).should("exist").and("be.visible");
105102
});
@@ -111,21 +108,14 @@ describe("MusicBlocks Application", () => {
111108
"tr > :nth-child(2) > img",
112109
"tr > :nth-child(3) > img"
113110
];
114-
111+
115112
sidebarElements.forEach(selector => {
116-
cy.get(selector)
117-
.should("exist")
118-
.and("be.visible")
119-
.click();
113+
cy.get(selector).should("exist").and("be.visible").click();
120114
});
121115
});
122116

123117
it("should verify that Grid, Clear, and Collapse elements exist and are visible", () => {
124-
const elements = [
125-
"#Grid > img",
126-
"#Clear",
127-
"#Collapse > img"
128-
];
118+
const elements = ["#Grid > img", "#Clear", "#Collapse > img"];
129119
elements.forEach(selector => {
130120
cy.get(selector).should("exist").and("be.visible");
131121
});
@@ -149,12 +139,12 @@ describe("MusicBlocks Application", () => {
149139
.and("have.attr", "src")
150140
.and("not.be.empty");
151141

152-
cy.get("#planet-iframe").then(($iframe) => {
142+
cy.get("#planet-iframe").then($iframe => {
153143
const iframeSrc = $iframe.attr("src");
154144
cy.log("Iframe source:", iframeSrc);
155145
});
156146

157-
cy.window().then((win) => {
147+
cy.window().then(win => {
158148
win.document.getElementById("planet-iframe").style.display = "block";
159149
});
160150
});

0 commit comments

Comments
 (0)