Skip to content

Commit

Permalink
e2e-test: leverage userSettings fixture (#5467)
Browse files Browse the repository at this point in the history
Updated existing tests to use new `userSettings` fixture.

### QA Notes
Running full suite to make sure things are good:
https://github.com/posit-dev/positron/actions/runs/11978168106
  • Loading branch information
midleman authored Nov 22, 2024
1 parent 5b84ed9 commit 8d0c666
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 52 deletions.
11 changes: 6 additions & 5 deletions test/smoke/src/areas/positron/_test.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,26 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({
await app.workbench.quickaccess.runCommand('workbench.action.toggleDevTools');
await use();
},

{ scope: 'test' }],

userSettings: [async ({ app }, use) => {
const userSettings = new PositronUserSettingsFixtures(app);

// define the set method
const setUserSetting = async (settings: UserSetting[], restartApp = false) => {
const setUserSetting = async (
settings: [string, string][],
restartApp = false
) => {
await userSettings.setUserSettings(settings, restartApp);
};

// use the fixture
await use({
set: setUserSetting
});

// cleanup after worker
await userSettings.unsetUserSettings();
}, { scope: 'worker' }],

attachScreenshotsToReport: [async ({ app }, use, testInfo) => {
let screenShotCounter = 1;
const page = app.code.driver.page;
Expand All @@ -166,7 +168,6 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({
for (const screenshotPath of screenshots) {
testInfo.attachments.push({ name: path.basename(screenshotPath), path: screenshotPath, contentType: 'image/png' });
}

}, { auto: true }],

attachLogsToReport: [async ({ suiteId, logsPath }, use, testInfo) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@

import { join } from 'path';
import { test, expect } from '../_test.setup';
import { UserSetting } from '../../../../../automation';

const connectionSetting: UserSetting = ['positron.connections.showConnectionPane', 'true'];

test.use({
suiteId: __filename
});

test.describe('SQLite DB Connection', { tag: ['@web', '@win', '@pr'] }, () => {
test.beforeAll(async function ({ userSettings }) {
await userSettings.set([connectionSetting], true);
await userSettings.set([['positron.connections.showConnectionPane', 'true']], true);
});

test.afterEach(async function ({ app }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@

import path = require('path');
import { test, expect } from '../_test.setup';
import { PositronUserSettingsFixtures } from '../../../../../automation';

test.use({
suiteId: __filename
});


test.describe('R Package Development', { tag: ['@web'] }, () => {
let userSettings: PositronUserSettingsFixtures;

test.beforeAll(async function ({ app, r }) {
test.beforeAll(async function ({ app, r, userSettings }) {
try {
userSettings = new PositronUserSettingsFixtures(app);

// don't use native file picker
await userSettings.setUserSetting(['files.simpleDialog.enable', 'true']);
await userSettings.set([['files.simpleDialog.enable', 'true']]);
await app.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
await app.workbench.positronConsole.barClearButton.click();
await app.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
Expand All @@ -30,11 +24,6 @@ test.describe('R Package Development', { tag: ['@web'] }, () => {
}
});

test.afterAll(async function () {
// unset the use of the VSCode file picker
await userSettings.unsetUserSettings();
});

test('R Package Development Tasks [C809821]', async function ({ app, logger }) {
test.slow();

Expand Down
14 changes: 3 additions & 11 deletions test/smoke/src/areas/positron/reticulate/reticulate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { test, expect } from '../_test.setup';
import { PositronUserSettingsFixtures, UserSetting } from '../../../../../automation';
import { UserSetting } from '../../../../../automation';

test.use({
suiteId: __filename
Expand All @@ -13,22 +13,19 @@ test.use({
// In order to run this test on Windows, I think we need to set the env var:
// RETICULATE_PYTHON
// to the installed python path
let userSettings: PositronUserSettingsFixtures;

test.describe('Reticulate', {
tag: ['@web'],
annotation: [{ type: 'issue', description: 'https://github.com/posit-dev/positron/issues/5226' }]
}, () => {
test.beforeAll(async function ({ app }) {
test.beforeAll(async function ({ app, userSettings }) {
try {
userSettings = new PositronUserSettingsFixtures(app);

// remove this once https://github.com/posit-dev/positron/issues/5226
// is resolved
const kernelSupervisorSetting: UserSetting = ['positronKernelSupervisor.enable', 'false'];
const reticulateSetting: UserSetting = ['positron.reticulate.enabled', 'true'];

await userSettings.setUserSettings([
await userSettings.set([
kernelSupervisorSetting,
reticulateSetting
]);
Expand All @@ -39,11 +36,6 @@ test.describe('Reticulate', {
}
});

test.afterAll(async function () {
await userSettings.unsetUserSettings();

});

test('R - Verify Basic Reticulate Functionality [C...]', async function ({ app, r, interpreter }) {

await app.workbench.positronConsole.pasteCodeToConsole('reticulate::repl_python()');
Expand Down
16 changes: 3 additions & 13 deletions test/smoke/src/areas/positron/test-explorer/test-explorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@

import path = require('path');
import { test, expect } from '../_test.setup';
import { PositronUserSettingsFixtures } from '../../../../../automation';

test.use({
suiteId: __filename
});

test.describe('Test Explorer', () => {
let userSettings: PositronUserSettingsFixtures;

test.beforeAll(async function ({ app, r }) {
test.beforeAll(async function ({ app, r, userSettings }) {
try {
userSettings = new PositronUserSettingsFixtures(app);

// don't use native file picker
await userSettings.setUserSetting([
await userSettings.set([[
'files.simpleDialog.enable',
'true',
]);
]]);

await app.workbench.quickaccess.runCommand('workbench.action.toggleAuxiliaryBar');
await app.workbench.positronConsole.barClearButton.click();
Expand All @@ -33,11 +28,6 @@ test.describe('Test Explorer', () => {
}
});

test.afterEach(async function () {
// unset the use of the VSCode file picker
await userSettings.unsetUserSettings();
});

test('R - Verify Basic Test Explorer Functionality [C749378]', async function ({ app }) {
await expect(async () => {
// Navigate to https://github.com/posit-dev/qa-example-content/tree/main/workspaces/r_testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { join } from 'path';
import { test, expect } from '../_test.setup';
import { PositronUserSettingsFixtures } from '../../../../../automation';

test.use({
suiteId: __filename
Expand All @@ -15,12 +14,9 @@ test.describe('Top Action Bar - Save Actions', {
tag: ['@web']
}, () => {

let userSettings: PositronUserSettingsFixtures;

test.beforeAll(async function ({ app }) {
test.beforeAll(async function ({ app, userSettings }) {
if (app.web) {
userSettings = new PositronUserSettingsFixtures(app);
await userSettings.setUserSetting(['files.autoSave', 'false']);
await userSettings.set([['files.autoSave', 'false']]);
}
});

Expand Down

0 comments on commit 8d0c666

Please sign in to comment.