Skip to content

Commit 20f3045

Browse files
authored
Merge pull request #4 from Hack23/pixi.js
Add sound and graphics library dependencies
2 parents 7b5c2d8 + a0cc83e commit 20f3045

33 files changed

Lines changed: 2305 additions & 152 deletions

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,3 +5654,30 @@ coverage/lcov-report/prettify.css
56545654
coverage/lcov-report/prettify.js
56555655
coverage/lcov-report/sort-arrow-sprite.png
56565656
coverage/lcov-report/sorter.js
5657+
dist/assets/browserAll-BiOfjq6z.js
5658+
dist/assets/CanvasPool-DhuECCtj.js
5659+
dist/assets/colorToUniform-KTpA7KSL.js
5660+
dist/assets/index-DpUUKxSf.js
5661+
dist/assets/index-Dw2lg5U2.css
5662+
dist/assets/SharedSystems-teRdgpM1.js
5663+
dist/assets/WebGLRenderer-CulhSKsG.js
5664+
dist/assets/WebGPURenderer-FbpSbPiE.js
5665+
dist/assets/webworkerAll-DDQEg618.js
5666+
coverage/game/cypress.config.ts.html
5667+
coverage/game/cypress.reporter.config.js.html
5668+
coverage/game/eslint.config.js.html
5669+
coverage/game/index.html
5670+
coverage/game/src/App.tsx.html
5671+
coverage/game/src/index.html
5672+
coverage/game/src/main.tsx.html
5673+
coverage/lcov-report/game/cypress.config.ts.html
5674+
coverage/lcov-report/game/cypress.reporter.config.js.html
5675+
coverage/lcov-report/game/eslint.config.js.html
5676+
coverage/lcov-report/game/index.html
5677+
coverage/lcov-report/game/src/App.tsx.html
5678+
coverage/lcov-report/game/src/index.html
5679+
coverage/lcov-report/game/src/main.tsx.html
5680+
dist/assets/browserAll-B03a4uXL.js
5681+
dist/assets/index-DhEMd0Oq.js
5682+
dist/assets/pixi-DgHaZaFf.js
5683+
dist/assets/webworkerAll-BOoFFBj4.js

cypress.config.reporter.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
{
2-
"reporterEnabled": "spec, junit",
3-
"reporterOptions": {
4-
"spec": {
5-
"showSkipped": true
6-
},
7-
"junit": {
8-
"mochaFile": "cypress/results/junit/results-[hash].xml",
9-
"toConsole": false
10-
}
2+
"reporterEnabled": "cypress-junit-reporter, spec",
3+
"cypressJunitReporterReporterOptions": {
4+
"mochaFile": "cypress/results/junit-[hash].xml",
5+
"toConsole": true,
6+
"attachments": true,
7+
"includePending": true,
8+
"testCaseSwitchClassnameAndName": false
9+
},
10+
"specReporterOptions": {
11+
"displayStacktrace": "all",
12+
"displaySuccessfullSpec": true,
13+
"displayFailureSpec": true,
14+
"displayPendingSpec": true,
15+
"displayDuration": true
1116
}
1217
}

cypress.config.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig } from "cypress";
22

