Skip to content

Commit

Permalink
Console output test: loop with short pauses (#4882)
Browse files Browse the repository at this point in the history
Test for #4848

Also, retries globally turned on for smoke tests with "double
screenshots and traces" as relevent.

### QA Notes

All smoke tests pass.
  • Loading branch information
testlabauto authored Oct 2, 2024
1 parent 78557c8 commit 34b5c57
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 5 deletions.
8 changes: 6 additions & 2 deletions test/automation/src/playwrightDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export class PlaywrightDriver {
try {
let persistPath: string | undefined = undefined;
if (persist) {
persistPath = join(this.options.logsPath, `playwright-trace-${PlaywrightDriver.traceCounter++}-${name.replace(/\s+/g, '-')}.zip`);
// --- Start Positron ---
persistPath = join(this.options.logsPath, `playwright-trace-${PlaywrightDriver.traceCounter++}-${name.replace(/\s+/g, '-')}_${Date.now()}.zip`);
// --- End Positron ---
}

await measureAndLog(() => this.context.tracing.stopChunk({ path: persistPath }), `stopTracing for ${name}`, this.options.logger);
Expand All @@ -73,7 +75,9 @@ export class PlaywrightDriver {
// does not guarantee to give us a screenshot unless
// some driver action ran before.
if (persist) {
await this.takeScreenshot(name);
// --- Start Positron ---
await this.takeScreenshot(`${name}_${Date.now()}`);
// --- End Positron ---
}
} catch (error) {
// Ignore
Expand Down
51 changes: 51 additions & 0 deletions test/smoke/src/areas/positron/console/consoleOutput.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------------------------
* Copyright (C) 2024 Posit Software, PBC. All rights reserved.
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
*--------------------------------------------------------------------------------------------*/


import { Application, PositronRFixtures } from '../../../../../automation';
import { setupAndStartApp } from '../../../positronUtils';

describe('Console Output', () => {
setupAndStartApp();

describe('Console Output - R', () => {
before(async function () {
await PositronRFixtures.SetupFixtures(this.app as Application);
});

it('R - Console output in a loop with short pauses [C885225]', async function () {
const app = this.app as Application;

const code = `tokens <- c(
"",
"Why",
" do",
" programmers",
" prefer",
" dark",
" mode",
"?\n\n",
"Because",
" light",
" attracts",
" bugs",
"!"
)
for(token in tokens) {
cat(token)
Sys.sleep(0.01)
}`;

await app.workbench.positronConsole.pasteCodeToConsole(code);

await app.workbench.positronConsole.sendEnterKey();

await app.workbench.positronConsole.waitForConsoleContents((contents) => contents.some((line) => line.includes('Why do programmers prefer dark mode')));
await app.workbench.positronConsole.waitForConsoleContents((contents) => contents.some((line) => line.includes('Because light attracts bugs!')));

});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Application, PositronPythonFixtures, PositronRFixtures } from '../../..
import { setupAndStartApp } from '../../../positronUtils';


describe('Console Output #web', () => {
describe('Output #web', () => {
setupAndStartApp();

describe('Console Output Log - Python', () => {
Expand Down
5 changes: 4 additions & 1 deletion test/smoke/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export function installDiagnosticsHandler(logger: Logger, appFn?: () => Applicat
logger.log('');

const app: Application = appFn?.() ?? this.app;
await app?.stopTracing(testTitle.replace(/[^a-z0-9\-]/ig, '_'), failed);
// --- Start Positron ---
// state is undefined during retry
await app?.stopTracing(testTitle.replace(/[^a-z0-9\-]/ig, '_'), failed || (currentTest.state === undefined));
// --- End Positron ---
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/smoke/test/positronIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function getMochaOptions(opts) {
spec: '-', // Console output
xunit: REPORT_PATH,
},
retries: 0,
retries: 1,
};
}

Expand Down

0 comments on commit 34b5c57

Please sign in to comment.