Skip to content

Commit ab0e67c

Browse files
committed
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.
1 parent fa1f355 commit ab0e67c

1 file changed

Lines changed: 171 additions & 72 deletions

File tree

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

Lines changed: 171 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -589,98 +589,197 @@ describe("query-history", () => {
589589
});
590590

591591
describe("when the item is a variant analysis", () => {
592-
describe("when the item being removed is not selected", () => {
593-
let toDelete: VariantAnalysisHistoryItem;
594-
let selected: VariantAnalysisHistoryItem;
592+
describe("when in progress", () => {
593+
describe("when the item being removed is not selected", () => {
594+
let toDelete: VariantAnalysisHistoryItem;
595+
let selected: VariantAnalysisHistoryItem;
595596

596-
beforeEach(async () => {
597-
// deleting the first item when a different item is selected
598-
// will not change the selection
599-
toDelete = variantAnalysisHistory[1];
600-
selected = variantAnalysisHistory[3];
597+
beforeEach(async () => {
598+
// deleting the first item when a different item is selected
599+
// will not change the selection
600+
toDelete = variantAnalysisHistory[1];
601+
selected = variantAnalysisHistory[3];
601602

602-
queryHistoryManager = await createMockQueryHistory(allHistory);
603-
// initialize the selection
604-
await queryHistoryManager.treeView.reveal(
605-
variantAnalysisHistory[0],
606-
{
603+
queryHistoryManager = await createMockQueryHistory(allHistory);
604+
// initialize the selection
605+
await queryHistoryManager.treeView.reveal(
606+
variantAnalysisHistory[0],
607+
{
608+
select: true,
609+
},
610+
);
611+
612+
// select the item we want
613+
await queryHistoryManager.treeView.reveal(selected, {
607614
select: true,
608-
},
609-
);
615+
});
610616

611-
// select the item we want
612-
await queryHistoryManager.treeView.reveal(selected, {
613-
select: true,
617+
// should be selected
618+
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
619+
selected,
620+
);
621+
622+
// remove an item
623+
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
624+
toDelete,
625+
]);
614626
});
615627

616-
// should be selected
617-
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
618-
selected,
619-
);
628+
it("should remove the item", () => {
629+
expect(
630+
variantAnalysisManagerStub.removeVariantAnalysis,
631+
).toHaveBeenCalledWith(toDelete.variantAnalysis);
632+
expect(
633+
queryHistoryManager.treeDataProvider.allHistory,
634+
).not.toContain(toDelete);
635+
});
620636

621-
// remove an item
622-
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
623-
toDelete,
624-
]);
637+
it("should not change the selection", () => {
638+
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
639+
selected,
640+
);
641+
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
642+
selected.variantAnalysis.id,
643+
);
644+
});
625645
});
626646

627-
it("should remove the item", () => {
628-
expect(
629-
variantAnalysisManagerStub.removeVariantAnalysis,
630-
).toHaveBeenCalledWith(toDelete.variantAnalysis);
631-
expect(
632-
queryHistoryManager.treeDataProvider.allHistory,
633-
).not.toContain(toDelete);
634-
});
647+
describe("when the item being removed is selected", () => {
648+
let toDelete: VariantAnalysisHistoryItem;
649+
let newSelected: VariantAnalysisHistoryItem;
635650

636-
it("should not change the selection", () => {
637-
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
638-
selected,
639-
);
640-
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
641-
selected.variantAnalysis.id,
642-
);
651+
beforeEach(async () => {
652+
// deleting the selected item automatically selects next item
653+
toDelete = variantAnalysisHistory[1];
654+
newSelected = variantAnalysisHistory[2];
655+
656+
queryHistoryManager = await createMockQueryHistory(
657+
variantAnalysisHistory,
658+
);
659+
660+
// select the item we want
661+
await queryHistoryManager.treeView.reveal(toDelete, {
662+
select: true,
663+
});
664+
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
665+
toDelete,
666+
]);
667+
});
668+
669+
it("should remove the item", () => {
670+
expect(
671+
variantAnalysisManagerStub.removeVariantAnalysis,
672+
).toHaveBeenCalledWith(toDelete.variantAnalysis);
673+
expect(
674+
queryHistoryManager.treeDataProvider.allHistory,
675+
).not.toContain(toDelete);
676+
});
677+
678+
it.skip("should change the selection", () => {
679+
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
680+
newSelected,
681+
);
682+
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
683+
newSelected.variantAnalysis.id,
684+
);
685+
});
643686
});
644687
});
645688

