Skip to content

Commit 222d3ed

Browse files
Merge pull request #3293 from github/robertbrignull/variant-analysis-history-test-dto
Don't compare internal and dto types in variant-analysis-history.test.ts
2 parents 5367bde + 31ea6ad commit 222d3ed

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

extensions/ql-vscode/test/vscode-tests/no-workspace/data/variant-analysis/workspace-query-history.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"status": "Completed",
3434
"completed": true,
3535
"variantAnalysis": {
36-
"id": 98574321397,
36+
"id": 58993265664,
3737
"controllerRepo": {
3838
"id": 128321,
3939
"fullName": "github/codeql",

extensions/ql-vscode/test/vscode-tests/no-workspace/query-history/variant-analysis-history.test.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { mockedObject } from "../../utils/mocking.helpers";
2525
import { createMockQueryHistoryDirs } from "../../../factories/query-history/query-history-dirs";
2626
import { createMockApp } from "../../../__mocks__/appMock";
2727
import { LanguageContextStore } from "../../../../src/language-context-store";
28+
import { mapQueryHistoryVariantAnalysisToDomainModel } from "../../../../src/query-history/store/query-history-variant-analysis-dto-mapper";
29+
import type { VariantAnalysisHistoryItem } from "../../../../src/query-history/variant-analysis-history-item";
2830

2931
// set a higher timeout since recursive delete may take a while, expecially on Windows.
3032
jest.setTimeout(120000);
@@ -41,7 +43,7 @@ describe("Variant Analyses and QueryHistoryManager", () => {
4143
};
4244

4345
let qhm: QueryHistoryManager;
44-
let rawQueryHistory: any;
46+
let queryHistory: VariantAnalysisHistoryItem[];
4547
let disposables: DisposableBucket;
4648

4749
const rehydrateVariantAnalysisStub = jest.fn();
@@ -72,9 +74,9 @@ describe("Variant Analyses and QueryHistoryManager", () => {
7274

7375
disposables = new DisposableBucket();
7476

75-
rawQueryHistory = readJSONSync(
77+
queryHistory = readJSONSync(
7678
join(STORAGE_DIR, "workspace-query-history.json"),
77-
).queries;
79+
).queries.map(mapQueryHistoryVariantAnalysisToDomainModel);
7880

7981
const app = createMockApp({});
8082

@@ -122,15 +124,15 @@ describe("Variant Analyses and QueryHistoryManager", () => {
122124
expect(rehydrateVariantAnalysisStub).toHaveBeenCalledTimes(2);
123125
expect(rehydrateVariantAnalysisStub).toHaveBeenNthCalledWith(
124126
1,
125-
rawQueryHistory[0].variantAnalysis,
127+
queryHistory[0].variantAnalysis,
126128
);
127129
expect(rehydrateVariantAnalysisStub).toHaveBeenNthCalledWith(
128130
2,
129-
rawQueryHistory[1].variantAnalysis,
131+
queryHistory[1].variantAnalysis,
130132
);
131133

132-
expect(qhm.treeDataProvider.allHistory[0]).toEqual(rawQueryHistory[0]);
133-
expect(qhm.treeDataProvider.allHistory[1]).toEqual(rawQueryHistory[1]);
134+
expect(qhm.treeDataProvider.allHistory[0]).toEqual(queryHistory[0]);
135+
expect(qhm.treeDataProvider.allHistory[1]).toEqual(queryHistory[1]);
134136
expect(qhm.treeDataProvider.allHistory.length).toBe(2);
135137
});
136138

@@ -141,12 +143,12 @@ describe("Variant Analyses and QueryHistoryManager", () => {
141143
await qhm.handleRemoveHistoryItem([qhm.treeDataProvider.allHistory[0]]);
142144

143145
// Add it back to the history
144-
qhm.addQuery(rawQueryHistory[0]);
146+
qhm.addQuery(queryHistory[0]);
145147
expect(removeVariantAnalysisStub).toHaveBeenCalledTimes(1);
146148
expect(rehydrateVariantAnalysisStub).toHaveBeenCalledTimes(2);
147149
expect(qhm.treeDataProvider.allHistory).toEqual([
148-
rawQueryHistory[1],
149-
rawQueryHistory[0],
150+
queryHistory[1],
151+
queryHistory[0],
150152
]);
151153
});
152154

@@ -163,11 +165,11 @@ describe("Variant Analyses and QueryHistoryManager", () => {
163165
expect(removeVariantAnalysisStub).toHaveBeenCalledTimes(2);
164166
expect(removeVariantAnalysisStub).toHaveBeenNthCalledWith(
165167
1,
166-
rawQueryHistory[1].variantAnalysis,
168+
queryHistory[1].variantAnalysis,
167169
);
168170
expect(removeVariantAnalysisStub).toHaveBeenNthCalledWith(
169171
2,
170-
rawQueryHistory[0].variantAnalysis,
172+
queryHistory[0].variantAnalysis,
171173
);
172174
expect(qhm.treeDataProvider.allHistory).toEqual([]);
173175

@@ -185,7 +187,7 @@ describe("Variant Analyses and QueryHistoryManager", () => {
185187

186188
await qhm.handleItemClicked(qhm.treeDataProvider.allHistory[0]);
187189
expect(showViewStub).toHaveBeenCalledWith(
188-
rawQueryHistory[0].variantAnalysis.id,
190+
queryHistory[0].variantAnalysis.id,
189191
);
190192
});
191193

@@ -194,7 +196,7 @@ describe("Variant Analyses and QueryHistoryManager", () => {
194196
await qhm.handleShowQueryText(qhm.treeDataProvider.allHistory[0]);
195197

196198
expect(openQueryTextSpy).toHaveBeenCalledWith(
197-
rawQueryHistory[0].variantAnalysis.id,
199+
queryHistory[0].variantAnalysis.id,
198200
);
199201
});
200202

0 commit comments

Comments
 (0)