Skip to content

Commit a10848b

Browse files
fix: Test assertions were expecting $ not > in interactive mode
1 parent c67d878 commit a10848b

6 files changed

Lines changed: 35 additions & 33 deletions

File tree

bin/development.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env node
2+
13
// For interactive mode, ensure SIGINT exits with code 130
24
if (process.argv.includes('interactive')) {
35
process.env.ABLY_INTERACTIVE_MODE = 'true';

test/e2e/interactive/ctrl-c-behavior.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
6666
});
6767

6868
// Wait for prompt
69-
await waitForOutput(proc, /\$/);
69+
await waitForOutput(proc, /ably>/);
7070

7171
// Send Ctrl+C
7272
proc.stdin!.write('\u0003');
@@ -79,7 +79,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
7979
expect(output).to.match(/Signal received|Type 'exit' to quit|To exit.*type 'exit'/i);
8080

8181
// Should still have prompt
82-
expect(output).to.include('$');
82+
expect(output).to.include('ably>');
8383

8484
// Clean exit
8585
proc.stdin!.write('exit\n');
@@ -92,7 +92,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
9292
});
9393

9494
// Wait for prompt
95-
await waitForOutput(proc, /\$/);
95+
await waitForOutput(proc, /ably>/);
9696

9797
// Send Ctrl+C
9898
proc.stdin!.write('\u0003');
@@ -136,7 +136,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
136136
// Wait for prompt using simple polling
137137
await new Promise<void>((resolve) => {
138138
const checkInterval = setInterval(() => {
139-
if (output.includes('$ ')) {
139+
if (output.includes('ably> ')) {
140140
clearInterval(checkInterval);
141141
resolve();
142142
}
@@ -177,7 +177,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
177177
const checkInterval = setInterval(() => {
178178
// Look for a new prompt after the command was interrupted
179179
const lines = output.split('\n');
180-
const promptCount = lines.filter(line => line.includes('$ ')).length;
180+
const promptCount = lines.filter(line => line.includes('ably> ')).length;
181181
if (promptCount >= 2) { // Initial prompt + prompt after interrupt
182182
clearInterval(checkInterval);
183183
resolve();
@@ -191,7 +191,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
191191
});
192192

193193
// Verify we're back at the prompt
194-
expect(output).to.include('$ ');
194+
expect(output).to.include('ably> ');
195195

196196
// Send a simple command to verify it's still working
197197
output = '';
@@ -224,7 +224,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
224224
const text = data.toString();
225225

226226
// Count prompts
227-
const prompts = text.match(/\$ /g);
227+
const prompts = text.match(/ably>/g);
228228
if (prompts) {
229229
promptCount += prompts.length;
230230
}
@@ -304,7 +304,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
304304
// Wait for prompt and send test:wait command
305305
await new Promise<void>((resolve) => {
306306
const checkForPrompt = setInterval(() => {
307-
if (output.includes('$')) {
307+
if (output.includes('ably>')) {
308308
clearInterval(checkForPrompt);
309309
proc.stdin!.write('test:wait --duration 10\n');
310310
resolve();
@@ -334,7 +334,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
334334

335335
// Verify we're back at prompt
336336
const lines = output.split('\n');
337-
const promptCount = lines.filter(line => line.includes('$ ')).length;
337+
const promptCount = lines.filter(line => line.includes('ably> ')).length;
338338
expect(promptCount).to.be.at.least(2); // Initial prompt + prompt after interrupt
339339

340340
// Clean exit
@@ -377,7 +377,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
377377
// Wait for prompt
378378
await new Promise<void>((resolve) => {
379379
const checkForPrompt = setInterval(() => {
380-
if (output.includes('$')) {
380+
if (output.includes('ably>')) {
381381
clearInterval(checkForPrompt);
382382
proc.stdin!.write('test:wait --duration 30\n');
383383
resolve();
@@ -430,7 +430,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
430430
});
431431

432432
// Wait for prompt
433-
await waitForOutput(proc, /\$/);
433+
await waitForOutput(proc, /ably>/);
434434

435435
// Type partial command
436436
proc.stdin!.write('test:wa');
@@ -441,7 +441,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
441441
// Should clear line and show new prompt
442442
const output = await captureOutput(proc, 1000);
443443
expect(output).to.include('^C');
444-
expect(output).to.include('$');
444+
expect(output).to.include('ably>');
445445

446446
// Should be able to type new command
447447
proc.stdin!.write('help\n');
@@ -470,7 +470,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
470470
// Wait for initial prompt
471471
await new Promise<void>((resolve) => {
472472
const checkInterval = setInterval(() => {
473-
if (output.includes('$ ')) {
473+
if (output.includes('ably> ')) {
474474
clearInterval(checkInterval);
475475
resolve();
476476
}
@@ -533,7 +533,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
533533
// Wait for initial prompt
534534
await new Promise<void>((resolve) => {
535535
const checkPrompt = setInterval(() => {
536-
if (output.includes('$ ')) {
536+
if (output.includes('ably> ')) {
537537
clearInterval(checkPrompt);
538538
resolve();
539539
}
@@ -566,7 +566,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
566566
await new Promise(resolve => setTimeout(resolve, 1000));
567567

568568
// Should return to prompt
569-
expect(output).to.include('$ ');
569+
expect(output).to.include('ably> ');
570570

571571
// Terminal should be functional - send a simple command
572572
output = '';
@@ -631,7 +631,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
631631
await new Promise<void>((resolve, reject) => {
632632
const timeout = setTimeout(() => reject(new Error('Timeout waiting for initial prompt')), 10000);
633633
const check = setInterval(() => {
634-
if (output.includes('$ ')) {
634+
if (output.includes('ably> ')) {
635635
clearInterval(check);
636636
clearTimeout(timeout);
637637
resolve();
@@ -669,7 +669,7 @@ describe('E2E: Interactive Mode - Ctrl+C Behavior', function() {
669669
expect(output).to.not.include('Failed to start interactive mode');
670670

671671
// We should see a new prompt
672-
expect(output).to.include('$ ');
672+
expect(output).to.include('ably> ');
673673

674674
// Try running a command to verify terminal is functional
675675
output = '';

test/e2e/interactive/wrapper-integration.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Interactive Mode - Wrapper Integration', function() {
3737
// Wait for prompt
3838
await new Promise<void>((resolve) => {
3939
const checkPrompt = setInterval(() => {
40-
if (output.includes('$ ')) {
40+
if (output.includes('ably>')) {
4141
clearInterval(checkPrompt);
4242
resolve();
4343
}
@@ -76,7 +76,7 @@ describe('Interactive Mode - Wrapper Integration', function() {
7676

7777
proc.stdout.on('data', (data) => {
7878
// Count how many times we see the prompt
79-
const matches = data.toString().match(/\$ /g);
79+
const matches = data.toString().match(/ably> /g);
8080
if (matches) {
8181
promptCount += matches.length;
8282
}
@@ -156,7 +156,7 @@ describe('Interactive Mode - Wrapper Integration', function() {
156156
}, 10000);
157157

158158
const checkPrompt = setInterval(() => {
159-
if (output1.includes('$ ')) {
159+
if (output1.includes('ably>')) {
160160
clearInterval(checkPrompt);
161161
clearTimeout(timeout);
162162
resolve();
@@ -189,7 +189,7 @@ describe('Interactive Mode - Wrapper Integration', function() {
189189
// Wait for prompt
190190
await new Promise<void>((resolve) => {
191191
const checkPrompt = setInterval(() => {
192-
if (output2.includes('$ ')) {
192+
if (output2.includes('ably>')) {
193193
clearInterval(checkPrompt);
194194
resolve();
195195
}
@@ -239,7 +239,7 @@ describe('Interactive Mode - Wrapper Integration', function() {
239239
output += text;
240240

241241
// Count prompts
242-
const prompts = text.match(/\$ /g);
242+
const prompts = text.match(/ably> /g);
243243
if (prompts) {
244244
promptCount += prompts.length;
245245
}
@@ -370,7 +370,7 @@ describe('Interactive Mode - Wrapper Integration', function() {
370370
}, 10000);
371371

372372
const interval = setInterval(() => {
373-
if (output.includes('$ ')) {
373+
if (output.includes('ably>')) {
374374
clearInterval(interval);
375375
clearTimeout(timeout);
376376
resolve();
@@ -405,7 +405,7 @@ describe('Interactive Mode - Wrapper Integration', function() {
405405
expect(errorOccurred, 'Terminal corruption error should not occur').to.be.false;
406406

407407
// Should have multiple prompts (initial + after restart)
408-
const promptCount = (output.match(/\$ /g) || []).length;
408+
const promptCount = (output.match(/ably> /g) || []).length;
409409
expect(promptCount).to.be.greaterThan(1);
410410

411411
// Clean exit

test/integration/commands/interactive.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('Interactive Command Integration', function() {
6161

6262
// Verify output
6363
expect(output).to.include('interactive CLI'); // Part of the tagline
64-
expect(output).to.include('$ '); // Prompt
64+
expect(output).to.include('ably>'); // Prompt
6565
expect(output).to.include('Goodbye!');
6666
});
6767

@@ -104,7 +104,7 @@ describe('Interactive Command Integration', function() {
104104
const text = data.toString();
105105
_output += text;
106106
// Count prompts to know when commands have completed
107-
const prompts = text.match(/\$ /g);
107+
const prompts = text.match(/ably>/g);
108108
if (prompts) {
109109
promptCount += prompts.length;
110110
}

test/integration/interactive-mode.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ describe('Interactive Mode Command Tests', function() {
287287
// Should show channels help
288288
expect(output).to.include('Interact with Ably Pub/Sub channels');
289289
// Usage should not have "ably" prefix
290-
expect(output).to.match(/\$\s+channels/);
291-
expect(output).to.not.match(/\$\s+ably\s+channels/);
290+
expect(output).to.match(/ably>\s+channels/);
291+
expect(output).to.not.match(/ably>\s+ably\s+channels/);
292292
done();
293293
});
294294
});

test/unit/commands/interactive-sigint.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ describe('Interactive Mode - SIGINT Handling', () => {
3535

3636

3737
// Count prompts
38-
const promptMatches = output.match(/\$ /g);
38+
const promptMatches = output.match(/ably> /g);
3939
if (promptMatches) {
4040
promptCount += promptMatches.length;
4141
}
4242

4343
// Check for initial prompt (with or without ANSI codes)
44-
if (!promptSeen && (output.includes('$ ') || output.includes('$\u001B'))) {
44+
if (!promptSeen && (output.includes('ably> ') || output.includes('$\u001B'))) {
4545
promptSeen = true;
4646
// Send test:wait command after seeing prompt
4747
setTimeout(() => {
@@ -117,7 +117,7 @@ describe('Interactive Mode - SIGINT Handling', () => {
117117

118118

119119
// Wait for initial prompt
120-
if (!sigintSent && (data.toString().includes('$ ') || data.toString().includes('$\u001B'))) {
120+
if (!sigintSent && (data.toString().includes('ably> ') || data.toString().includes('$\u001B'))) {
121121
sigintSent = true;
122122
// Send SIGINT on empty prompt
123123
setTimeout(() => {
@@ -172,7 +172,7 @@ describe('Interactive Mode - SIGINT Handling', () => {
172172
child.stdout.on('data', (data) => {
173173
_output += data.toString();
174174

175-
if (!commandTyped && (data.toString().includes('$ ') || data.toString().includes('$\u001B'))) {
175+
if (!commandTyped && (data.toString().includes('ably> ') || data.toString().includes('$\u001B'))) {
176176
commandTyped = true;
177177
// Type partial command
178178
child.stdin.write('channels sub');
@@ -219,7 +219,7 @@ describe('Interactive Mode - SIGINT Handling', () => {
219219
child.stdout.on('data', (data) => {
220220
const output = data.toString();
221221

222-
if (!promptSeen && (output.includes('$ ') || output.includes('$\u001B'))) {
222+
if (!promptSeen && (output.includes('ably> ') || output.includes('$\u001B'))) {
223223
promptSeen = true;
224224
// Send test:wait command
225225
setTimeout(() => {

0 commit comments

Comments
 (0)