Skip to content

Commit 4723404

Browse files
e2e-test: fix import vscode settings test (#7727)
### Summary Fix for vscode import settings. ### QA Notes @:vscode-settings --------- Co-authored-by: Sam Clark <sam.clark@posit.co>
1 parent 2dc2584 commit 4723404

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/vs/workbench/contrib/positronWelcome/browser/helpers.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,26 @@ export async function mergeSettingsJson(
141141
incoming: URI
142142
): Promise<string> {
143143
// Read the contents of the existing and incoming settings files
144-
const existingContents = await fileService.readFile(existing);
145-
const incomingContents = await fileService.readFile(incoming);
144+
let existingContents;
145+
if (await fileService.exists(existing)) {
146+
const fileContent = await fileService.readFile(incoming);
147+
existingContents = fileContent.value.toString();
148+
} else {
149+
existingContents = '{}';
150+
}
151+
152+
let incomingContents;
153+
if (await fileService.exists(incoming)) {
154+
const fileContent = await fileService.readFile(incoming);
155+
incomingContents = fileContent.value.toString();
156+
} else {
157+
incomingContents = '{}';
158+
}
146159

147160
// Parse the contents as JSON
148161
// Using the `jsonc.parse` function to handle comments and trailing commas
149-
const existingJson = parse<Record<string, any>>(existingContents.value.toString());
150-
const incomingJson = parse<Record<string, any>>(incomingContents.value.toString());
162+
const existingJson = parse<Record<string, any>>(existingContents);
163+
const incomingJson = parse<Record<string, any>>(incomingContents);
151164

152165
// Merge the two JSON objects
153166
const mergedJson = mergeObjects(existingJson, incomingJson);

test/e2e/tests/import-vscode-settings/import-vscode-settings.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,8 @@ test.describe('Import VSCode Settings', { tag: [tags.VSCODE_SETTINGS, tags.WIN]
126126
async function expectDiffToBeVisible(page: Page, visible = true) {
127127
if (visible) {
128128
await expect(page.getByRole('tab', { name: 'settings.json' })).toBeVisible();
129-
await expect(page.getByText('settings.json (in file) ↔ settings.json', { exact: true })).toBeVisible();
130129
} else {
131130
await page.waitForTimeout(3000); // waiting to avoid false positive
132131
await expect(page.getByRole('tab', { name: 'settings.json' })).not.toBeVisible();
133-
await expect(page.getByText('settings.json (in file) ↔ settings.json', { exact: true })).not.toBeVisible();
134132
}
135133
}

0 commit comments

Comments
 (0)