Skip to content

Commit 1bcc4d0

Browse files
fix: resolve linting errors and increase rate limit pause for web CLI tests
- Fix linting errors in interactive-mode.test.ts (forEach in describe block) - Fix unused variables in help.test.ts by prefixing with underscore - Remove unused Config import from support.test.ts - Add eslint-disable comments for necessary any types - Add eslint-disable comments for legitimately skipped tests - Remove obsolete test for command timeouts feature - Increase rate limit pause from 61s to 75s for CI_FAST config - Reduce connections per batch from 9 to 8 for more safety
1 parent e111cbd commit 1bcc4d0

14 files changed

Lines changed: 475 additions & 20 deletions

cli-help-standardisation.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# 🛠 Ably CLI Restructure: Help System and Support Topic
2+
3+
## Objective
4+
5+
Align the CLI with industry standards by:
6+
7+
* Making the `help` command idiomatic and intuitive
8+
* Avoiding overloaded or redundant command names (e.g. `help help`, `support support`)
9+
* Promoting support-related features to a dedicated and clearly named topic
10+
11+
---
12+
13+
## 🎯 Key Changes
14+
15+
### ✅ 1. Update `help` Command Behavior
16+
17+
#### Current:
18+
19+
* `ably help` shows all commands and also includes `help ask`, `help contact`, etc.
20+
* `help` is treated as both a command and a topic, leading to confusion.
21+
22+
#### New behavior:
23+
24+
* `ably help` or `ably` → show standard CLI usage and list of root commands.
25+
* `ably help <command>` → show help for that command (equivalent to `ably <command> --help`).
26+
* `--help` or `-h` → supported on all commands and subcommands.
27+
* `help` is no longer treated as a parent command topic (remove `help ask`, `help contact`, etc).
28+
29+
#### Notes:
30+
31+
* Ensure command-specific help works with both `--help` and `help <command>`.
32+
* The interactive shell should behave consistently with the above (`help` triggers the standard usage view).
33+
34+
---
35+
36+
### ✅ 2. Promote `status` to a Top-Level Command
37+
38+
#### Old:
39+
40+
* `help status`
41+
42+
#### New:
43+
44+
* `ably status`
45+
46+
#### Behavior:
47+
48+
* Show current Ably service status
49+
* Optionally support `--open` flag to launch status page in browser
50+
51+
---
52+
53+
### ✅ 3. Create a New `support` Topic
54+
55+
Rename and regroup support-related subcommands under a new topic: `support`.
56+
57+
#### Command structure:
58+
59+
```bash
60+
ably support ask
61+
ably support contact
62+
ably support info
63+
```
64+
65+
#### Command Details:
66+
67+
| Command | Description |
68+
| ---------------------- | --------------------------------------------------------- |
69+
| `ably support ask` | Interact with the Ably AI assistant for usage questions |
70+
| `ably support contact` | Show how to contact Ably (e.g. email, portal, link) |
71+
| `ably support info` | Show general support guidance (previously `help support`) |
72+
73+
* `ably support` without args → show summary of available subcommands (ask, contact, info).
74+
* Remove `help ask`, `help contact`, `help support`.
75+
76+
---
77+
78+
## 🧹 Cleanup and Consistency
79+
80+
* Remove all traces of the old `help` subcommands from help output and CLI structure.
81+
* Ensure all commands under `support` and `status` have:
82+
83+
* Proper descriptions in `--help` output
84+
* Tab completion (if supported)
85+
* Visibility in interactive mode's root listing (or in the “support” section)
86+
87+
---
88+
89+
## 📋 Final Command Overview
90+
91+
| Command | Description |
92+
| ----------------------- | ------------------------------------------------- |
93+
| `ably help` | Show help and list of top-level commands |
94+
| `ably <command> --help` | Show help for a specific command |
95+
| `ably help <command>` | Alias for above |
96+
| `ably status` | Check the current status of Ably systems |
97+
| `ably support ask` | Ask Ably’s AI assistant a usage question |
98+
| `ably support contact` | Show how to reach Ably’s support team |
99+
| `ably support info` | General support resources and documentation links |
100+
101+
---
102+
103+
## 🗣 Messaging / UX Suggestions
104+
105+
* In `ably --help` output, add a **Support Commands** section:
106+
107+
```
108+
SUPPORT COMMANDS
109+
support ask Ask the Ably AI assistant a usage question
110+
support contact Show how to contact Ably
111+
support info General support resources and links
112+
status Check current status of Ably's platform
113+
```
114+
115+
* In interactive mode welcome message, consider:
116+
117+
```
118+
Type 'help' to see all commands. Need assistance? Try 'support ask' or 'support contact'.
119+
```
120+
121+
# CLI Terminal Server
122+
123+
Please look at the code in the Terminal Server (/cli-terminal-server) and investigate what tests or code may depend on this structure that may now need updating. For example, we have `help web-cli` command which will no longer exist. Consider whether we should change `help web-cli` completely and just make it an argument of the root level help command such as --web-cli. Consider whether there are any other hidden commands under help too that need addressing. Make changes to both repositories to reflect these changes.
124+
125+
Once done, ensure all tests and linting is passing in the main CLI.
126+
127+
We will then need to do a minor release of the CLI, so that we can test the changes in the CLI terminal server. Confirm when that is ready to be done, and bump the 0.9.0-alpha.[version] and tell me when to publish the NPM package.
128+
129+
---
130+
131+
## ✅ Deliverables Checklist
132+
133+
* [ ] Remove existing `help` subcommands from the command tree
134+
* [ ] Add `support` topic and subcommands:
135+
* [ ] `support ask`
136+
* [ ] `support contact`
137+
* [ ] `support info`
138+
* [ ] Promote `status` to root command
139+
* [ ] Ensure `help`, `--help`, and `help <command>` all work consistently
140+
* [ ] Update CLI banner, `--help` output, and interactive shell messages
141+
* [ ] Validate everything in interactive and non-interactive modes
142+
* [ ] Ensure Terminal Server is updated to reflect these changes
143+
* [ ] Once all tests in main are passing, confirm changes are made, so that we can bump the version and release a new NPM pacakge so that we can test the terminal server changes.
144+

