forked from sugarlabs/musicblocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cy.js
More file actions
155 lines (132 loc) · 5.55 KB
/
main.cy.js
File metadata and controls
155 lines (132 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
Cypress.on("uncaught:exception", (err, runnable) => {
return false;
});
describe("MusicBlocks Application", () => {
before(() => {
cy.visit("http://localhost:3000");
});
afterEach(() => {
console.log("Next test running, no reload should happen");
});
describe("Loading and Initial Render", () => {
it("should display the loading animation and then the main content", () => {
cy.get("#loading-image-container").should("be.visible");
cy.contains("#loadingText", "Loading Complete!", { timeout: 20000 }).should(
"be.visible"
);
cy.wait(10000);
cy.get("#canvas", { timeout: 10000 }).should("be.visible");
});
it("should display the Musicblocks guide page", () => {
cy.get(".heading").contains("Welcome to Music Blocks");
});
});
describe("Audio Controls", () => {
it("should have a functional play button", () => {
cy.get("#play").should("be.visible").click();
cy.window().then(win => {
const audioContext = win.Tone.context;
cy.wrap(audioContext.state).should("eq", "running");
});
});
it("should have a functional stop button", () => {
cy.get("#stop").should("be.visible").click();
});
});
describe("Toolbar and Navigation", () => {
it("should open the language selection dropdown", () => {
cy.get("#aux-toolbar").invoke("show");
cy.get("#languageSelectIcon").click({ force: true });
cy.get("#languagedropdown").should("be.visible");
});
it("should toggle full-screen mode", () => {
cy.get("#FullScreen").click();
cy.wait(500);
cy.document().its("fullscreenElement").should("not.be.null");
cy.get("#FullScreen").click();
cy.wait(500);
cy.document().its("fullscreenElement").should("be.null");
});
it("should toggle the toolbar menu", () => {
cy.get("#toggleAuxBtn").click();
cy.get("#aux-toolbar").should("be.visible");
cy.get("#toggleAuxBtn").click();
cy.get("#aux-toolbar").should("not.be.visible");
});
});
describe("File Operations", () => {
it("should open the file load modal", () => {
cy.get("#load").click();
cy.get("#myOpenFile").should("exist");
});
it("should open the save dropdown", () => {
cy.get("#saveButton").click();
cy.get("#saveddropdownbeg").should("be.visible");
});
it("should display file save options", () => {
cy.get("#saveButton").click();
cy.get("#saveddropdownbeg").should("be.visible");
cy.get("#save-html-beg").should("exist");
cy.get("#save-png-beg").should("exist");
});
it('should click the New File button and verify "New Project" appears', () => {
cy.get("#newFile > .material-icons").should("exist").and("be.visible");
cy.get("#newFile > .material-icons").click();
cy.wait(500);
cy.contains("New project").should("be.visible");
});
});
describe("UI Elements", () => {
it("should verify that bottom bar elements exist and are visible", () => {
const bottomBarElements = [
"#Home\\ \\[HOME\\] > img",
"#Show\\/hide\\ blocks > img",
"#Expand\\/collapse\\ blocks > img",
"#Decrease\\ block\\ size > img",
"#Increase\\ block\\ size > img"
];
bottomBarElements.forEach(selector => {
cy.get(selector).should("exist").and("be.visible");
});
});
it("should verify sidebar elements exist, are visible, and clickable", () => {
const sidebarElements = [
"thead > tr > :nth-child(1) > img",
"tr > :nth-child(2) > img",
"tr > :nth-child(3) > img"
];
sidebarElements.forEach(selector => {
cy.get(selector).should("exist").and("be.visible").click();
});
});
it("should verify that Grid, Clear, and Collapse elements exist and are visible", () => {
const elements = ["#Grid > img", "#Clear", "#Collapse > img"];
elements.forEach(selector => {
cy.get(selector).should("exist").and("be.visible");
});
});
it("should verify that all nth-child elements from 1 to 6 exist", () => {
for (let i = 1; i <= 6; i++) {
cy.get(`[width="126"] > tbody > :nth-child(${i})`)
.should("exist")
.and("be.visible");
}
});
});
describe("Planet Page Interaction", () => {
it("should load the Planet page and return to the main page when clicking the close button", () => {
cy.get("#planetIcon > .material-icons").should("exist").and("be.visible").click();
cy.get("#planet-iframe", { timeout: 10000 })
.should("be.visible")
.and("have.attr", "src")
.and("not.be.empty");
cy.get("#planet-iframe").then($iframe => {
const iframeSrc = $iframe.attr("src");
cy.log("Iframe source:", iframeSrc);
});
cy.window().then(win => {
win.document.getElementById("planet-iframe").style.display = "block";
});
});
});
});