Skip to content

Commit 7cffb99

Browse files
norascheuchelenatanasoiu
authored andcommitted
Add query text test
1 parent 83291c5 commit 7cffb99

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

extensions/ql-vscode/src/vscode-tests/no-workspace/remote-queries/variant-analysis-history.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { expect } from 'chai';
66
import {
77
ExtensionContext,
88
Uri,
9+
window,
10+
workspace,
911
} from 'vscode';
1012
import { QueryHistoryConfig } from '../../../config';
1113
import { DatabaseManager } from '../../../databases';
@@ -39,6 +41,9 @@ describe('Variant Analyses and QueryHistoryManager', function() {
3941
let variantAnalysisManagerStub: VariantAnalysisManager;
4042
let rawQueryHistory: any;
4143
let disposables: DisposableBucket;
44+
let showTextDocumentSpy: sinon.SinonSpy;
45+
let openTextDocumentSpy: sinon.SinonSpy;
46+
4247
let openRemoteQueryResultsStub: sinon.SinonStub;
4348
let rehydrateVariantAnalysisStub: sinon.SinonStub;
4449
let removeVariantAnalysisStub: sinon.SinonStub;
@@ -98,6 +103,9 @@ describe('Variant Analyses and QueryHistoryManager', function() {
98103
asyncNoop
99104
);
100105
disposables.push(qhm);
106+
107+
showTextDocumentSpy = sandbox.spy(window, 'showTextDocument');
108+
openTextDocumentSpy = sandbox.spy(workspace, 'openTextDocument');
101109
});
102110

103111
afterEach(function() {
@@ -171,6 +179,20 @@ describe('Variant Analyses and QueryHistoryManager', function() {
171179
expect(openRemoteQueryResultsStub).calledOnceWithExactly(rawQueryHistory[0].historyItemId);
172180
});
173181

182+
it('should get the query text', async () => {
183+
await qhm.readQueryHistory();
184+
await qhm.handleShowQueryText(qhm.treeDataProvider.allHistory[0], []);
185+
186+
expect(showTextDocumentSpy).to.have.been.calledOnce;
187+
expect(openTextDocumentSpy).to.have.been.calledOnce;
188+
189+
const uri: Uri = openTextDocumentSpy.getCall(0).args[0];
190+
expect(uri.scheme).to.eq('codeql');
191+
const params = new URLSearchParams(uri.query);
192+
expect(params.get('isQuickEval')).to.eq('false');
193+
expect(params.get('queryText')).to.eq(rawQueryHistory[0].variantAnalysis.query.text);
194+
});
195+
174196
async function copyHistoryState() {
175197
fs.ensureDirSync(STORAGE_DIR);
176198
fs.copySync(

0 commit comments

Comments
 (0)