From 62f8bfac2f481c93598fe19a51594769f522d684 Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Fri, 25 Aug 2023 00:32:01 +0200 Subject: [PATCH] Fix searching/filtering bugs #235 - Fix a bug (introduced in 1b9be8fe) preventing the tree view from being visible during a search. - Fix a minor bug where the scripts view does not render based on the initial filter. - Add Vue component tests for `TheScriptView` to prevent regressions. - Refactor `isSearching` in `TheScriptView` to simplify its logic. --- .../Events/EventSubscriptionCollection.ts | 3 +- .../Events/IEventSubscriptionCollection.ts | 7 + .../Scripts/View/TheScriptsView.vue | 37 +- .../Shared/Hooks/UseCollectionState.ts | 33 +- .../Scripts/View/TheScriptsView.spec.ts | 416 ++++++++++++++++++ .../Stubs/CategoryCollectionStateStub.ts | 7 +- .../Stubs/EventSubscriptionCollectionStub.ts | 14 + tests/unit/shared/Stubs/FilterResultStub.ts | 6 + tests/unit/shared/Stubs/UseApplicationStub.ts | 19 + .../shared/Stubs/UseCollectionStateStub.ts | 87 ++++ tests/unit/shared/Stubs/UserFilterStub.ts | 15 +- 11 files changed, 613 insertions(+), 31 deletions(-) create mode 100644 src/infrastructure/Events/IEventSubscriptionCollection.ts create mode 100644 tests/unit/presentation/components/Scripts/View/TheScriptsView.spec.ts create mode 100644 tests/unit/shared/Stubs/EventSubscriptionCollectionStub.ts create mode 100644 tests/unit/shared/Stubs/UseApplicationStub.ts create mode 100644 tests/unit/shared/Stubs/UseCollectionStateStub.ts diff --git a/src/infrastructure/Events/EventSubscriptionCollection.ts b/src/infrastructure/Events/EventSubscriptionCollection.ts index 819ec0d5..f8ce7baf 100644 --- a/src/infrastructure/Events/EventSubscriptionCollection.ts +++ b/src/infrastructure/Events/EventSubscriptionCollection.ts @@ -1,6 +1,7 @@ import { IEventSubscription } from './IEventSource'; +import { IEventSubscriptionCollection } from './IEventSubscriptionCollection'; -export class EventSubscriptionCollection { +export class EventSubscriptionCollection implements IEventSubscriptionCollection { private readonly subscriptions = new Array(); public register(...subscriptions: IEventSubscription[]) { diff --git a/src/infrastructure/Events/IEventSubscriptionCollection.ts b/src/infrastructure/Events/IEventSubscriptionCollection.ts new file mode 100644 index 00000000..57d09cb0 --- /dev/null +++ b/src/infrastructure/Events/IEventSubscriptionCollection.ts @@ -0,0 +1,7 @@ +import { IEventSubscription } from '@/infrastructure/Events/IEventSource'; + +export interface IEventSubscriptionCollection { + register(...subscriptions: IEventSubscription[]); + + unsubscribeAll(); +} diff --git a/src/presentation/components/Scripts/View/TheScriptsView.vue b/src/presentation/components/Scripts/View/TheScriptsView.vue index 3247e209..29321b3b 100644 --- a/src/presentation/components/Scripts/View/TheScriptsView.vue +++ b/src/presentation/components/Scripts/View/TheScriptsView.vue @@ -1,19 +1,24 @@