-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from zamm-dev/windows-escape-codes
Handle recorded Windows terminal escape codes
- Loading branch information
Showing
19 changed files
with
322 additions
and
40 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,27 @@ | ||
import { TauriInvokePlayback } from "./sample-call-testing"; | ||
|
||
describe("TauriInvokePlayback", () => { | ||
it("should mock matched calls", async () => { | ||
const playback = new TauriInvokePlayback(); | ||
playback.addCalls({ | ||
request: ["command", { inputArg: "input" }], | ||
response: { outputKey: "output" }, | ||
succeeded: true, | ||
}); | ||
const result = await playback.mockCall("command", { inputArg: "input" }); | ||
expect(result).toEqual({ outputKey: "output" }); | ||
}); | ||
|
||
it("should throw an error for unmatched calls", async () => { | ||
const playback = new TauriInvokePlayback(); | ||
playback.addCalls({ | ||
request: ["command", { inputArg: "input" }], | ||
response: { outputKey: "output" }, | ||
succeeded: true, | ||
}); | ||
expect(() => playback.mockCall("command", { inputArg: "wrong" })).toThrow( | ||
'No matching call found for ["command",{"inputArg":"wrong"}].\n' + | ||
'Candidates are ["command",{"inputArg":"input"}]', | ||
); | ||
}); | ||
}); |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,18 @@ | ||
request: | ||
- run_command | ||
- > | ||
{ | ||
"command": "cmd" | ||
} | ||
response: | ||
message: > | ||
{ | ||
"id": "319cc7fd-58cc-4320-ab46-2f0ba11c5402", | ||
"timestamp": "2024-10-17T06:02:13", | ||
"output": "Microsoft Windows [Version 10.0.22631.4169]\n(c) Microsoft Corporation. All rights reserved.\n\nC:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri>" | ||
} | ||
sideEffects: | ||
database: | ||
endStateDump: command-run-cmd | ||
terminal: | ||
recordingFile: windows.cast |
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
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
17 changes: 17 additions & 0 deletions
17
src-tauri/api/sample-calls/send_command_input-cmd-dir.yaml
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 @@ | ||
request: | ||
- send_command_input | ||
- > | ||
{ | ||
"session_id": "319cc7fd-58cc-4320-ab46-2f0ba11c5402", | ||
"input": "dir" | ||
} | ||
response: | ||
message: > | ||
"dir\n Volume in drive C is Windows\n Volume Serial Number is 30A7-E02E\n\n Directory of C:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri\n\n25/09/2024 05:54 pm <DIR> .\n20/09/2024 07:02 pm <DIR> ..\n14/02/2024 08:37 pm 73 .gitignore\n14/02/2024 08:37 pm 52 .rustfmt.toml\n17/10/2024 12:47 pm <DIR> api\n14/02/2024 08:37 pm <DIR> binaries\n14/02/2024 08:37 pm 90 build.rs\n25/09/2024 05:54 pm 142,536 Cargo.lock\n17/10/2024 12:58 pm 2,102 Cargo.toml\n20/09/2024 07:02 pm 830 clippy.py\n14/02/2024 08:37 pm 244 diesel.toml\n20/09/2024 07:02 pm <DIR> icons\n14/05/2024 03:37 pm 495 Makefile\n20/09/2024 07:02 pm <DIR> migrations\n14/02/2024 08:37 pm <DIR> sounds\n17/10/2024 12:47 pm <DIR> src\n25/06/2024 08:14 pm <DIR> target\n20/09/2024 07:02 pm 1,645 tauri.conf.json\n 9 File(s) 148,067 bytes\n 9 Dir(s) 190,782,652,416 bytes free\n\nC:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri>" | ||
sideEffects: | ||
database: | ||
startStateDump: command-run-cmd | ||
endStateDump: command-run-cmd-dir | ||
terminal: | ||
recordingFile: windows.cast | ||
startingIndex: 1 |
1 change: 1 addition & 0 deletions
1
src-tauri/api/sample-database-writes/command-run-cmd-dir/dump.sql
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 @@ | ||
INSERT INTO asciicasts VALUES('319cc7fd-58cc-4320-ab46-2f0ba11c5402','2024-10-17 06:02:13','cmd','Windows',replace('{"version":2,"width":80,"height":24,"timestamp":1729144933,"command":"cmd"}\012[0.208,"o","\u001b[?25l\u001b[2J\u001b[m\u001b[HMicrosoft Windows [Version 10.0.22631.4169]\r\n(c) Microsoft Corporation. All rights reserved.\u001b[4;1HC:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri>\u001b]0;C:\\WINDOWS\\system32\\cmd.EXE\u0007\u001b[?25h"]\012[0.208,"i","dir\r\n"]\012[0.41,"o","\u001b[?25ldir\r\n Volume in drive C is Windows\r\n Volume Serial Number is 30A7-E02E\u001b[8;1H Directory of C:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri\u001b[10;1H25/09/2024 05:54 pm <DIR> .\r\n20/09/2024 07:02 pm <DIR> ..\r\n14/02/2024 08:37 pm 73 .gitignore\r\n14/02/2024 08:37 pm 52 .rustfmt.toml\r\n17/10/2024 12:47 pm <DIR> api\r\n14/02/2024 08:37 pm <DIR> binaries\r\n14/02/2024 08:37 pm 90 build.rs\r\n25/09/2024 05:54 pm 142,536 Cargo.lock\r\n17/10/2024 12:58 pm 2,102 Cargo.toml\r\n20/09/2024 07:02 pm 830 clippy.py\r\n14/02/2024 08:37 pm 244 diesel.toml\r\n20/09/2024 07:02 pm <DIR> icons\r\n14/05/2024 03:37 pm 495 Makefile\r\n20/09/2024 07:02 pm <DIR> migrations\r\n14/02/2024 08:37 pm <DIR> sounds\r\u001b]0;C:\\WINDOWS\\system32\\cmd.EXE - dir\u0007\u001b[?25h\n17/10/2024 12:47 pm <DIR> src\r\n25/06/2024 08:14 pm <DIR> target\r\n20/09/2024 07:02 pm 1,645 tauri.conf.json\r\n 9 File(s) 148,067 bytes\r\n 9 Dir(s) 190,782,652,416 bytes free\r\n\u001b]0;C:\\WINDOWS\\system32\\cmd.EXE\u0007\nC:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri>"]','\012',char(10))); |
22 changes: 22 additions & 0 deletions
22
src-tauri/api/sample-database-writes/command-run-cmd-dir/dump.yaml
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,22 @@ | ||
terminal_sessions: | ||
- id: 319cc7fd-58cc-4320-ab46-2f0ba11c5402 | ||
timestamp: 2024-10-17T06:02:13 | ||
command: cmd | ||
os: Windows | ||
cast: | ||
header: | ||
version: 2 | ||
width: 80 | ||
height: 24 | ||
timestamp: 1729144933 | ||
command: cmd | ||
entries: | ||
- - 0.208 | ||
- 'o' | ||
- "\e[?25l\e[2J\e[m\e[HMicrosoft Windows [Version 10.0.22631.4169]\r\n(c) Microsoft Corporation. All rights reserved.\e[4;1HC:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri>\e]0;C:\\WINDOWS\\system32\\cmd.EXE\a\e[?25h" | ||
- - 0.208 | ||
- 'i' | ||
- "dir\r\n" | ||
- - 0.41 | ||
- 'o' | ||
- "\e[?25ldir\r\n Volume in drive C is Windows\r\n Volume Serial Number is 30A7-E02E\e[8;1H Directory of C:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri\e[10;1H25/09/2024 05:54 pm <DIR> .\r\n20/09/2024 07:02 pm <DIR> ..\r\n14/02/2024 08:37 pm 73 .gitignore\r\n14/02/2024 08:37 pm 52 .rustfmt.toml\r\n17/10/2024 12:47 pm <DIR> api\r\n14/02/2024 08:37 pm <DIR> binaries\r\n14/02/2024 08:37 pm 90 build.rs\r\n25/09/2024 05:54 pm 142,536 Cargo.lock\r\n17/10/2024 12:58 pm 2,102 Cargo.toml\r\n20/09/2024 07:02 pm 830 clippy.py\r\n14/02/2024 08:37 pm 244 diesel.toml\r\n20/09/2024 07:02 pm <DIR> icons\r\n14/05/2024 03:37 pm 495 Makefile\r\n20/09/2024 07:02 pm <DIR> migrations\r\n14/02/2024 08:37 pm <DIR> sounds\r\e]0;C:\\WINDOWS\\system32\\cmd.EXE - dir\a\e[?25h\n17/10/2024 12:47 pm <DIR> src\r\n25/06/2024 08:14 pm <DIR> target\r\n20/09/2024 07:02 pm 1,645 tauri.conf.json\r\n 9 File(s) 148,067 bytes\r\n 9 Dir(s) 190,782,652,416 bytes free\r\n\e]0;C:\\WINDOWS\\system32\\cmd.EXE\a\nC:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri>" |
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 @@ | ||
INSERT INTO asciicasts VALUES('319cc7fd-58cc-4320-ab46-2f0ba11c5402','2024-10-17 06:02:13','cmd','Windows',replace('{"version":2,"width":80,"height":24,"timestamp":1729144933,"command":"cmd"}\012[0.208,"o","\u001b[?25l\u001b[2J\u001b[m\u001b[HMicrosoft Windows [Version 10.0.22631.4169]\r\n(c) Microsoft Corporation. All rights reserved.\u001b[4;1HC:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri>\u001b]0;C:\\WINDOWS\\system32\\cmd.EXE\u0007\u001b[?25h"]','\012',char(10))); |
16 changes: 16 additions & 0 deletions
16
src-tauri/api/sample-database-writes/command-run-cmd/dump.yaml
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,16 @@ | ||
terminal_sessions: | ||
- id: 319cc7fd-58cc-4320-ab46-2f0ba11c5402 | ||
timestamp: 2024-10-17T06:02:13 | ||
command: cmd | ||
os: Windows | ||
cast: | ||
header: | ||
version: 2 | ||
width: 80 | ||
height: 24 | ||
timestamp: 1729144933 | ||
command: cmd | ||
entries: | ||
- - 0.208 | ||
- 'o' | ||
- "\e[?25l\e[2J\e[m\e[HMicrosoft Windows [Version 10.0.22631.4169]\r\n(c) Microsoft Corporation. All rights reserved.\e[4;1HC:\\Users\\Amos Ng\\Documents\\projects\\zamm-dev\\zamm\\src-tauri>\e]0;C:\\WINDOWS\\system32\\cmd.EXE\a\e[?25h" |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod models; | ||
mod parse; | ||
mod run; | ||
mod send_input; | ||
|
||
|
Oops, something went wrong.