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

chore: remove internal options, enable watch #464

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,6 @@
"default": false,
"description": "%configuration.playwright.showTrace%"
},
"playwright.useTestServer": {
"type": "boolean",
"default": false
},
"playwright.allowWatchingFiles": {
"type": "boolean",
"default": false
},
"playwright.workspaceSettings": {
"type": "object",
"default": {}
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class Extension implements RunHooks {
this._testController = vscode.tests.createTestController('playwright', 'Playwright');
this._testController.resolveHandler = item => this._resolveChildren(item);
this._testController.refreshHandler = () => this._rebuildModels(true).then(() => {});
const supportsContinuousRun = this._settingsModel.allowWatchingFiles.get();
const supportsContinuousRun = true;
this._runProfile = this._testController.createRunProfile('playwright-run', this._vscode.TestRunProfileKind.Run, this._handleTestRun.bind(this, false), true, undefined, supportsContinuousRun);
this._debugProfile = this._testController.createRunProfile('playwright-debug', this._vscode.TestRunProfileKind.Debug, this._handleTestRun.bind(this, true), true, undefined, supportsContinuousRun);
this._testTree = new TestTree(vscode, this._models, this._testController);
Expand Down
2 changes: 0 additions & 2 deletions src/settingsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export class SettingsModel extends DisposableBase {
private _onChange: vscodeTypes.EventEmitter<void>;
showBrowser: Setting<boolean>;
showTrace: Setting<boolean>;
allowWatchingFiles: Setting<boolean>;
workspaceSettings: Setting<WorkspaceSettings>;

constructor(vscode: vscodeTypes.VSCode) {
Expand All @@ -51,7 +50,6 @@ export class SettingsModel extends DisposableBase {

this.showBrowser = this._createSetting('reuseBrowser');
this.showTrace = this._createSetting('showTrace');
this.allowWatchingFiles = this._createSetting('allowWatchingFiles');
this.workspaceSettings = this._createSetting('workspaceSettings', true);

this.showBrowser.onChange(enabled => {
Expand Down
2 changes: 2 additions & 0 deletions src/settingsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ export class SettingsView extends DisposableBase implements vscodeTypes.WebviewV
continue;
this._models.setModelEnabled(model.config.configFile, !!result?.includes(modelItem), true);
}
this._models.ensureHasEnabledModels();
this._updateModels();
});
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/testModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,17 @@ export class TestModelCollection extends DisposableBase {
}

selectedModel(): TestModel | undefined {
const model = this._models.find(m => m.config.configFile === this._selectedConfigFile);
const enabledModels = this.enabledModels();
if (!enabledModels.length) {
this._selectedConfigFile = undefined;
return undefined;
}

const model = enabledModels.find(m => m.config.configFile === this._selectedConfigFile);
if (model)
return model;
return this._models.find(m => m.isEnabled);
this._selectedConfigFile = enabledModels[0].config.configFile;
Copy link
Contributor

Choose a reason for hiding this comment

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

Updating in a getter sounds strange! Perhaps the method that enables/disables a model should update this field? Or default to a first enabled model when this._selectedConfigFile points nowhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or default to a first enabled model when this._selectedConfigFile points nowhere?

That's what it was, but in that case picking new model will change the current selection in the UI, which does not sound friendly. Think about this assignment here as a cache.

return enabledModels[0];
}

selectModel(configFile: string) {
Expand Down
5 changes: 0 additions & 5 deletions tests/watch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import path from 'path';

test.skip(({ overridePlaywrightVersion }) => !!overridePlaywrightVersion);

test.beforeEach(async ({ vscode }) => {
const configuration = vscode.workspace.getConfiguration('playwright');
configuration.update('allowWatchingFiles', true);
});

test('should watch all tests', async ({ activate }) => {
const { vscode, testController, workspaceFolder } = await activate({
'playwright.config.js': `module.exports = { testDir: 'tests' }`,
Expand Down
Loading