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
Родитель fa1f355b93
Коммит ab0e67c251
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 865B598BB92245B0
1 изменённых файлов: 171 добавлений и 72 удалений

Просмотреть файл

@ -589,6 +589,7 @@ describe("query-history", () => {
});
describe("when the item is a variant analysis", () => {
describe("when in progress", () => {
describe("when the item being removed is not selected", () => {
let toDelete: VariantAnalysisHistoryItem;
let selected: VariantAnalysisHistoryItem;
@ -684,6 +685,104 @@ describe("query-history", () => {
});
});
});
describe("when not in progress", () => {
describe("when the item being removed is not selected", () => {
let toDelete: VariantAnalysisHistoryItem;
let selected: VariantAnalysisHistoryItem;
beforeEach(async () => {
// deleting the first item when a different item is selected
// will not change the selection
toDelete = variantAnalysisHistory[2];
selected = variantAnalysisHistory[3];
queryHistoryManager = await createMockQueryHistory(allHistory);
// initialize the selection
await queryHistoryManager.treeView.reveal(
variantAnalysisHistory[0],
{
select: true,
},
);
// select the item we want
await queryHistoryManager.treeView.reveal(selected, {
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,
);
});
});
describe("when the item being removed is selected", () => {
let toDelete: VariantAnalysisHistoryItem;
let newSelected: VariantAnalysisHistoryItem;
beforeEach(async () => {
// deleting the selected item automatically selects next item
toDelete = variantAnalysisHistory[0];
newSelected = variantAnalysisHistory[2];
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("handleCancel", () => {