646-
describe("when the item being removed is selected", () => {
647-
let toDelete: VariantAnalysisHistoryItem;
648-
let newSelected: VariantAnalysisHistoryItem;
689+
describe("when not in progress", () => {
690+
describe("when the item being removed is not selected", () => {
691+
let toDelete: VariantAnalysisHistoryItem;
692+
let selected: VariantAnalysisHistoryItem;
649693

650-
beforeEach(async () => {
651-
// deleting the selected item automatically selects next item
652-
toDelete = variantAnalysisHistory[1];
653-
newSelected = variantAnalysisHistory[2];
694+
beforeEach(async () => {
695+
// deleting the first item when a different item is selected
696+
// will not change the selection
697+
toDelete = variantAnalysisHistory[2];
698+
selected = variantAnalysisHistory[3];
654699

655-
queryHistoryManager = await createMockQueryHistory(
656-
variantAnalysisHistory,
657-
);
700+
queryHistoryManager = await createMockQueryHistory(allHistory);
701+
// initialize the selection
702+
await queryHistoryManager.treeView.reveal(
703+
variantAnalysisHistory[0],
704+
{
705+
select: true,
706+
},
707+
);
658708

659-
// select the item we want
660-
await queryHistoryManager.treeView.reveal(toDelete, {
661-
select: true,
709+
// select the item we want
710+
await queryHistoryManager.treeView.reveal(selected, {
711+
select: true,
712+
});
713+
714+
// should be selected
715+
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
716+
selected,
717+
);
718+
719+
// remove an item
720+
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
721+
toDelete,
722+
]);
662723
});
663-
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
664-
toDelete,
665-
]);
666-
});
667724

668-
it("should remove the item", () => {
669-
expect(
670-
variantAnalysisManagerStub.removeVariantAnalysis,
671-
).toHaveBeenCalledWith(toDelete.variantAnalysis);
672-
expect(
673-
queryHistoryManager.treeDataProvider.allHistory,
674-
).not.toContain(toDelete);
725+
it("should remove the item", () => {
726+
expect(
727+
variantAnalysisManagerStub.removeVariantAnalysis,
728+
).toHaveBeenCalledWith(toDelete.variantAnalysis);
729+
expect(
730+
queryHistoryManager.treeDataProvider.allHistory,
731+
).not.toContain(toDelete);
732+
});
733+
734+
it("should not change the selection", () => {
735+
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
736+
selected,
737+
);
738+
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
739+
selected.variantAnalysis.id,
740+
);
741+
});
675742
});
676743

677-
it.skip("should change the selection", () => {
678-
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
679-
newSelected,
680-
);
681-
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
682-
newSelected.variantAnalysis.id,
683-
);
744+
describe("when the item being removed is selected", () => {
745+
let toDelete: VariantAnalysisHistoryItem;
746+
let newSelected: VariantAnalysisHistoryItem;
747+
748+
beforeEach(async () => {
749+
// deleting the selected item automatically selects next item
750+
toDelete = variantAnalysisHistory[0];
751+
newSelected = variantAnalysisHistory[2];
752+
753+
queryHistoryManager = await createMockQueryHistory(
754+
variantAnalysisHistory,
755+
);
756+
757+
// select the item we want
758+
await queryHistoryManager.treeView.reveal(toDelete, {
759+
select: true,
760+
});
761+
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [
762+
toDelete,
763+
]);
764+
});
765+
766+
it("should remove the item", () => {
767+
expect(
768+
variantAnalysisManagerStub.removeVariantAnalysis,
769+
).toHaveBeenCalledWith(toDelete.variantAnalysis);
770+
expect(
771+
queryHistoryManager.treeDataProvider.allHistory,
772+
).not.toContain(toDelete);
773+
});
774+
775+
it.skip("should change the selection", () => {
776+
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
777+
newSelected,
778+
);
779+
expect(variantAnalysisManagerStub.showView).toHaveBeenCalledWith(
780+
newSelected.variantAnalysis.id,
781+
);
782+
});
684783
});
685784
});
686785
});

0 commit comments

Comments
 (0)