Skip to content

Commit ddb7a55

Browse files
authored
Fix E2E tests (#12871)
1 parent a61c55c commit ddb7a55

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

Diff for: Extension/test/scenarios/SingleRootProject/tests/copilotProviders.test.ts

+18-12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ describe('registerRelatedFilesProvider', () => {
2222
let callbackPromise: Promise<{ entries: vscode.Uri[]; traits?: CopilotTrait[] }> | undefined;
2323
let vscodeExtension: vscode.Extension<unknown>;
2424

25+
const includedFiles = process.platform === 'win32' ?
26+
['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] :
27+
['/system/include/vector', '/system/include/string', '/home/src/my_project/foo.h'];
28+
const rootUri = vscode.Uri.file(process.platform === 'win32' ? 'C:\\src\\my_project' : '/home/src/my_project');
29+
const expectedInclude = process.platform === 'win32' ? 'file:///c%3A/src/my_project/foo.h' : 'file:///home/src/my_project/foo.h';
30+
2531
beforeEach(() => {
2632
proxyquire.noPreserveCache(); // Tells proxyquire to not fetch the module from cache
2733
// Ensures that each test has a freshly loaded instance of moduleUnderTest
@@ -105,9 +111,9 @@ describe('registerRelatedFilesProvider', () => {
105111
it('should not add #cpp traits when ChatContext isn\'t available.', async () => {
106112
arrange({
107113
vscodeExtension: vscodeExtension,
108-
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
114+
getIncludeFiles: { includedFiles },
109115
chatContext: undefined,
110-
rootUri: vscode.Uri.file('C:\\src\\my_project'),
116+
rootUri,
111117
flags: { copilotcppTraits: true }
112118
});
113119
await moduleUnderTest.registerRelatedFilesProvider();
@@ -120,22 +126,22 @@ describe('registerRelatedFilesProvider', () => {
120126
ok(callbackPromise, 'callbackPromise should be defined');
121127
ok(result, 'result should be defined');
122128
ok(result.entries.length === 1, 'result.entries should have 1 included file');
123-
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
129+
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
124130
ok(result.traits === undefined, 'result.traits should be undefined');
125131
});
126132

127133
it('should not add #cpp traits when copilotcppTraits flag is false.', async () => {
128134
arrange({
129135
vscodeExtension: vscodeExtension,
130-
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
136+
getIncludeFiles: { includedFiles },
131137
chatContext: {
132138
language: 'c++',
133139
standardVersion: 'c++20',
134140
compiler: 'msvc',
135141
targetPlatform: 'windows',
136142
targetArchitecture: 'x64'
137143
},
138-
rootUri: vscode.Uri.file('C:\\src\\my_project'),
144+
rootUri,
139145
flags: { copilotcppTraits: false }
140146
});
141147
await moduleUnderTest.registerRelatedFilesProvider();
@@ -148,22 +154,22 @@ describe('registerRelatedFilesProvider', () => {
148154
ok(callbackPromise, 'callbackPromise should be defined');
149155
ok(result, 'result should be defined');
150156
ok(result.entries.length === 1, 'result.entries should have 1 included file');
151-
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
157+
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
152158
ok(result.traits === undefined, 'result.traits should be undefined');
153159
});
154160

155161
it('should add #cpp traits when copilotcppTraits flag is true.', async () => {
156162
arrange({
157163
vscodeExtension: vscodeExtension,
158-
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
164+
getIncludeFiles: { includedFiles },
159165
chatContext: {
160166
language: 'c++',
161167
standardVersion: 'c++20',
162168
compiler: 'msvc',
163169
targetPlatform: 'windows',
164170
targetArchitecture: 'x64'
165171
},
166-
rootUri: vscode.Uri.file('C:\\src\\my_project'),
172+
rootUri,
167173
flags: { copilotcppTraits: true }
168174
});
169175
await moduleUnderTest.registerRelatedFilesProvider();
@@ -177,7 +183,7 @@ describe('registerRelatedFilesProvider', () => {
177183
ok(callbackPromise, 'callbackPromise should be defined');
178184
ok(result, 'result should be defined');
179185
ok(result.entries.length === 1, 'result.entries should have 1 included file');
180-
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
186+
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
181187
ok(result.traits, 'result.traits should be defined');
182188
ok(result.traits.length === 5, 'result.traits should have 5 traits');
183189
ok(result.traits[0].name === 'language', 'result.traits[0].name should be "language"');
@@ -206,15 +212,15 @@ describe('registerRelatedFilesProvider', () => {
206212
const excludeTraits = ['compiler', 'targetPlatform'];
207213
arrange({
208214
vscodeExtension: vscodeExtension,
209-
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
215+
getIncludeFiles: { includedFiles },
210216
chatContext: {
211217
language: 'c++',
212218
standardVersion: 'c++20',
213219
compiler: 'msvc',
214220
targetPlatform: 'windows',
215221
targetArchitecture: 'x64'
216222
},
217-
rootUri: vscode.Uri.file('C:\\src\\my_project'),
223+
rootUri,
218224
flags: { copilotcppTraits: true, copilotcppExcludeTraits: excludeTraits }
219225
});
220226
await moduleUnderTest.registerRelatedFilesProvider();
@@ -228,7 +234,7 @@ describe('registerRelatedFilesProvider', () => {
228234
ok(callbackPromise, 'callbackPromise should be defined');
229235
ok(result, 'result should be defined');
230236
ok(result.entries.length === 1, 'result.entries should have 1 included file');
231-
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
237+
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
232238
ok(result.traits, 'result.traits should be defined');
233239
ok(result.traits.length === 3, 'result.traits should have 3 traits');
234240
ok(result.traits.filter(trait => excludeTraits.includes(trait.name)).length === 0, 'result.traits should not include excluded traits');

0 commit comments

Comments
 (0)