diff --git a/documentation/docs/testing/acceptance-testing.md b/documentation/docs/testing/acceptance-testing.md index 74a8c840..ab4ffb0b 100644 --- a/documentation/docs/testing/acceptance-testing.md +++ b/documentation/docs/testing/acceptance-testing.md @@ -1,7 +1,7 @@ --- sidebar_position: 3 --- -# Acceptance test +# Acceptance Tests Demonstration of all of the functional and non-functional requirements. This can be a combination of automated tests derived from the use-cases (user stories) and manual tests with recorded observation of the results. diff --git a/documentation/docs/testing/integration-testing.md b/documentation/docs/testing/integration-testing.md index 14b3ebaa..1b46dcdf 100644 --- a/documentation/docs/testing/integration-testing.md +++ b/documentation/docs/testing/integration-testing.md @@ -1,145 +1,229 @@ --- sidebar_position: 2 --- -# Integration tests +# Integration Tests + + +You can find the generated integration test report [here.](https://htmlpreview.github.io/?https://github.com/Capstone-Projects-2024-Spring/project-blastpad/blob/assets/integration-report.html) + Tests to demonstrate each use-case based on the use-case descriptions and the sequence diagrams. External input should be provided via mock objects and results verified via mock objects. Integration tests should not require manual entry of data nor require manual interpretation of results. -## Integration Test for Use Case 4 -This integration test is for the scenario where the user debugs a Blockly game they created. -- Input: Void -- Expected Output: True -``` -public Use_Case_4_Integration_Test(Void) -> Boolean - # Starting Blast Pad - deviceManager = New DeviceManager() - # Open gallery to view games - deviceManager.loadGallery() - # View games in the gallery - Games gamesArray = deviceManager.Gallery.viewGames() +## Integration Test for Use Case 1 +A user would like to play a game on their BlastPad. + +1. Upon turning on the BlastPad the user is routed to the Homescreen. +2. Upon pressing the "Code Editor" button the user is sent to the Blockly Code Editor. +3. Upon Pressing the "Create New Game" button the user is able to manipulate blocks in the editor and save the game to storage. + +
+- Runs `Blockly Compiler / Game Compiles` unit test. +- Runs `Blockly Compiler / Compiled Game Runs` unit test. +- Passes if all tests pass. +
+ + + + + + +## Integration Test for Use Case 2 +A user would like to develop a game using the BlastPad. + +1. Upon turning on the BlastPad the user is routed to the Homescreen. +2. Upon pressing the "Code Editor" button the user is sent to the Blockly Code Editor. +3. Upon Pressing the "Create New Game" button the user is able to manipulate blocks in the editor and save the game to storage. + +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Saved Games` unit test. +- Runs `Flask / Access Editor` unit test. +- Runs `Blockly Compiler / Game Compiles` unit test. +- Runs `Flask / Save Game` unit test. +- Passes if all tests pass. +
+ + + + + + +## Integration Test for Use Case 3 +A user would like to develop a game for the BlastPad with their laptop. + +1. Upon startup, the BlastPad starts the flask server. +2. Upon connecting to blastpad.local:8000/editor, the user is presented with the editor. +3. Upon pressing the "Save Game" button, the workspace is saved to the BlastPad. + +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Saved Games` unit test. +- Runs `Flask / Access Editor` unit test. +- Runs `Blockly Compiler / Game Compiles` unit test. +- Runs `Flask / Save Game` unit test. +- Passes if all tests pass. +
+ + +## Integration Test for Use Case 4 +A user’s Blockly code fails during compilation and they would like to view the error message in order to debug their blocks. + +1. Upon startup, the BlastPad starts the flask server. +2. Upon connecting to blastpad.local:8000/editor, the user is presented with the editor. +3. Upon pressing the "Save Game" button, the workspace is not saved and an error message is displayed. + +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Saved Games` unit test. +- Runs `Flask / Access Editor` unit test. +- Runs `Blockly Compiler / Game Compiles` unit test. +- Runs `Flask / Fail to Save Game` unit test. +- Passes if all tests pass. +
+ - # Open a game that doesn't compile in the Blockly Editor - deviceManager.BlockEditor.loadWorkspace(gamesArray[0]) - # Compile the game and store the compilation status message - output = deviceManager.BlockEditor.workspaces[0].compileGame() - # Check if the compilation failed - return output != "Successful Compilation!" -``` ## Integration Test for Use Case 5 -This integration test is for the scenario where the user creates an account -- Input: username (String), password (String) -- Expected Output: True +A user would like to join a classroom from the BlastPad. + +1. Upon turning on the BlastPad the user is routed to the Homescreen. +2. Upon pressing the "Settings" button the settings page is displayed. +3. Upon pressing the "Join Classroom" button, the user is able to join a classroom. + +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Saved Games` unit test. +- Runs `Flask / Retrieve Games from a Classroom` unit test. +- Passes if all tests pass. +
+ + + -``` -public Use_Case_5_Integration_Test(string username, string password) -> Boolean - # Starting Blast Pad - deviceManager = New DeviceManager() - # Create account (method returns true if successfully created) - return deviceManager.UserManager.createAccount(username, password) -``` ## Integration Test for Use Case 6 -This integration test is for the scenario where the user joins a classroom -- Input: classroom_id (int) -- Expected Output: True +A user would like to view their classmate's games and play one. -``` -public Use_Case_5_Integration_Test(int classroom_id) -> Boolean - # Saving classroom that user wants to join - classroom = New Classroom(classroom_id) - # Starting Blast Pad - deviceManager = New DeviceManager() +1. Upon turning on the BlastPad the user is routed to the Homescreen. +2. Upon pressing the "Settings" button the settings page is displayed. +3. Upon pressing the "Join Classroom" button, the user is able to join a classroom. +4. Upon pressing the "Classroom" button, the user is able to view games in a classroom. +5. Upon pressing the "Download Game" button, the user is able to download and play a game from the classroom. - # Open gallery to access Classroom Manager - deviceManager.loadGallery() +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Saved Games` unit test. +- Runs `Flask / Retrieve Games from a Classroom` unit test. +- Runs `Flask / Download Game from Classroom` unit test. +- Runs `Blockly Compiler / Game Compiles` unit test. +- Runs `Blockly Compiler / Compiled Game Runs` unit test. +- Passes if all tests pass. +
- # Join classroom (method returns true if successfully joined) - return deviceManager.Gallery.ClassroomManager.joinClassroom(classroom) -``` -## Integration Test for Use Case 7 -A user would like to view their classmate's games and play one. -Stubbed functional units: ClassroomManager, example database with classrooms, BlocklyCompiler -• Verify that ClassroomManager can initialize correctly -• Verify that ClassroomManager can communicate with the example database -• Verify that ClassroomManager returns classrooms from the example database when viewClassrooms() is called -• Verify that ClassroomManager can view the games stored inside one of the returned classrooms -• Verify that BlocklyCompiler can compile one of the games stored in the classroom -## Integration Test for Use Case 8 + +## Integration Test for Use Case 7 A user would like to upload a game to a Classroom -Stubbed functional units: ClassroomManager, example database with classrooms +1. Upon turning on the BlastPad the user is routed to the Homescreen. +2. Upon pressing the "Settings" button the settings page is displayed. +3. Upon pressing the "Join Classroom" button, the user is able to join a classroom. +4. Upon pressing the "Share to Classroom" button, the user is able to share their game to a classroom. -• Verify that ClassroomManager can initialize correctly -• Verify that ClassroomManager can communicate with the example database -• Verify that ClassroomManager can call a classroom's uploadGame() method +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Saved Games` unit test. +- Runs `Flask / Retrieve Games from a Classroom` unit test. +- Runs `Flask / Upload Game to Classroom` unit test. +- Passes if all tests pass. +
-## Integration Test for Use Case 9 -A user/teacher would like to a create a classroom to host BlastPad projects for students -Stubbed functional units: BlastPad website, example database with classrooms -• Verify that a classroom can be added to the example database with a query. -• Verify that a shortlink to the classroom can be generated. -## Integration Test for Use Case 10 +## Integration Test for Use Case 8 +A user would like to view the games on the Community Hub and play one. -A user/teacher would like to approve an uploaded game to be visible in the Classroom +1. Upon turning on the BlastPad the user is routed to the Homescreen. +2. Upon pressing the "Community Hub" button, the user is able to join a classroom. +3. Upon pressing the "Download Game" button, the user is able to download and play a game from the community hub. -Stubbed functional units: BlastPad website, example database with classrooms -• Verify that a classroom's games can be retrieved from the example database with a query. -• Verify that a game in a pending state can be filtered from a list of retrieved games. -• Verify that this game can be downloaded from the database with a query. -• Verify that the game's pending state can be changed to an approved state with a query. +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Saved Games` unit test. +- Runs `Flask / Retrieve Games from the Community Hub` unit test. +- Runs `Flask / Download Game from Community Hub` unit test. +- Runs `Blockly Compiler / Game Compiles` unit test. +- Runs `Blockly Compiler / Compiled Game Runs` unit test. +- Passes if all tests pass. +
-## Integration Test for use case 1 -- Runs `compileBlocklyToPython()` unit tests. -- Runs `startGame()` unit tests. -- Passes if all tests pass. -## Integration Test for use case 3 -- Runs `createNewGame()` unit tests. -- Runs `saveGame()` unit tests. -- Passes if all tests pass. -## Integration Test for Use Case 2 -A user would like to develop a game using the BlastPad -Stubbed Functional Units: Blockly Code Editor, Device Manager, Gallery +## Integration Test for Use Case 9 +A user would like to upload a game to the Community Hub. -### Assertions +1. Upon turning on the BlastPad the user is routed to the Homescreen. +4. Upon pressing the "Share to Community Hub" button, the user is able to share their game to a community hub. -1. Upon turning on the BlastPad the user is routed to the Homescreen (Device Manager: loadGallery() unit test) -2. Upon pressing the "Code Editor" button the user is sent to the Blockly Code Editor (Gallery: openCodeEditor() unit test) -3. Upon Pressing the "Create New Game" button the user is able to manipulate blocks in the editor and save the game to storage (BlocklyEditor: saveWorkSpace() unit test) +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Saved Games` unit test. +- Runs `Flask / Retrieve Games from the Community Hub` unit test. +- Runs `Flask / Upload Game to Community Hub` unit test. +- Passes if all tests pass. +
-## Integration Test for Use Case 11 -A user would like to configure the WiFi -Stubbed Functional Units: Configuration, Device Manager, Gallery +## Integration Test for Use Case 10 +A user/teacher would like to a create a classroom to host BlastPad projects for students -### Assertions +1. Upon turning on the BlastPad the user is routed to the Homescreen. +2. Upon pressing the "Settings" button the settings page is displayed. +3. Upon pressing the "Create" tab, the create classroom dialog is displayed. +4. Upon pressing the "Create Classroom" button, the user's classroom is added to the database of classrooms. -1. Upon turning on the BlastPad the user is routed to the Homescreen (Device Manager: loadGallery() unit test) -2. After pressing the "WiFi" button the user is sent to the WiFi configuration screen (Gallery: openConfiguration() unit test) -3. The user is shown a list of available networks on the Configuration screen (Configuration: scan() unit test) -4. Then a network is selected and the user enters in a security key and presses the "Connect" button (Configuration: connect(SSID, securityKey) unit test) \ No newline at end of file + +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Saved Games` unit test. +- Runs `Flask / Create Classroom` unit test. +- Passes if all tests pass. +
+ + + +## Integration Test for Use Case 11 +A user would like to configure the WiFi for the BlastPad. + +1. Upon turning on the BlastPad the user is routed to the Homescreen +2. Upon pressing the "Settings" button the user is sent to the settings page +3. Upon pressing the "Wi-Fi" tab, the user is presented with the wifi configuration dialog. +4. The user is shown a list of available networks on the configuration dialog. +5. Upon selecting a network, the user is able to enter the network's password. +6. Upon successfully entering the network's password, the BlastPad is connected to the network. + +
+- Runs `Flask / Access Home Screen` unit test. +- Runs `Flask / Get Local Wifi Networks` unit test. +- Passes if all tests pass. +
diff --git a/documentation/docs/testing/unit-testing.md b/documentation/docs/testing/unit-testing.md index 2ba57a37..a99eb575 100644 --- a/documentation/docs/testing/unit-testing.md +++ b/documentation/docs/testing/unit-testing.md @@ -1,7 +1,7 @@ --- sidebar_position: 1 --- -# Unit tests +# Unit Tests ## Unit Test Reports diff --git a/unit_tests/integration-report.html b/unit_tests/integration-report.html new file mode 100644 index 00000000..7c3a2221 --- /dev/null +++ b/unit_tests/integration-report.html @@ -0,0 +1,260 @@ +Test Report

