Skip to content

Commit

Permalink
Add missing awaits to async expects in proj wizard tests (#4156)
Browse files Browse the repository at this point in the history
NOTE: this PR is waiting on input from @sharon-wang. We have one case
that doesn't pass once the awaits were added and want to get her
thoughts on it.


This PR simply adds awaits where they were missing on the project wizard
tests. Just to be safe, the timeouts for the async blocks in question
were also bumped significantly.

No change in execution functionality was observed on a fast Mac.
Problems were encountered, however, in CI.
### QA Notes

All smoke tests should pass.

---------

Co-authored-by: Jon Vanausdeln <[email protected]>
  • Loading branch information
testlabauto and jonvanausdeln authored Jul 29, 2024
1 parent 9b40f51 commit 0fc8636
Showing 1 changed file with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export function setup(logger: Logger) {
await pw.currentOrNewWindowSelectionModal.currentWindowButton.click();
await app.workbench.positronExplorer.explorerProjectTitle.waitForText('myPythonProject');
await app.workbench.positronConsole.waitForReady('>>>', 10000);
await app.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
await app.workbench.positronConsole.barClearButton.click();
await app.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
});
it('Create a new Conda environment [C628628]', async function () {
// This test relies on Conda already being installed on the machine
Expand All @@ -52,12 +55,15 @@ export function setup(logger: Logger) {
`myPythonProject${projSuffix}`
);
// Check that the `.conda` folder gets created in the project
expect(async () => {
await expect(async () => {
const projectFiles = await app.workbench.positronExplorer.getExplorerProjectFiles();
expect(projectFiles).toContain('.conda');
}).toPass({ timeout: 10000 });
}).toPass({ timeout: 50000 });
// The console should initialize without any prompts to install ipykernel
await app.workbench.positronConsole.waitForReady('>>>', 10000);
await app.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
await app.workbench.positronConsole.barClearButton.click();
await app.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
});
});

Expand All @@ -82,12 +88,12 @@ export function setup(logger: Logger) {
await pw.pythonConfigurationStep.existingEnvRadioButton.click();
// Select the interpreter that was started above. It's possible that this needs
// to be attempted a few times to ensure the interpreters are properly loaded.
expect(
await expect(
async () =>
await pw.pythonConfigurationStep.selectInterpreterByPath(
interpreterInfo!.path
)
).toPass({ timeout: 10000 });
).toPass({ timeout: 50000 });
await pw.pythonConfigurationStep.interpreterFeedback.isNotVisible();
await pw.navigate(ProjectWizardNavigateAction.CREATE);
await pw.currentOrNewWindowSelectionModal.currentWindowButton.click();
Expand All @@ -97,17 +103,17 @@ export function setup(logger: Logger) {
// The console should initialize without any prompts to install ipykernel
await app.workbench.positronConsole.waitForReady('>>>', 10000);
});

it('With ipykernel not already installed [C609617]', async function () {
const projSuffix = '_noIpykernel';
const app = this.app as Application;
const pw = app.workbench.positronNewProjectWizard;
const pythonFixtures = new PositronPythonFixtures(app);
// Start the Python interpreter and uninstall ipykernel
await pythonFixtures.startAndGetPythonInterpreter(true);
const firstInfo = await pythonFixtures.startAndGetPythonInterpreter(true);
// Ensure the console is ready with the selected interpreter
await app.workbench.positronConsole.waitForReady('>>>', 10000);
const interpreterInfo = await app.workbench.startInterpreter.getSelectedInterpreterInfo();
expect(interpreterInfo?.path).toBeDefined();
expect(firstInfo?.path).toBeDefined();
await app.workbench.positronConsole.typeToConsole('pip uninstall -y ipykernel');
await app.workbench.positronConsole.sendEnterKey();
await app.workbench.positronConsole.waitForConsoleContents((contents) =>
Expand All @@ -121,14 +127,7 @@ export function setup(logger: Logger) {
await pw.navigate(ProjectWizardNavigateAction.NEXT);
// Choose the existing environment which does not have ipykernel
await pw.pythonConfigurationStep.existingEnvRadioButton.click();
// Select the interpreter that was started above. It's possible that this needs
// to be attempted a few times to ensure the interpreters are properly loaded.
expect(
async () =>
await pw.pythonConfigurationStep.selectInterpreterByPath(
interpreterInfo!.path
)
).toPass({ timeout: 10000 });

await pw.pythonConfigurationStep.interpreterFeedback.waitForText(
'ipykernel will be installed for Python language support.'
);
Expand All @@ -140,6 +139,9 @@ export function setup(logger: Logger) {
// If ipykernel was successfully installed during the new project initialization,
// the console should be ready without any prompts to install ipykernel
await app.workbench.positronConsole.waitForReady('>>>', 10000);
await app.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
await app.workbench.positronConsole.barClearButton.click();
await app.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
});
});

Expand All @@ -166,13 +168,13 @@ export function setup(logger: Logger) {
await app.workbench.positronConsole.waitForReady('>>>', 10000);

// Verify git-related files are present
expect(async () => {
await expect(async () => {
const projectFiles = await app.workbench.positronExplorer.getExplorerProjectFiles();
expect(projectFiles).toContain('.gitignore');
expect(projectFiles).toContain('README.md');
// Ideally, we'd check for the .git folder, but it's not visible in the Explorer
// by default due to the default `files.exclude` setting in the workspace.
}).toPass({ timeout: 10000 });
}).toPass({ timeout: 50000 });

// Git status should show that we're on the main branch
await app.workbench.terminal.createTerminal();
Expand Down Expand Up @@ -237,12 +239,12 @@ export function setup(logger: Logger) {
// await app.workbench.positronConsole.sendEnterKey();

// Verify renv files are present
expect(async () => {
await expect(async () => {
const projectFiles = await app.workbench.positronExplorer.getExplorerProjectFiles();
expect(projectFiles).toContain('renv');
expect(projectFiles).toContain('.Rprofile');
expect(projectFiles).toContain('renv.lock');
}).toPass({ timeout: 10000 });
}).toPass({ timeout: 50000 });
// Verify that renv output in the console confirms no issues occurred
await app.workbench.positronConsole.waitForConsoleContents((contents) =>
contents.some((line) => line.includes('renv activated'))
Expand All @@ -267,12 +269,12 @@ export function setup(logger: Logger) {
`myRProject${projSuffix}`
);
// Verify renv files are present
expect(async () => {
await expect(async () => {
const projectFiles = await app.workbench.positronExplorer.getExplorerProjectFiles();
expect(projectFiles).toContain('renv');
expect(projectFiles).toContain('.Rprofile');
expect(projectFiles).toContain('renv.lock');
}).toPass({ timeout: 10000 });
}).toPass({ timeout: 50000 });
// Verify that renv output in the console confirms no issues occurred
await app.workbench.positronConsole.waitForConsoleContents((contents) =>
contents.some((line) => line.includes('renv activated'))
Expand Down Expand Up @@ -304,12 +306,12 @@ export function setup(logger: Logger) {
// Interact with the modal to skip installing renv
await app.workbench.positronPopups.installRenv(false);
// Verify renv files are **not** present
expect(async () => {
await expect(async () => {
const projectFiles = await app.workbench.positronExplorer.getExplorerProjectFiles();
expect(projectFiles).not.toContain('renv');
expect(projectFiles).not.toContain('.Rprofile');
expect(projectFiles).not.toContain('renv.lock');
}).toPass({ timeout: 10000 });
}).toPass({ timeout: 50000 });
});
});
});
Expand Down

0 comments on commit 0fc8636

Please sign in to comment.