test(NotificationsService): add snapshot test to legacy script execution error

This commit is contained in:
Pujit Mehrotra
2024-10-09 11:53:33 -04:00
parent f7cccc8c37
commit 05765495c4
2 changed files with 29 additions and 0 deletions

View File

@@ -6,14 +6,35 @@ exports[`NotificationsService legacy script compatibility > yields correct cli a
©®™✓✓✓—“”‘’" -l "https://unraid.net/?query=param&special=💡🔥✨""
`;
exports[`NotificationsService legacy script compatibility > yields correct cli args for alerts 2`] = `
"Command failed with ENOENT: /usr/local/emhttp/webGui/scripts/notify -i alert -e Test Notification !@#$%^&*()_+={}[]|:;"'<>,.?/~\` -s Test Subject
🚀💻🛠️ -d Test Description with special characters
©®™✓✓✓—“”‘’ -l https://unraid.net/?query=param&special=💡🔥✨
spawn /usr/local/emhttp/webGui/scripts/notify ENOENT"
`;
exports[`NotificationsService legacy script compatibility > yields correct cli args for normals 1`] = `
""/usr/local/emhttp/webGui/scripts/notify" -i normal -e "Test Notification !@#$%^&*()_+={}[]|:;\\"'<>,.?/~\`" -s "Test Subject
🚀💻🛠️" -d "Test Description with special characters
©®™✓✓✓—“”‘’" -l "https://unraid.net/?query=param&special=💡🔥✨""
`;
exports[`NotificationsService legacy script compatibility > yields correct cli args for normals 2`] = `
"Command failed with ENOENT: /usr/local/emhttp/webGui/scripts/notify -i normal -e Test Notification !@#$%^&*()_+={}[]|:;"'<>,.?/~\` -s Test Subject
🚀💻🛠️ -d Test Description with special characters
©®™✓✓✓—“”‘’ -l https://unraid.net/?query=param&special=💡🔥✨
spawn /usr/local/emhttp/webGui/scripts/notify ENOENT"
`;
exports[`NotificationsService legacy script compatibility > yields correct cli args for warnings 1`] = `
""/usr/local/emhttp/webGui/scripts/notify" -i warning -e "Test Notification !@#$%^&*()_+={}[]|:;\\"'<>,.?/~\`" -s "Test Subject
🚀💻🛠️" -d "Test Description with special characters
©®™✓✓✓—“”‘’" -l "https://unraid.net/?query=param&special=💡🔥✨""
`;
exports[`NotificationsService legacy script compatibility > yields correct cli args for warnings 2`] = `
"Command failed with ENOENT: /usr/local/emhttp/webGui/scripts/notify -i warning -e Test Notification !@#$%^&*()_+={}[]|:;"'<>,.?/~\` -s Test Subject
🚀💻🛠️ -d Test Description with special characters
©®™✓✓✓—“”‘’ -l https://unraid.net/?query=param&special=💡🔥✨
spawn /usr/local/emhttp/webGui/scripts/notify ENOENT"
`;

View File

@@ -407,6 +407,14 @@ describe.concurrent('NotificationsService legacy script compatibility', () => {
const result = await execa(cmd, args, { reject: false });
expect.soft(result.escapedCommand).toMatchSnapshot();
if (result.failed) {
// @ts-expect-error this is correct; `execa`'s return type just isn't comprehensive
// see https://github.com/sindresorhus/execa/blob/main/docs/errors.md#error-message
//
//* we use a snapshot because the script should only fail when it doesn't exist (ENOENT)
expect(result.message).toMatchSnapshot();
}
}
);
});