33
// Centralize report directories with proper typing
4-
const REPORTS_BASE_DIR = "docs/cypress";
4+
const REPORTS_BASE_DIR = "cypress";
55
const REPORTS = {
66
junit: `${REPORTS_BASE_DIR}/junit`,
77
mochawesome: `${REPORTS_BASE_DIR}/mochawesome`,
@@ -39,6 +39,12 @@ export default defineConfig({
3939
},
4040
defaultCommandTimeout: 8000,
4141
chromeWebSecurity: false,
42+
video: true,
43+
videosFolder: "cypress/videos",
44+
screenshotsFolder: "cypress/screenshots",
45+
downloadsFolder: "cypress/downloads",
46+
fixturesFolder: "cypress/fixtures",
47+
responseTimeout: 10000,
4248
setupNodeEvents(
4349
on: Cypress.PluginEvents,
4450
config: Cypress.PluginConfigOptions
@@ -54,5 +60,25 @@ export default defineConfig({
5460
},
5561
specPattern: "src/**/*.cy.{js,jsx,ts,tsx}",
5662
supportFile: "cypress/support/component.ts",
63+
setupNodeEvents(on, config) {
64+
// implement node event listeners here
65+
on("before:browser:launch", (browser, launchOptions) => {
66+
if (browser.family === "chromium" && browser.name !== "electron") {
67+
// Add flags to suppress WebGL warnings and enable software rendering
68+
launchOptions.args.push("--enable-unsafe-swiftshader");
69+
launchOptions.args.push("--disable-web-security");
70+
launchOptions.args.push("--disable-features=VizDisplayCompositor");
71+
launchOptions.args.push("--disable-gpu");
72+
launchOptions.args.push("--no-sandbox");
73+
launchOptions.args.push("--disable-dev-shm-usage");
74+
// Suppress specific WebGL warnings
75+
launchOptions.args.push("--disable-logging");
76+
launchOptions.args.push("--silent");
77+
launchOptions.args.push("--log-level=3");
78+
}
79+
return launchOptions;
80+
});
81+
},
82+
indexHtmlFile: "cypress/support/component-index.html",
5783
},
5884
});

cypress/e2e/app.cy.ts

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,86 @@
1-
describe("Game App E2E", () => {
1+
describe("PixiJS Game E2E", () => {
22
beforeEach(() => {
33
cy.visit("/");
44
});
55

66
describe("Initial Page Load", () => {
7-
it("should display the main page correctly", () => {
7+
it("should display the game page correctly", () => {
88
// Check page title
99
cy.title().should("eq", "Vite + React + TS");
1010

1111
// Check main heading
12-
cy.get("h1").should("contain.text", "Vite + React");
12+
cy.get("h1").should("contain.text", "PixiJS React Game");
1313

14-
// Check logos are present and visible
15-
cy.get('img[alt="Vite logo"]').should("be.visible");
16-
cy.get('img[alt="React logo"]').should("be.visible");
14+
// Check instructions are present
15+
cy.get("p.instructions").should(
16+
"contain.text",
17+
"A minimal PixiJS game built with @pixi/react"
18+
);
1719

18-
// Check initial counter state
19-
cy.get("button").should("contain.text", "count is 0");
20+
// Check that the game container exists
21+
cy.get(".app-container").should("be.visible");
2022
});
21-
});
2223

23-
describe("Counter Functionality", () => {
24-
it("should increment counter when clicked", () => {
25-
// Get initial counter button
26-
cy.get("button").contains("count is 0").as("counterButton");
24+
it("should have proper page structure", () => {
25+
// Check main container
26+
cy.get(".app-container").should("exist").and("be.visible");
2727

28-
// Click the counter button
29-
cy.get("@counterButton").click();
28+
// Check heading structure
29+
cy.get("h1").should("have.length", 1);
3030

31-
// Verify counter incremented
32-
cy.get("button").should("contain.text", "count is 1");
31+
// Check instructions
32+
cy.get("p.instructions").should("be.visible");
3333
});
34+
});
3435

35-
it("should increment counter multiple times", () => {
36-
const clickCount = 3;
36+
describe("Game Canvas", () => {
37+
it("should render the PixiJS canvas", () => {
38+
// PixiJS creates a canvas element
39+
cy.get("canvas").should("exist");
40+
});
41+
42+
it("should have the correct canvas dimensions", () => {
43+
// Check that canvas has the expected dimensions (800x600)
44+
cy.get("canvas").should(($canvas) => {
45+
expect($canvas[0]).to.have.property("width", 800);
46+
expect($canvas[0]).to.have.property("height", 600);
47+
});
48+
});
49+
});
3750

38-
// Click multiple times
39-
for (let i = 0; i < clickCount; i++) {
40-
cy.get("button").click();
41-
}
51+
describe("Game Interaction", () => {
52+
it("should be interactive", () => {
53+
// Wait for canvas to be ready
54+
cy.get("canvas").should("be.visible");
4255

43-
// Verify final count
44-
cy.get("button").should("contain.text", `count is ${clickCount}`);
56+
// The game canvas should be present and ready for interaction
57+
cy.get("canvas").should("have.attr", "style");
4558
});
4659
});
4760

4861
describe("Accessibility", () => {
4962
it("should have proper heading structure", () => {
50-
cy.get("h1").should("have.length.at.least", 1);
63+
cy.get("h1").should("have.length", 1);
64+
});
65+
66+
it("should have readable content", () => {
67+
cy.get("h1")
68+
.should("be.visible")
69+
.and("contain.text", "PixiJS React Game");
70+
cy.get("p.instructions").should("be.visible");
5171
});
72+
});
73+
74+
describe("Responsive Design", () => {
75+
it("should be visible on different screen sizes", () => {
76+
// Test on tablet size
77+
cy.viewport(768, 1024);
78+
cy.get(".app-container").should("be.visible");
79+
cy.get("canvas").should("be.visible");
5280

53-
it("should have interactive elements accessible", () => {
54-
cy.get("button").should("be.visible").and("not.be.disabled");
81+
// Test on mobile size
82+
cy.viewport(375, 667);
83+
cy.get(".app-container").should("be.visible");
5584
});
5685
});
5786
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites name="Mocha Tests" time="1.796" tests="8" failures="0">
3+
<testsuite name="Root Suite" timestamp="2025-05-24T16:41:45" tests="0" file="cypress/e2e/app.cy.ts" failures="0" time="0">
4+
</testsuite>
5+
<testsuite name="PixiJS Game E2E" timestamp="2025-05-24T16:41:45" tests="0" failures="0" time="0">
6+
</testsuite>
7+
<testsuite name="Initial Page Load" timestamp="2025-05-24T16:41:45" tests="2" failures="0" time="0.749">
8+
<testcase name="PixiJS Game E2E Initial Page Load should display the game page correctly" time="0.598" classname="should display the game page correctly" failure="false" error="false" success="true">
9+
</testcase>
10+
<testcase name="PixiJS Game E2E Initial Page Load should have proper page structure" time="0.151" classname="should have proper page structure" failure="false" error="false" success="true">
11+
</testcase>
12+
</testsuite>
13+
<testsuite name="Game Canvas" timestamp="2025-05-24T16:41:46" tests="2" failures="0" time="0.301">
14+
<testcase name="PixiJS Game E2E Game Canvas should render the PixiJS canvas" time="0.112" classname="should render the PixiJS canvas" failure="false" error="false" success="true">
15+
</testcase>
16+
<testcase name="PixiJS Game E2E Game Canvas should have the correct canvas dimensions" time="0.189" classname="should have the correct canvas dimensions" failure="false" error="false" success="true">
17+
</testcase>
18+
</testsuite>
19+
<testsuite name="Game Interaction" timestamp="2025-05-24T16:41:47" tests="1" failures="0" time="0.173">
20+
<testcase name="PixiJS Game E2E Game Interaction should be interactive" time="0.173" classname="should be interactive" failure="false" error="false" success="true">
21+
</testcase>
22+
</testsuite>
23+
<testsuite name="Accessibility" timestamp="2025-05-24T16:41:48" tests="2" failures="0" time="0.22999999999999998">
24+
<testcase name="PixiJS Game E2E Accessibility should have proper heading structure" time="0.105" classname="should have proper heading structure" failure="false" error="false" success="true">
25+
</testcase>
26+
<testcase name="PixiJS Game E2E Accessibility should have readable content" time="0.125" classname="should have readable content" failure="false" error="false" success="true">
27+
</testcase>
28+
</testsuite>
29+
<testsuite name="Responsive Design" timestamp="2025-05-24T16:41:48" tests="1" failures="0" time="0.343">
30+
<testcase name="PixiJS Game E2E Responsive Design should be visible on different screen sizes" time="0.343" classname="should be visible on different screen sizes" failure="false" error="false" success="true">
31+
</testcase>
32+
</testsuite>
33+
</testsuites>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites name="Mocha Tests" time="1.6400000000000001" tests="8" failures="0">
3+
<testsuite name="Root Suite" timestamp="2025-05-24T16:38:13" tests="0" file="cypress/e2e/app.cy.ts" failures="0" time="0">
4+
</testsuite>
5+
<testsuite name="PixiJS Game E2E" timestamp="2025-05-24T16:38:13" tests="0" failures="0" time="0">
6+
</testsuite>
7+
<testsuite name="Initial Page Load" timestamp="2025-05-24T16:38:13" tests="2" failures="0" time="0.791">
8+
<testcase name="PixiJS Game E2E Initial Page Load should display the game page correctly" time="0.624" classname="should display the game page correctly" failure="false" error="false" success="true">
9+
</testcase>
10+
<testcase name="PixiJS Game E2E Initial Page Load should have proper page structure" time="0.167" classname="should have proper page structure" failure="false" error="false" success="true">
11+
</testcase>
12+
</testsuite>
13+
<testsuite name="Game Canvas" timestamp="2025-05-24T16:38:14" tests="2" failures="0" time="0.317">
14+
<testcase name="PixiJS Game E2E Game Canvas should render the PixiJS canvas" time="0.112" classname="should render the PixiJS canvas" failure="false" error="false" success="true">
15+
</testcase>
16+
<testcase name="PixiJS Game E2E Game Canvas should have the correct canvas dimensions" time="0.205" classname="should have the correct canvas dimensions" failure="false" error="false" success="true">
17+
</testcase>
18+
</testsuite>
19+
<testsuite name="Game Interaction" timestamp="2025-05-24T16:38:14" tests="1" failures="0" time="0.164">
20+
<testcase name="PixiJS Game E2E Game Interaction should be interactive" time="0.164" classname="should be interactive" failure="false" error="false" success="true">
21+
</testcase>
22+
</testsuite>
23+
<testsuite name="Accessibility" timestamp="2025-05-24T16:38:15" tests="2" failures="0" time="0.256">
24+
<testcase name="PixiJS Game E2E Accessibility should have proper heading structure" time="0.124" classname="should have proper heading structure" failure="false" error="false" success="true">
25+
</testcase>
26+
<testcase name="PixiJS Game E2E Accessibility should have readable content" time="0.132" classname="should have readable content" failure="false" error="false" success="true">
27+
</testcase>
28+
</testsuite>
29+
<testsuite name="Responsive Design" timestamp="2025-05-24T16:38:16" tests="1" failures="0" time="0.112">
30+
<testcase name="PixiJS Game E2E Responsive Design should be visible on different screen sizes" time="0.112" classname="should be visible on different screen sizes" failure="false" error="false" success="true">
31+
</testcase>
32+
</testsuite>
33+
</testsuites>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
7+
<title>Components App</title>
8+
<!-- Used by Cypress for component testing -->
9+
</head>
10+
<body>
11+
<div data-cy-root></div>
12+
</body>
13+
</html>

cypress/support/component.ts

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,55 @@
1-
// This file is processed and loaded automatically before your component test files.
1+
// ***********************************************************
2+
// This example support/component.ts is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
215

3-
// Import commands using ES2015 syntax:
16+
// Import commands.ts using ES2015 syntax:
417
import "./commands";
518

6-
// You can read more here:
7-
// https://on.cypress.io/component-testing
19+
// Use React 19 compatible mount function
20+
import { mount } from "cypress/react";
21+
22+
// Augment the Cypress namespace to include type definitions for
23+
// your custom command.
24+
// Alternatively, can be defined in cypress/support/component.d.ts
25+
// with a <reference path="./component" /> at the top of your spec.
26+
declare global {
27+
namespace Cypress {
28+
interface Chainable {
29+
mount: typeof mount;
30+
}
31+
}
32+
}
33+
34+
Cypress.Commands.add("mount", mount);
35+
36+
// Add browser launch configuration for component tests
37+
Cypress.on("before:browser:launch", (browser, launchOptions) => {
38+
if (browser.family === "chromium" && browser.name !== "electron") {
39+
// Add flags to suppress WebGL warnings and enable software rendering
40+
launchOptions.args.push("--enable-unsafe-swiftshader");
41+
launchOptions.args.push("--disable-web-security");
42+
launchOptions.args.push("--disable-features=VizDisplayCompositor");
43+
launchOptions.args.push("--disable-gpu");
44+
launchOptions.args.push("--no-sandbox");
45+
launchOptions.args.push("--disable-dev-shm-usage");
46+
// Suppress specific WebGL warnings
47+
launchOptions.args.push("--disable-logging");
48+
launchOptions.args.push("--silent");
49+
launchOptions.args.push("--log-level=3");
50+
}
51+
return launchOptions;
52+
});
53+
54+
// Example use:
55+
// cy.mount(<MyComponent />)

cypress/support/e2e.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,21 @@ import "./commands";
1111

1212
// You can read more here:
1313
// https://on.cypress.io/configuration
14+
15+
// Add browser launch configuration
16+
Cypress.on("before:browser:launch", (browser, launchOptions) => {
17+
if (browser.family === "chromium" && browser.name !== "electron") {
18+
// Add flags to suppress WebGL warnings and enable software rendering
19+
launchOptions.args.push("--enable-unsafe-swiftshader");
20+
launchOptions.args.push("--disable-web-security");
21+
launchOptions.args.push("--disable-features=VizDisplayCompositor");
22+
launchOptions.args.push("--disable-gpu");
23+
launchOptions.args.push("--no-sandbox");
24+
launchOptions.args.push("--disable-dev-shm-usage");
25+
// Suppress specific WebGL warnings
26+
launchOptions.args.push("--disable-logging");
27+
launchOptions.args.push("--silent");
28+
launchOptions.args.push("--log-level=3");
29+
}
30+
return launchOptions;
31+
});

0 commit comments

Comments
 (0)