-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Console input smoke test - enter your name (#4022)
This is a simple console user input test. In both Python and R, the "user" is prompted to enter their name and "Hello ${name}" is echoed back. The test waits until the echo is received in the console output to determine pass/fail. This PR also adds in a pasteToConsole function that simulates a user pasting code as opposed to entering code via a command (to use the console itself more). ### QA Notes All smoke tests should pass!
- Loading branch information
1 parent
73063f2
commit 58e22e1
Showing
5 changed files
with
102 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
test/smoke/src/areas/positron/console/consoleInput.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
|
||
import { Application, Logger, PositronPythonFixtures, PositronRFixtures } from '../../../../../automation'; | ||
import { installAllHandlers } from '../../../utils'; | ||
|
||
export function setup(logger: Logger) { | ||
describe('Console Input', () => { | ||
// Shared before/after handling | ||
installAllHandlers(logger); | ||
|
||
describe('Console Input - Python', () => { | ||
before(async function () { | ||
await PositronPythonFixtures.SetupFixtures(this.app as Application); | ||
}); | ||
|
||
it('Python - Get Input String Console [C667516]', async function () { | ||
const app = this.app as Application; | ||
|
||
const inputCode = `val = input("Enter your name: ") | ||
print(f'Hello {val}!')`; | ||
|
||
await app.workbench.positronConsole.pasteCodeToConsole(inputCode); | ||
|
||
await app.workbench.positronConsole.sendEnterKey(); | ||
|
||
await app.workbench.positronConsole.waitForConsoleContents((contents) => contents.some((line) => line.includes('Enter your name:')) ); | ||
|
||
await app.workbench.positronConsole.typeToConsole('John Doe'); | ||
|
||
await app.workbench.positronConsole.sendEnterKey(); | ||
|
||
await app.workbench.positronConsole.waitForConsoleContents((contents) => contents.some((line) => line.includes('Hello John Doe!')) ); | ||
|
||
}); | ||
}); | ||
|
||
describe('Console Input - R', () => { | ||
before(async function () { | ||
await PositronRFixtures.SetupFixtures(this.app as Application); | ||
}); | ||
|
||
it('R - Get Input String Console [C667517]', async function () { | ||
const app = this.app as Application; | ||
|
||
const inputCode = `val <- readline(prompt = "Enter your name: ") | ||
cat(sprintf('Hello %s!\n', val))`; | ||
|
||
await app.workbench.positronConsole.pasteCodeToConsole(inputCode); | ||
|
||
await app.workbench.positronConsole.sendEnterKey(); | ||
|
||
await app.workbench.positronConsole.waitForConsoleContents((contents) => contents.some((line) => line.includes('Enter your name:')) ); | ||
|
||
await app.workbench.positronConsole.typeToConsole('John Doe'); | ||
|
||
await app.workbench.positronConsole.sendEnterKey(); | ||
|
||
await app.workbench.positronConsole.waitForConsoleContents((contents) => contents.some((line) => line.includes('Hello John Doe!')) ); | ||
|
||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters