Refactor to unify scripts/categories as Executable
This commit consolidates scripts and categories under a unified 'Executable' concept. This simplifies the architecture and improves code readability. - Introduce subfolders within `src/domain` to segregate domain elements. - Update class and interface names by removing the 'I' prefix in alignment with new coding standards. - Replace 'Node' with 'Executable' to clarify usage; reserve 'Node' exclusively for the UI's tree component.
This commit is contained in:
@@ -3,14 +3,14 @@ import {
|
||||
type SelectionCheckContext, type SelectionMutationContext,
|
||||
getCurrentRecommendationStatus, setCurrentRecommendationStatus,
|
||||
} from '@/presentation/components/Scripts/Menu/Recommendation/RecommendationStatusHandler';
|
||||
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
||||
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
|
||||
import type { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState';
|
||||
import { EnumRangeTestRunner } from '@tests/unit/application/Common/EnumRangeTestRunner';
|
||||
import type { ScriptSelection } from '@/application/Context/State/Selection/Script/ScriptSelection';
|
||||
import type { MethodCall } from '@tests/unit/shared/Stubs/StubWithObservableMethodCalls';
|
||||
import { expectExists } from '@tests/shared/Assertions/ExpectExists';
|
||||
import { scrambledEqual } from '@/application/Common/Array';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import { RecommendationStatusType } from '@/presentation/components/Scripts/Menu/Recommendation/RecommendationStatusType';
|
||||
import { RecommendationStatusTestScenario } from './RecommendationStatusTestScenario';
|
||||
|
||||
@@ -85,8 +85,8 @@ describe('RecommendationStatusHandler', () => {
|
||||
expectExists(call);
|
||||
if (expectedCall.args.length > 0) { /** {@link ScriptSelection.selectOnly}. */
|
||||
expect(scrambledEqual(
|
||||
call.args[0] as IScript[],
|
||||
expectedCall.args[0] as IScript[],
|
||||
call.args[0] as Script[],
|
||||
expectedCall.args[0] as Script[],
|
||||
)).to.equal(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { SelectedScript } from '@/application/Context/State/Selection/Script/SelectedScript';
|
||||
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
||||
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
|
||||
import { CategoryCollectionStateStub } from '@tests/unit/shared/Stubs/CategoryCollectionStateStub';
|
||||
import { ScriptSelectionStub } from '@tests/unit/shared/Stubs/ScriptSelectionStub';
|
||||
import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
|
||||
|
||||
@@ -8,15 +8,15 @@ import { UserSelectionStub } from '@tests/unit/shared/Stubs/UserSelectionStub';
|
||||
import { SelectedScriptStub } from '@tests/unit/shared/Stubs/SelectedScriptStub';
|
||||
import type { SelectedScript } from '@/application/Context/State/Selection/Script/SelectedScript';
|
||||
import { CategorySelectionStub } from '@tests/unit/shared/Stubs/CategorySelectionStub';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
|
||||
describe('CategoryReverter', () => {
|
||||
describe('getState', () => {
|
||||
// arrange
|
||||
const testScenarios: ReadonlyArray<{
|
||||
readonly description: string;
|
||||
readonly allScripts: readonly IScript[];
|
||||
readonly selectScripts: (allScripts: readonly IScript[]) => readonly SelectedScript[];
|
||||
readonly allScripts: readonly Script[];
|
||||
readonly selectScripts: (allScripts: readonly Script[]) => readonly SelectedScript[];
|
||||
readonly expectedState: boolean;
|
||||
}> = [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import type { ICategory } from '@/domain/ICategory';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import type { Category } from '@/domain/Executables/Category/Category';
|
||||
import { CategoryStub } from '@tests/unit/shared/Stubs/CategoryStub';
|
||||
import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
|
||||
import { CategoryCollectionStub } from '@tests/unit/shared/Stubs/CategoryCollectionStub';
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
getCategoryId, getCategoryNodeId, getScriptId,
|
||||
getScriptNodeId, parseAllCategories, parseSingleCategory,
|
||||
} from '@/presentation/components/Scripts/View/Tree/TreeViewAdapter/CategoryNodeMetadataConverter';
|
||||
import { NodeDataType } from '@/application/Parser/NodeValidation/NodeDataType';
|
||||
import { ExecutableType } from '@/application/Parser/Executable/Validation/ExecutableType';
|
||||
import type { NodeMetadata } from '@/presentation/components/Scripts/View/Tree/NodeContent/NodeMetadata';
|
||||
import { expectExists } from '@tests/shared/Assertions/ExpectExists';
|
||||
|
||||
@@ -94,7 +94,7 @@ describe('CategoryNodeMetadataConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
function isReversible(category: ICategory): boolean {
|
||||
function isReversible(category: Category): boolean {
|
||||
if (category.scripts) {
|
||||
if (category.scripts.some((s) => !s.canRevert())) {
|
||||
return false;
|
||||
@@ -108,8 +108,8 @@ function isReversible(category: ICategory): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
function expectSameCategory(node: NodeMetadata, category: ICategory): void {
|
||||
expect(node.type).to.equal(NodeDataType.Category, getErrorMessage('type'));
|
||||
function expectSameCategory(node: NodeMetadata, category: Category): void {
|
||||
expect(node.type).to.equal(ExecutableType.Category, getErrorMessage('type'));
|
||||
expect(node.id).to.equal(getCategoryNodeId(category), getErrorMessage('id'));
|
||||
expect(node.docs).to.equal(category.docs, getErrorMessage('docs'));
|
||||
expect(node.text).to.equal(category.name, getErrorMessage('name'));
|
||||
@@ -135,8 +135,8 @@ function expectSameCategory(node: NodeMetadata, category: ICategory): void {
|
||||
}
|
||||
}
|
||||
|
||||
function expectSameScript(node: NodeMetadata, script: IScript): void {
|
||||
expect(node.type).to.equal(NodeDataType.Script, getErrorMessage('type'));
|
||||
function expectSameScript(node: NodeMetadata, script: Script): void {
|
||||
expect(node.type).to.equal(ExecutableType.Script, getErrorMessage('type'));
|
||||
expect(node.id).to.equal(getScriptNodeId(script), getErrorMessage('id'));
|
||||
expect(node.docs).to.equal(script.docs, getErrorMessage('docs'));
|
||||
expect(node.text).to.equal(script.name, getErrorMessage('name'));
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';
|
||||
import { useSelectedScriptNodeIds } from '@/presentation/components/Scripts/View/Tree/TreeViewAdapter/UseSelectedScriptNodeIds';
|
||||
import { SelectedScriptStub } from '@tests/unit/shared/Stubs/SelectedScriptStub';
|
||||
import { getScriptNodeId } from '@/presentation/components/Scripts/View/Tree/TreeViewAdapter/CategoryNodeMetadataConverter';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import { UseUserSelectionStateStub } from '@tests/unit/shared/Stubs/UseUserSelectionStateStub';
|
||||
import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('useSelectedScriptNodeIds', () => {
|
||||
new SelectedScriptStub(new ScriptStub('id-1')),
|
||||
new SelectedScriptStub(new ScriptStub('id-2')),
|
||||
];
|
||||
const parsedNodeIds = new Map<IScript, string>([
|
||||
const parsedNodeIds = new Map<Script, string>([
|
||||
[selectedScripts[0].script, 'expected-id-1'],
|
||||
[selectedScripts[1].script, 'expected-id-2'],
|
||||
]);
|
||||
@@ -47,7 +47,7 @@ describe('useSelectedScriptNodeIds', () => {
|
||||
new SelectedScriptStub(new ScriptStub('id-1')),
|
||||
new SelectedScriptStub(new ScriptStub('id-2')),
|
||||
];
|
||||
const parsedNodeIds = new Map<IScript, string>([
|
||||
const parsedNodeIds = new Map<Script, string>([
|
||||
[changedScripts[0].script, 'expected-id-1'],
|
||||
[changedScripts[1].script, 'expected-id-2'],
|
||||
]);
|
||||
@@ -70,7 +70,7 @@ describe('useSelectedScriptNodeIds', () => {
|
||||
|
||||
type ScriptNodeIdParser = typeof getScriptNodeId;
|
||||
|
||||
function createNodeIdParserFromMap(scriptToIdMap: Map<IScript, string>): ScriptNodeIdParser {
|
||||
function createNodeIdParserFromMap(scriptToIdMap: Map<Script, string>): ScriptNodeIdParser {
|
||||
return (script) => {
|
||||
const expectedId = scriptToIdMap.get(script);
|
||||
if (!expectedId) {
|
||||
|
||||
@@ -11,8 +11,8 @@ import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
|
||||
import { CategoryStub } from '@tests/unit/shared/Stubs/CategoryStub';
|
||||
import { TreeNodeStub } from '@tests/unit/shared/Stubs/TreeNodeStub';
|
||||
import { HierarchyAccessStub } from '@tests/unit/shared/Stubs/HierarchyAccessStub';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import type { ICategory } from '@/domain/ICategory';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import type { Category } from '@/domain/Executables/Category/Category';
|
||||
import type { TreeNode } from '@/presentation/components/Scripts/View/Tree/TreeView/Node/TreeNode';
|
||||
import { FilterChangeDetailsStub } from '@tests/unit/shared/Stubs/FilterChangeDetailsStub';
|
||||
import type { FilterChangeDetails } from '@/application/Context/State/Filter/Event/FilterChangeDetails';
|
||||
@@ -208,8 +208,8 @@ function itExpectedFilterTriggeredEvent(
|
||||
) {
|
||||
const testScenarios: ReadonlyArray<{
|
||||
readonly description: string;
|
||||
readonly scriptMatches: IScript[],
|
||||
readonly categoryMatches: ICategory[],
|
||||
readonly scriptMatches: Script[],
|
||||
readonly categoryMatches: Category[],
|
||||
readonly givenNode: TreeNode,
|
||||
readonly expectedPredicateResult: boolean;
|
||||
}> = [
|
||||
|
||||
Reference in New Issue
Block a user