docker-first-test-changes.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
1. WebSocket Ctrl+C Handling Tests (Missing TypeScript Implementation)
2+
3+
- Need to create TypeScript test files for Ctrl+C behavior (currently only compiled JS exists in dist/)
4+
- Test JSON payload format: {"type":"data","payload":"\x03"}
5+
- Test that readline properly receives and processes Ctrl+C
6+
- Test signal feedback message behavior
7+
- Test prompt restoration after Ctrl+C
8+
9+
2. Docker CLI Direct Tests Updates
10+
11+
- Update expected behavior for ably-interactive wrapper script
12+
- Remove skipped tests that are now fixed:
13+
- Welcome message suppression after Ctrl+C
14+
- Multiple Ctrl+C handling
15+
- Immediate feedback on Ctrl+C
16+
17+
3. WebSocket Message Handling Tests
18+
19+
- Test that JSON WebSocket messages are properly parsed and only payload is sent to container
20+
- Test that raw JSON is never displayed in terminal output
21+
- Test proper handling of different message types: data, signal, resize
22+
23+
4. Interactive Mode Command Tests
24+
25+
- Test version command works in interactive mode
26+
- Test all INTERACTIVE_UNSUITABLE_COMMANDS are properly blocked:
27+
- autocomplete
28+
- config
29+
- version (as a command line argument, not the interactive command)
30+
- mcp
31+
32+
5. Network Security Message Tests
33+
34+
- Update tests to expect no [Network Security] message in normal mode
35+
- Add tests for debug mode where message should appear
36+
- Update existing tests that filter out this message
37+
38+
6. Terminal Server Integration Tests
39+
40+
- Replace placeholder tests in terminal-server.test.ts
41+
- Add actual WebSocket connection establishment tests
42+
- Add authentication flow tests
43+
- Add session management tests
44+
- Add command execution through WebSocket tests
45+
46+
7. Exit Code and Signal Handling Tests
47+
48+
- Test exit code 42 for wrapper mode
49+
- Test exit code 0 for direct mode
50+
- Test exit code 130 for SIGINT
51+
- Test proper cleanup on different exit scenarios
52+
53+
8. Welcome Message and Prompt Tests
54+
55+
- Test welcome message appears only once on startup
56+
- Test ABLY_SUPPRESS_WELCOME environment variable
57+
- Test prompt restoration without welcome after Ctrl+C
58+
- Test proper prompt display after commands
59+
60+
9. Anonymous Mode Restriction Tests
61+
62+
- Update tests for ABLY_ANONYMOUS_USER_MODE
63+
- Test restricted commands in anonymous mode
64+
- Test that security message behavior differs in anonymous mode
65+
66+
10. Performance and Load Tests
67+
68+
- Update load tests to account for new signal handling
69+
- Test concurrent Ctrl+C handling across multiple sessions
70+
- Test resource cleanup under load
71+
72+
11. Test Infrastructure Updates
73+
74+
- Update Dockerfile version reference from @ably/cli@0.9.0-alpha.3 to new version
75+
- Update test timeouts to account for wrapper script restart behavior
76+
- Add test utilities for WebSocket message construction
77+
- Update test documentation to reflect Docker-first testing strategy
78+
79+
12. Manual Test Scripts
80+
81+
- Update manual test scripts in tests/manual/ to reflect new behavior
82+
- Add manual test for interactive mode with wrapper script
83+
- Update signal handling manual tests
84+
85+
Key Behavioral Changes to Test
86+
87+
1. Ctrl+C no longer exits the container - wrapper script restarts the process
88+
2. Welcome message suppression works correctly after Ctrl+C
89+
3. Version command available as hidden command in interactive mode
90+
4. JSON messages are parsed, not displayed raw
91+
5. Network security message only in debug mode
92+
6. Signal feedback ("Signal received") on first Ctrl+C
93+
7. MCP command blocked in interactive mode
94+
95+
All tests should follow the "Docker First, WebSocket Second" principle - verify actual Docker behavior first, then ensure WebSocket layer matches exactly.

