Skip to content

Commit

Permalink
test(Cypress): Update tests to use new mock data
Browse files Browse the repository at this point in the history
  • Loading branch information
lavalleeale committed Apr 9, 2022
1 parent cfb02ca commit 7fb9dea
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 23 deletions.
54 changes: 35 additions & 19 deletions web/cypress/fixtures/status.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
{
"start": {
"errorMessage": "Fake Error Message",
"opModeName": "$Stop$Robot$",
"state": "RUNNING",
"status": "INIT",
"warningMessage": "Fake Warning Message",
"type": "SEND_STATUS"
"warning": {
"type": "telemetry",
"message": {
"tag": "$System$Warning$",
"dataStrings": [{ "value": "Fake Warning Message" }]
}
},
"error": {
"type": "telemetry",
"message": {
"tag": "$System$Error$",
"dataStrings": [{ "value": "Fake Error Message" }]
}
},
"init": {
"errorMessage": "",
"opModeName": "Final TeleOP",
"state": "RUNNING",
"status": "INIT",
"warningMessage": "Fake Warning Message",
"type": "SEND_STATUS"
"type": "activeOpmode",
"value": "Websocket Test"
},
"nonwarning": {
"type": "telemetry",
"message": {
"tag": "$System$Warning$",
"dataStrings": [{ "value": "" }]
}
},
"nonerror": {
"type": "telemetry",
"message": {
"tag": "$System$Error$",
"dataStrings": [{ "value": "" }]
}
},
"started": {
"errorMessage": "Fake Error Message",
"opModeName": "Final TeleOP",
"state": "RUNNING",
"status": "RUNNING",
"warningMessage": "",
"type": "SEND_STATUS"
"type": "runOpmode",
"message": "Websocket Test"
},
"stop": {
"type": "activeOpmode",
"value": "$Stop$Robot$"
}
}
9 changes: 6 additions & 3 deletions web/cypress/integration/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ describe("Basic Interaction", () => {
console.log("connection");
ws.on("message", (message) => {
const decoded = JSON.parse(message as string);
console.log(decoded);
switch (decoded.type) {
case "joinroom":
ws.send(JSON.stringify(opmodes));
ws.send(JSON.stringify(status.start));
ws.send(JSON.stringify(status.warning));
ws.send(JSON.stringify(status.error));
break;
case "INIT_OPMODE":
ws.send(JSON.stringify(status.init));
ws.send(JSON.stringify(status.nonerror));
break;
case "START_OPMODE":
ws.send(JSON.stringify(status.started));
ws.send(JSON.stringify(status.error));
ws.send(JSON.stringify(status.nonwarning));
break;
case "STOP_OPMODE":
ws.send(JSON.stringify(status.start));
ws.send(JSON.stringify(status.stop));
break;
}
});
Expand Down
1 change: 0 additions & 1 deletion web/src/pages/control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ const Control = () => {
if (controller.index === gamepad1) {
setGamepad1(null);
if (ws?.readyState === WebSocket.OPEN) {
// TODO: EMPTY???
ws!.send(
JSON.stringify({
type: "controller",
Expand Down

0 comments on commit 7fb9dea

Please sign in to comment.