Adjust handling of historyItem

This commit is contained in:
Nora
2022-10-25 15:42:38 +02:00
committed by Elena Tanasoiu
parent 7cffb997a7
commit c4b4cee057
2 changed files with 7 additions and 8 deletions

View File

@@ -5,7 +5,6 @@
"t": "variant-analysis", "t": "variant-analysis",
"status": "Completed", "status": "Completed",
"completed": true, "completed": true,
"historyItemId": "12349821",
"variantAnalysis": { "variantAnalysis": {
"id": 98574321397, "id": 98574321397,
"controllerRepoId": 128321, "controllerRepoId": 128321,
@@ -29,7 +28,6 @@
"t": "variant-analysis", "t": "variant-analysis",
"status": "Completed", "status": "Completed",
"completed": true, "completed": true,
"historyItemId": "12349821",
"variantAnalysis": { "variantAnalysis": {
"id": 98574321397, "id": 98574321397,
"controllerRepoId": 128321, "controllerRepoId": 128321,

View File

@@ -79,7 +79,8 @@ describe('Variant Analyses and QueryHistoryManager', function() {
onVariantAnalysisAdded: sandbox.stub(), onVariantAnalysisAdded: sandbox.stub(),
onVariantAnalysisRemoved: sandbox.stub(), onVariantAnalysisRemoved: sandbox.stub(),
removeRemoteQuery: removeVariantAnalysisStub, removeRemoteQuery: removeVariantAnalysisStub,
rehydrateVariantAnalysis: rehydrateVariantAnalysisStub rehydrateVariantAnalysis: rehydrateVariantAnalysisStub,
onVariantAnalysisStatusUpdated: sandbox.stub()
} as any as VariantAnalysisManager; } as any as VariantAnalysisManager;
rawQueryHistory = fs.readJSONSync(path.join(STORAGE_DIR, 'workspace-query-history.json')).queries; rawQueryHistory = fs.readJSONSync(path.join(STORAGE_DIR, 'workspace-query-history.json')).queries;
@@ -134,7 +135,7 @@ describe('Variant Analyses and QueryHistoryManager', function() {
// Remove the first variant analysis // Remove the first variant analysis
await qhm.handleRemoveHistoryItem(qhm.treeDataProvider.allHistory[0]); await qhm.handleRemoveHistoryItem(qhm.treeDataProvider.allHistory[0]);
expect(removeVariantAnalysisStub).calledOnceWithExactly(rawQueryHistory[0].historyItemId); expect(removeVariantAnalysisStub).calledOnceWithExactly(rawQueryHistory[0].variantAnalysis.id.toString());
expect(rehydrateVariantAnalysisStub).to.have.callCount(2); expect(rehydrateVariantAnalysisStub).to.have.callCount(2);
expect(rehydrateVariantAnalysisStub.getCall(0).args[0]).to.deep.eq(rawQueryHistory[0].variantAnalysis); expect(rehydrateVariantAnalysisStub.getCall(0).args[0]).to.deep.eq(rawQueryHistory[0].variantAnalysis);
@@ -143,7 +144,7 @@ describe('Variant Analyses and QueryHistoryManager', function() {
expect(rehydrateVariantAnalysisStub.getCall(1).args[0]).to.deep.eq(rawQueryHistory[1].variantAnalysis); expect(rehydrateVariantAnalysisStub.getCall(1).args[0]).to.deep.eq(rawQueryHistory[1].variantAnalysis);
expect(rehydrateVariantAnalysisStub.getCall(1).args[1]).to.deep.eq(rawQueryHistory[1].status); expect(rehydrateVariantAnalysisStub.getCall(1).args[1]).to.deep.eq(rawQueryHistory[1].status);
expect(openRemoteQueryResultsStub).calledOnceWithExactly(rawQueryHistory[1].historyItemId); expect(openRemoteQueryResultsStub).calledOnceWithExactly(rawQueryHistory[1].variantAnalysis.id.toString());
expect(qhm.treeDataProvider.allHistory).to.deep.eq(rawQueryHistory.slice(1)); expect(qhm.treeDataProvider.allHistory).to.deep.eq(rawQueryHistory.slice(1));
// Add it back to the history // Add it back to the history
@@ -161,8 +162,8 @@ describe('Variant Analyses and QueryHistoryManager', function() {
await qhm.handleRemoveHistoryItem(undefined!, [qhm.treeDataProvider.allHistory[1], qhm.treeDataProvider.allHistory[0]]); await qhm.handleRemoveHistoryItem(undefined!, [qhm.treeDataProvider.allHistory[1], qhm.treeDataProvider.allHistory[0]]);
expect(removeVariantAnalysisStub.callCount).to.eq(2); expect(removeVariantAnalysisStub.callCount).to.eq(2);
expect(removeVariantAnalysisStub.getCall(0).args[0]).to.eq(rawQueryHistory[1].historyItemId); expect(removeVariantAnalysisStub.getCall(0).args[0]).to.eq(rawQueryHistory[1].variantAnalysis.id.toString());
expect(removeVariantAnalysisStub.getCall(1).args[0]).to.eq(rawQueryHistory[0].historyItemId); expect(removeVariantAnalysisStub.getCall(1).args[0]).to.eq(rawQueryHistory[0].variantAnalysis.id.toString());
expect(qhm.treeDataProvider.allHistory).to.deep.eq([]); expect(qhm.treeDataProvider.allHistory).to.deep.eq([]);
// also, both queries should be removed from disk storage // also, both queries should be removed from disk storage
@@ -176,7 +177,7 @@ describe('Variant Analyses and QueryHistoryManager', function() {
await qhm.readQueryHistory(); await qhm.readQueryHistory();
await qhm.handleItemClicked(qhm.treeDataProvider.allHistory[0], []); await qhm.handleItemClicked(qhm.treeDataProvider.allHistory[0], []);
expect(openRemoteQueryResultsStub).calledOnceWithExactly(rawQueryHistory[0].historyItemId); expect(openRemoteQueryResultsStub).calledOnceWithExactly(rawQueryHistory[0].variantAnalysis.id.toString());
}); });
it('should get the query text', async () => { it('should get the query text', async () => {