-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Cypress testing for Music Blocks
- Loading branch information
Showing
7 changed files
with
1,909 additions
and
83 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { defineConfig } = require("cypress"); | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
viewportWidth: 1400, | ||
viewportHeight: 1000, | ||
testIsolation: false | ||
}, | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
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.document().its("fullscreenElement").should("exist"); | ||
cy.get("#FullScreen").click(); | ||
cy.document().its("fullscreenElement").should("not.exist"); | ||
}); | ||
|
||
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("Welcome Content", () => { | ||
it('should hide the "Welcome to Music Blocks" content when clicking the close button', () => { | ||
cy.contains('Welcome to Music Blocks').should('be.visible'); | ||
cy.get('.wfTopBar > .close') | ||
.should('exist') | ||
.and('be.visible') | ||
.click(); | ||
cy.contains('Welcome to Music Blocks').should('not.exist'); | ||
}); | ||
}); | ||
|
||
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') | ||
.should('be.visible'); | ||
}); | ||
}); | ||
|
||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// *********************************************************** | ||
// This example support/e2e.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' |
Oops, something went wrong.