PromucFlow_constructor/app/client/packages/rts/src/ctl/utils.test.js
Shrikant Sharat Kandula 81b7727817
chore: Move appsmithctl to RTS (#37531)
Move the `appsmithctl` code to RTS.

RTS' own build system will build `appsmithctl` as well. We're adding two
command scripts, `ctl` and `appsmithctl` to `/opt/bin`, which will be
the entrypoints for this. The `appsmithctl` is now just an alias to the
much shorter and non-redundancy-inducing `ctl`.

We aren't migrating to TypeScript in this PR so we're ignoring the new
`ctl` folder in both `tsconfig.json` and `.eslintrc`. That's temporary,
the next PR will fix that.


## Automation

/test sanity

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11930931528>
> Commit: 90b5f97b801ac8d4b4b0126d85edff3dccc050bd
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11930931528&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Wed, 20 Nov 2024 10:36:02 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

- **New Features**
  - Introduced the `appsmithctl` command for easier command execution.
  - Updated build process to include additional entry points.

- **Bug Fixes**
- Streamlined Docker build process, enhancing efficiency and reducing
complexity.

- **Documentation**
- Added a new section in the README for `appsmithctl` command
description.

- **Chores**
  - Updated dependencies in `package.json`.
  - Removed obsolete files and workflows to simplify project structure.

- **Style**
  - Added a new ESLint configuration for specific project needs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-11-20 20:58:38 +05:30

69 lines
1.8 KiB
JavaScript

const { describe, test, expect } = require("@jest/globals");
const utils = require("./utils");
describe("execCommandReturningOutput", () => {
test("Output of echo", async () => {
const result = await utils.execCommandReturningOutput([
"echo",
"hello",
"world",
]);
expect(result).toBe("hello world");
});
test("Node console out", async () => {
const result = await utils.execCommandReturningOutput([
"node",
"--eval",
"console.log('to out')",
]);
expect(result).toBe("to out");
});
test("Node console err", async () => {
const result = await utils.execCommandReturningOutput([
"node",
"--eval",
"console.error('to err')",
]);
expect(result).toBe("to err");
});
test("Node console out and err", async () => {
const result = await utils.execCommandReturningOutput([
"node",
"--eval",
"console.log('to out'); console.error('to err')",
]);
expect(result).toBe("to out\nto err");
});
test("Node console err and out", async () => {
const result = await utils.execCommandReturningOutput([
"node",
"--eval",
"console.error('to err'); console.log('to out')",
]);
expect(result).toBe("to out\nto err");
});
});
describe("execCommandSilent", () => {
test("Runs a command", async () => {
await utils.execCommandSilent(["echo"]);
});
test("silences stdout and stderr", async () => {
const consoleSpy = jest.spyOn(console, "log");
await utils.execCommandSilent(["node", "--eval", "console.log('test')"]);
expect(consoleSpy).not.toHaveBeenCalled();
consoleSpy.mockRestore();
});
test("handles errors silently", async () => {
await expect(
utils.execCommandSilent(["nonexistentcommand"]),
).rejects.toThrow();
});
});