Split removal tests based on state of query

We now have special behaviour for removing an "in progress" query so the
tests will be different.

Let's have a separate section for "in progress" queries. We'll add extra
behaviour testing in the next commit.
This commit is contained in:
Elena Tanasoiu
2023-01-10 11:53:49 +00:00
parent fa1f355b93
commit ab0e67c251

View File

@@ -589,98 +589,197 @@ describe("query-history", () => {
}); });
describe("when the item is a variant analysis", () => { describe("when the item is a variant analysis", () => {
describe("when the item being removed is not selected", () => { describe("when in progress", () => {
let toDelete: VariantAnalysisHistoryItem; describe("when the item being removed is not selected", () => {
let selected: VariantAnalysisHistoryItem; let toDelete: VariantAnalysisHistoryItem;
let selected: VariantAnalysisHistoryItem;
beforeEach(async () => { beforeEach(async () => {
// deleting the first item when a different item is selected // deleting the first item when a different item is selected
// will not change the selection // will not change the selection
toDelete = variantAnalysisHistory[1]; toDelete = variantAnalysisHistory[1];
selected = variantAnalysisHistory[3]; selected = variantAnalysisHistory[3];
queryHistoryManager = await createMockQueryHistory(allHistory); queryHistoryManager = await createMockQueryHistory(allHistory);
// initialize the selection // initialize the selection
await queryHistoryManager.treeView.reveal( await queryHistoryManager.treeView.reveal(
variantAnalysisHistory[0], variantAnalysisHistory[0],
{ {
select: true,
},
);
// select the item we want
await queryHistoryManager.treeView.reveal(selected, {
select: true, select: true,
}, });
);
// select the item we want // should be selected
await queryHistoryManager.treeView.reveal(selected, { expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
select: true, selected,
);
// remove an item
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
toDelete,
]);
}); });
// should be selected it("should remove the item", () => {
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual( expect(
selected, variantAnalysisManagerStub.removeVariantAnalysis,
); ).toHaveBeenCalledWith(toDelete.variantAnalysis);
expect(
queryHistoryManager.treeDataProvider.allHistory,
).not.toContain(toDelete);
});
// remove an item it("should not change the selection", () => {
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [ expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
toDelete, selected,
]); );
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
selected.variantAnalysis.id,
);
});
}); });
it("should remove the item", () => { describe("when the item being removed is selected", () => {
expect( let toDelete: VariantAnalysisHistoryItem;
variantAnalysisManagerStub.removeVariantAnalysis, let newSelected: VariantAnalysisHistoryItem;
).toHaveBeenCalledWith(toDelete.variantAnalysis);
expect(
queryHistoryManager.treeDataProvider.allHistory,
).not.toContain(toDelete);
});
it("should not change the selection", () => { beforeEach(async () => {
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual( // deleting the selected item automatically selects next item
selected, toDelete = variantAnalysisHistory[1];
); newSelected = variantAnalysisHistory[2];
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
selected.variantAnalysis.id, queryHistoryManager = await createMockQueryHistory(
); variantAnalysisHistory,
);
// select the item we want
await queryHistoryManager.treeView.reveal(toDelete, {
select: true,
});
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
toDelete,
]);
});
it("should remove the item", () => {
expect(
variantAnalysisManagerStub.removeVariantAnalysis,
).toHaveBeenCalledWith(toDelete.variantAnalysis);
expect(
queryHistoryManager.treeDataProvider.allHistory,
).not.toContain(toDelete);
});
it.skip("should change the selection", () => {
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
newSelected,
);
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
newSelected.variantAnalysis.id,
);
});
}); });
}); });
describe("when the item being removed is selected", () => { describe("when not in progress", () => {
let toDelete: VariantAnalysisHistoryItem; describe("when the item being removed is not selected", () => {
let newSelected: VariantAnalysisHistoryItem; let toDelete: VariantAnalysisHistoryItem;
let selected: VariantAnalysisHistoryItem;
beforeEach(async () => { beforeEach(async () => {
// deleting the selected item automatically selects next item // deleting the first item when a different item is selected
toDelete = variantAnalysisHistory[1]; // will not change the selection
newSelected = variantAnalysisHistory[2]; toDelete = variantAnalysisHistory[2];
selected = variantAnalysisHistory[3];
queryHistoryManager = await createMockQueryHistory( queryHistoryManager = await createMockQueryHistory(allHistory);
variantAnalysisHistory, // initialize the selection
); await queryHistoryManager.treeView.reveal(
variantAnalysisHistory[0],
{
select: true,
},
);
// select the item we want // select the item we want
await queryHistoryManager.treeView.reveal(toDelete, { await queryHistoryManager.treeView.reveal(selected, {
select: true, select: true,
});
// should be selected
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
selected,
);
// remove an item
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
toDelete,
]);
});
it("should remove the item", () => {
expect(
variantAnalysisManagerStub.removeVariantAnalysis,
).toHaveBeenCalledWith(toDelete.variantAnalysis);
expect(
queryHistoryManager.treeDataProvider.allHistory,
).not.toContain(toDelete);
});
it("should not change the selection", () => {
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
selected,
);
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
selected.variantAnalysis.id,
);
}); });
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
toDelete,
]);
}); });
it("should remove the item", () => { describe("when the item being removed is selected", () => {
expect( let toDelete: VariantAnalysisHistoryItem;
variantAnalysisManagerStub.removeVariantAnalysis, let newSelected: VariantAnalysisHistoryItem;
).toHaveBeenCalledWith(toDelete.variantAnalysis);
expect(
queryHistoryManager.treeDataProvider.allHistory,
).not.toContain(toDelete);
});
it.skip("should change the selection", () => { beforeEach(async () => {
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual( // deleting the selected item automatically selects next item
newSelected, toDelete = variantAnalysisHistory[0];
); newSelected = variantAnalysisHistory[2];
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
newSelected.variantAnalysis.id, queryHistoryManager = await createMockQueryHistory(
); variantAnalysisHistory,
);
// select the item we want
await queryHistoryManager.treeView.reveal(toDelete, {
select: true,
});
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
toDelete,
]);
});
it("should remove the item", () => {
expect(
variantAnalysisManagerStub.removeVariantAnalysis,
).toHaveBeenCalledWith(toDelete.variantAnalysis);
expect(
queryHistoryManager.treeDataProvider.allHistory,
).not.toContain(toDelete);
});
it.skip("should change the selection", () => {
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
newSelected,
);
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
newSelected.variantAnalysis.id,
);
});
}); });
}); });
}); });