src/base-topic-command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export abstract class BaseTopicCommand extends InteractiveBaseCommand {
2020
// Show help for this topic command using CustomHelp
2121
const { default: CustomHelp } = await import('./help.js');
2222
const help = new CustomHelp(this.config);
23+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2324
await help.showCommandHelp(this.constructor as any);
2425
return;
2526
}

src/interactive-base-command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export abstract class InteractiveBaseCommand extends Command {
3131
}
3232

3333
// In normal mode or when exit is false, use default behavior
34+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3435
return super.error(input, options as any);
3536
}
3637

test/e2e/web-cli/reconnection.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ test.describe('Web CLI Reconnection E2E Tests', () => {
440440
await expect(page.locator(statusSelector)).toHaveText('connected', { timeout: 15000 });
441441
});
442442

443-
test.skip('should show manual reconnect prompt after max attempts', async ({ page }) => {
443+
// eslint-disable-next-line mocha/no-skipped-tests
444+
test.skip('should show manual reconnect prompt after max attempts - COMPLEX test with timing issues', async ({ page }) => {
444445
test.setTimeout(90000); // Extended timeout for multiple reconnection attempts
445446

446447
// Helper to add WebSocket interception

test/e2e/web-cli/terminal-ui.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ test.describe('Web CLI Terminal UI Tests', () => {
99
test.setTimeout(120_000); // Overall test timeout
1010

1111
test.describe('Connection Animation', () => {
12-
test.skip('should display ASCII box animation during connection', async ({ page }) => {
12+
// eslint-disable-next-line mocha/no-skipped-tests
13+
test.skip('should display ASCII box animation during connection - TIMING sensitive test', async ({ page }) => {
1314
const apiKey = process.env.E2E_ABLY_API_KEY || process.env.ABLY_API_KEY;
1415
if (!apiKey) {
1516
throw new Error('E2E_ABLY_API_KEY or ABLY_API_KEY environment variable is required for e2e tests');

test/e2e/web-cli/test-rate-limiter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ const getConfig = () => {
5353
}
5454
case 'CI_FAST': {
5555
return {
56-
connectionsPerBatch: 9, // Aggressive for CI (10 per minute limit with 1 buffer)
57-
pauseDuration: 61000, // 61 seconds to ensure rate limit window reset
56+
connectionsPerBatch: 8, // Reduced from 9 to 8 for more safety
57+
pauseDuration: 75000, // Increased from 61s to 75s for extra safety
5858
};
5959
}
6060
case 'CI_EMERGENCY': {

test/integration/interactive-mode.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('Interactive Mode Command Tests', function() {
9090
'mcp'
9191
];
9292

93-
unsuitableCommands.forEach(cmd => {
93+
for (const cmd of unsuitableCommands) {
9494
it(`should block ${cmd} command in interactive mode`, function(done) {
9595
this.timeout(timeout);
9696

@@ -137,16 +137,16 @@ describe('Interactive Mode Command Tests', function() {
137137
child.on('exit', () => {
138138
const fullOutput = output + errorOutput;
139139
// Should either show "not available" or "command not found"
140-
if (!blockedMessage && !fullOutput.match(/command.*not.*found|Unknown command/i)) {
140+
if (!blockedMessage && !/command.*not.*found|Unknown command/i.test(fullOutput)) {
141141
console.log(`Test failed for ${cmd}:`);
142142
console.log('Output:', output);
143143
console.log('Error:', errorOutput);
144144
}
145-
expect(blockedMessage || fullOutput.match(/command.*not.*found|Unknown command/i)).to.be.true;
145+
expect(blockedMessage || /command.*not.*found|Unknown command/i.test(fullOutput)).to.be.true;
146146
done();
147147
});
148148
});
149-
});
149+
}
150150
});
151151

152152
describe('Ably Command Feedback', function() {

test/unit/commands/help.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import HelpCommand from '../../../src/commands/help.js';
66

77
describe('Help Command Tests', function() {
88
let sandbox: sinon.SinonSandbox;
9-
let consoleLogStub: sinon.SinonStub;
10-
let processExitStub: sinon.SinonStub;
9+
let _consoleLogStub: sinon.SinonStub;
10+
let _processExitStub: sinon.SinonStub;
1111

1212
beforeEach(function() {
1313
sandbox = sinon.createSandbox();
14-
consoleLogStub = sandbox.stub(console, 'log');
15-
processExitStub = sandbox.stub(process, 'exit');
14+
_consoleLogStub = sandbox.stub(console, 'log');
15+
_processExitStub = sandbox.stub(process, 'exit');
1616
});
1717

1818
afterEach(function() {

test/unit/commands/interactive-enhanced-simple.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ describe('Interactive Command - Enhanced Features (Simplified)', () => {
113113
});
114114
});
115115

116-
it.skip('should timeout long-running commands', async () => {
117-
// SKIP: The interactive command no longer implements command timeouts
118-
// Long-running commands can be interrupted with Ctrl+C instead
119-
});
116+
// Removed test: The interactive command no longer implements command timeouts
117+
// Long-running commands can be interrupted with Ctrl+C instead
120118

121119
it('should manage runningCommand state', async () => {
122120
// The interactive command tracks if a command is running

0 commit comments

Comments
 (0)