Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli-repl): multiline dots and prompts #2191

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/e2e-tests/test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,30 @@ describe('e2e', function () {
shell.assertNoErrors();
});

it('prints only multiline dots between prompts', async function () {
await shell.waitForPrompt();
const outputOffsetBefore = shell.output.length;
shell.writeInputLine(`
const foo = {
bar: "baz"
};
`);

// Wait for some multiline dots
await eventually(() => {
shell.assertContainsOutput('... ...');
});
const outputOffsetAfterDots = shell.output.length;
const output = shell.output
.substring(outputOffsetBefore, outputOffsetAfterDots)
.trim();
// Expect just the multiline dots
expect(output.startsWith('... ...')).equals(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does fail for me, locally, but unfortunately I think that's actually expected behavior? The first prompt printed by mongosh in response to the .writeInputLine() call is a regular prompt, not a multiline prompt, but that's happening because the first line of the writeInputLine() argument is empty/whitespace-only.

That being said ... yeah, there's a good chance that that causes the flakiness in the FLE test at least. I feel like it's probably a good idea to just always .trim() the input to .writeInputLine()? For raw input, there's always .writeInput() itself

Copy link
Contributor Author

@kraenhansen kraenhansen Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Trimming the input to writeInputLine fixed the issue 👍

true,
`Expected output to start with dots, got '${output}'`
);
});

it('runs help command', async function () {
expect(await shell.executeLine('help')).to.include('Shell Help');
shell.assertNoErrors();
Expand Down
Loading