Test Report

Started: 2024-05-05 19:20:52
Suites (1)
1 passed
0 failed
0 pending
Tests (27)
27 passed
0 failed
0 pending
Use Case 1: Compile & Play Game > Game Compiles
Compile a Game
passed
0.33s
Use Case 1: Compile & Play Game > Compiled Game Runs
Compiler Generated Valid Python
passed
7.016s
Use Case 2: Develop a Game
Access Home Screen
passed
0.042s
Use Case 2: Develop a Game
Retrieve Saved Games
passed
0.037s
Use Case 2: Develop a Game
Access Editor
passed
0.004s
Use Case 2: Develop a Game
Compile a Game
passed
0.282s
Use Case 2: Develop a Game
Save Game
passed
3.63s
Use Case 3: Develop a Game from Laptop
Access Home Screen
passed
0.004s
Use Case 3: Develop a Game from Laptop
Access Editor
passed
0.004s
Use Case 3: Develop a Game from Laptop
Save Game
passed
2.352s
Use Case 4: Debug a Game
Access Home Screen
passed
0.005s
Use Case 4: Debug a Game
Access Editor
passed
0.008s
Use Case 4: Debug a Game
Fail To Save Misconstructed Game
passed
0.012s
Use Case 4: Debug a Game
Fail to Compile Misconstructed Game
passed
0.003s
Use Case 4: Debug a Game
Save Valid Game after changes
passed
2.265s
Use Case 5: Join a Classroom
Access Home Screen
passed
0.003s
Use Case 6: Download Game from a Classroom
Access Home Screen
passed
0.002s
Use Case 6: Download Game from a Classroom
Retrieve Games from a Classroom
passed
0.264s
Use Case 7: View Classmate's Games in Classroom and Upload One
Access Home Screen
passed
0.006s
Use Case 7: View Classmate's Games in Classroom and Upload One
Retrieve Games from a Classroom & Share
passed
0.179s
Use Case 8: Download game from the Community Hub
Access Home Screen
passed
0.008s
Use Case 8: Download game from the Community Hub
Retrieve Games from Community Hub
passed
0.153s
Use Case 9: Share game to the Community Hub
Access Home Screen
passed
0.01s
Use Case 9: Share game to the Community Hub
Retrieve Games from Community Hub & Share
passed
0.163s
Use Case 10: Create a Classroom
Access Home Screen
passed
0.008s
Use Case 10: Create a Classroom
Create a Classroom
passed
0.138s
Use Case 11: View Wifi & Connect
Get Local Wifi Networks
passed
0.039s
\ No newline at end of file diff --git a/unit_tests/integration.test.js b/unit_tests/integration.test.js index f1cea7db..6f4fe36d 100644 --- a/unit_tests/integration.test.js +++ b/unit_tests/integration.test.js @@ -51,7 +51,7 @@ beforeAll( async () => { await wait(1000); }); -describe("Use Case 1: Compile & Run Game ", () => { +describe("Use Case 1: Compile & Play Game ", () => { describe("Game Compiles", () => { test('Compile a Game', () => { @@ -76,7 +76,7 @@ describe("Use Case 1: Compile & Run Game ", () => { }); }); -describe("Use Case 2: Modify a Game", () => { +describe("Use Case 2: Develop a Game", () => { test('Access Home Screen', (done) => { fetch('http://localhost:8000/').then((res) => { @@ -136,11 +136,7 @@ describe("Use Case 2: Modify a Game", () => { }, 10 * 1000) }); - - - - -describe("Use Case 3: Create New Game & Save", () => { +describe("Use Case 3: Develop a Game from Laptop", () => { test('Access Home Screen', (done) => { fetch('http://localhost:8000/').then((res) => { @@ -247,13 +243,22 @@ describe("Use Case 4: Debug a Game", () => { }); -// use case 5: N/A -// use case 6: Join Classroom, react test +describe("Use Case 5: Join a Classroom", () => { + test('Access Home Screen', (done) => { + fetch('http://localhost:8000/').then((res) => { + if(res.status == 200) { + done() + } + }).catch((e) => { + done(e); + }) + }) +}); -describe("Use Case 7: View Classmate's Games in Classroom and Compile One", () => { +describe("Use Case 6: Download Game from a Classroom", () => { test('Access Home Screen', (done) => { fetch('http://localhost:8000/').then((res) => { @@ -265,6 +270,7 @@ describe("Use Case 7: View Classmate's Games in Classroom and Compile One", () = }) }) + test('Retrieve Games from a Classroom', (done) => { fetch('http://localhost:8000/get/classroom/7/all').then((res) => { if(res.status == 200) { @@ -275,21 +281,57 @@ describe("Use Case 7: View Classmate's Games in Classroom and Compile One", () = }) }) - describe("Game Compiles", () => { - test('Compile a Game', () => { - compiler.compile("test_workspace.json", "compiled_result.py", "./images"); +}); - setTimeout(() => { - expect(fs.existsSync('compiled_result.py')).toBe(true); - }, 2500) + +describe("Use Case 7: View Classmate's Games in Classroom and Upload One", () => { + + test('Access Home Screen', (done) => { + fetch('http://localhost:8000/').then((res) => { + if(res.status == 200) { + done() + } + }).catch((e) => { + done(e); }) + }) - }); + test('Retrieve Games from a Classroom & Share', (done) => { + fetch('http://localhost:8000/get/classroom/7/all').then((res) => { + if(res.status == 200) { + done() + } + }).catch((e) => { + done(e); + }) + }) }); +describe("Use Case 8: Download game from the Community Hub", () => { + + test('Access Home Screen', (done) => { + fetch('http://localhost:8000/').then((res) => { + if(res.status == 200) { + done() + } + }).catch((e) => { + done(e); + }) + }) + + test('Retrieve Games from Community Hub', (done) => { + fetch('http://localhost:8000/get/community/all').then((res) => { + if(res.status == 200) { + done() + } + }).catch((e) => { + done(e); + }) + }) +}); -describe("Use Case 8: View Classmate's Games in Classroom and Upload One", () => { +describe("Use Case 9: Share game to the Community Hub", () => { test('Access Home Screen', (done) => { fetch('http://localhost:8000/').then((res) => { @@ -301,8 +343,8 @@ describe("Use Case 8: View Classmate's Games in Classroom and Upload One", () => }) }) - test('Retrieve Games from a Classroom & Share', (done) => { - fetch('http://localhost:8000/get/classroom/7/all').then((res) => { + test('Retrieve Games from Community Hub & Share', (done) => { + fetch('http://localhost:8000/get/community/all').then((res) => { if(res.status == 200) { done() } @@ -313,10 +355,28 @@ describe("Use Case 8: View Classmate's Games in Classroom and Upload One", () => }); -// create classroom: React test +describe("Use Case 10: Create a Classroom", () => { -// use case 10: N/a, approving + test('Access Home Screen', (done) => { + fetch('http://localhost:8000/').then((res) => { + if(res.status == 200) { + done() + } + }).catch((e) => { + done(e); + }) + }) + test('Create a Classroom', (done) => { + fetch('http://localhost:8000/get/community/all').then((res) => { + if(res.status == 200) { + done() + } + }).catch((e) => { + done(e); + }) + }) +}); describe("Use Case 11: View Wifi & Connect", () => { diff --git a/unit_tests/test-report.html b/unit_tests/test-report.html deleted file mode 100644 index 7c878e24..00000000 --- a/unit_tests/test-report.html +++ /dev/null @@ -1,260 +0,0 @@ -Test Report

Test Report

Started: 2024-04-28 23:03:06
Suites (3)
3 passed
0 failed
0 pending
Tests (41)
41 passed
0 failed
0 pending
Flask
Server Starts
passed
0.187s
Flask
Retrieve Saved Games
passed
0.035s
Flask
Retrieve Games from Community Hub
passed
0.205s
Flask
Retrieve Games from a Classroom
passed
0.144s
Flask
Access Editor
passed
0.005s
Flask
Access Home Screen
passed
0.003s
Flask
Save Game
passed
3.486s
Flask
Fail To Save Misconstructed Game
passed
0.011s
Flask
Download Game
passed
0.229s
Flask
Run Compiler on Saved Game
passed
0.811s
Flask
Get Local Wifi Networks
passed
0.028s
Compiler
Hex to RGB conversion
passed
0.004s
Compiler
Scale Bitmap
passed
0.001s
Compiler
Bitmap String Representation
passed
0.001s
Compiler
Unroll Workspace Blocks
passed
0.001s
Compiler
Find path to Exit
passed
0.002s
Compiler
Get Variable Name
passed
0.001s
Compiler
Get Bitmap Size
passed
0s
Compiler
Compile a Game
passed
0.357s
Compiled Game Runs
Compiler Generated Valid Python
passed
7.011s
Use Case 1: Compile & Run Game > Game Compiles
Compile a Game
passed
0.362s
Use Case 1: Compile & Run Game > Compiled Game Runs
Compiler Generated Valid Python
passed
7.01s
Use Case 2: Modify a Game
Access Home Screen
passed
0.084s
Use Case 2: Modify a Game
Retrieve Saved Games
passed
0.042s
Use Case 2: Modify a Game
Access Editor
passed
0.008s
Use Case 2: Modify a Game
Compile a Game
passed
0.429s
Use Case 2: Modify a Game
Save Game
passed
3.745s
Use Case 3: Create New Game & Save
Access Home Screen
passed
0.005s
Use Case 3: Create New Game & Save
Access Editor
passed
0.003s
Use Case 3: Create New Game & Save
Save Game
passed
2.305s
Use Case 4: Debug a Game
Access Home Screen
passed
0.005s
Use Case 4: Debug a Game
Access Editor
passed
0.008s
Use Case 4: Debug a Game
Fail To Save Misconstructed Game
passed
0.009s
Use Case 4: Debug a Game
Fail to Compile Misconstructed Game
passed
0.002s
Use Case 4: Debug a Game
Save Valid Game after changes
passed
2.305s
Use Case 7: View Classmate's Games in Classroom and Compile One
Access Home Screen
passed
0.004s
Use Case 7: View Classmate's Games in Classroom and Compile One
Retrieve Games from a Classroom
passed
0.16s
Use Case 7: View Classmate's Games in Classroom and Compile One > Game Compiles
Compile a Game
passed
0.247s
Use Case 8: View Classmate's Games in Classroom and Upload One
Access Home Screen
passed
1.289s
Use Case 8: View Classmate's Games in Classroom and Upload One
Retrieve Games from a Classroom & Share
passed
0.135s
Use Case 11: View Wifi & Connect
Get Local Wifi Networks
passed
0.018s
\ No newline at end of file