Skip to content

Commit 0b5fdac

Browse files
committed
Fix an e2e test
1 parent c613507 commit 0b5fdac

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

freebuff/e2e/tests/slash-commands.e2e.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { afterEach, describe, expect, test } from 'bun:test'
33
import { FreebuffSession, requireFreebuffBinary } from '../utils'
44

55
const TEST_TIMEOUT = 60_000
6+
const SESSION_HEIGHT = 40
67

78
/**
89
* Commands that should be REMOVED in Freebuff.
@@ -51,11 +52,13 @@ describe('Freebuff: Slash Commands', () => {
5152
'slash command menu does not show removed commands',
5253
async () => {
5354
const binary = requireFreebuffBinary()
54-
session = await FreebuffSession.start(binary, { waitSeconds: 5 })
55+
session = await FreebuffSession.start(binary, { waitSeconds: 5, height: SESSION_HEIGHT })
5556

5657
// Type "/" to trigger the slash command autocomplete menu
57-
await session.send('/', { noEnter: true })
58-
const output = await session.capture(2)
58+
// Use sendKey instead of send to avoid C-u clearing keystroke that
59+
// interferes with opentui's input handling in newer versions
60+
await session.sendKey('/')
61+
const output = await session.capture(4)
5962

6063
// Removed commands should NOT appear in the autocomplete menu
6164
for (const cmd of REMOVED_COMMANDS) {
@@ -71,11 +74,11 @@ describe('Freebuff: Slash Commands', () => {
7174
'slash command menu shows kept commands',
7275
async () => {
7376
const binary = requireFreebuffBinary()
74-
session = await FreebuffSession.start(binary, { waitSeconds: 5 })
77+
session = await FreebuffSession.start(binary, { waitSeconds: 5, height: SESSION_HEIGHT })
7578

7679
// Type "/" to trigger the slash command autocomplete menu
77-
await session.send('/', { noEnter: true })
78-
const output = await session.capture(2)
80+
await session.sendKey('/')
81+
const output = await session.capture(4)
7982

8083
// Kept commands SHOULD appear in the autocomplete menu
8184
for (const cmd of KEPT_COMMANDS) {
@@ -90,11 +93,12 @@ describe('Freebuff: Slash Commands', () => {
9093
'no mode-related slash commands are visible',
9194
async () => {
9295
const binary = requireFreebuffBinary()
93-
session = await FreebuffSession.start(binary, { waitSeconds: 5 })
96+
session = await FreebuffSession.start(binary, { waitSeconds: 5, height: SESSION_HEIGHT })
9497

9598
// Type "/mode" to check for mode commands
96-
await session.send('/mode', { noEnter: true })
97-
const output = await session.capture(2)
99+
// Use sendKey for the full string to avoid C-u clearing the input
100+
await session.sendKey('/mode')
101+
const output = await session.capture(4)
98102

99103
// Mode commands should not exist in Freebuff
100104
expect(output).not.toContain('mode:max')

freebuff/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"release": "bun cli/release.ts",
77
"build:binary": "bun cli/build.ts 0.0.0-dev",
8-
"e2e": "bun test e2e/tests/",
8+
"e2e": "bun run build:binary && bun test e2e/tests/",
99
"e2e:version": "bun test e2e/tests/version.e2e.test.ts",
1010
"e2e:startup": "bun test e2e/tests/startup.e2e.test.ts",
1111
"e2e:help": "bun test e2e/tests/help-command.e2e.test.ts",

0 commit comments

Comments
 (0)