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:
@@ -2,7 +2,8 @@ import { describe, it, expect } from 'vitest';
|
||||
import { CategoryStub } from '@tests/unit/shared/Stubs/CategoryStub';
|
||||
import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
|
||||
import { AppliedFilterResult } from '@/application/Context/State/Filter/Result/AppliedFilterResult';
|
||||
import type { ICategory, IScript } from '@/domain/ICategory';
|
||||
import type { Category } from '@/domain/Executables/Category/Category';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
|
||||
describe('AppliedFilterResult', () => {
|
||||
describe('constructor', () => {
|
||||
@@ -68,18 +69,18 @@ describe('AppliedFilterResult', () => {
|
||||
});
|
||||
|
||||
class ResultBuilder {
|
||||
private scriptMatches: readonly IScript[] = [new ScriptStub('id')];
|
||||
private scriptMatches: readonly Script[] = [new ScriptStub('id')];
|
||||
|
||||
private categoryMatches: readonly ICategory[] = [new CategoryStub(5)];
|
||||
private categoryMatches: readonly Category[] = [new CategoryStub(5)];
|
||||
|
||||
private query: string = `[${ResultBuilder.name}]query`;
|
||||
|
||||
public withScriptMatches(scriptMatches: readonly IScript[]): this {
|
||||
public withScriptMatches(scriptMatches: readonly Script[]): this {
|
||||
this.scriptMatches = scriptMatches;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withCategoryMatches(categoryMatches: readonly ICategory[]): this {
|
||||
public withCategoryMatches(categoryMatches: readonly Category[]): this {
|
||||
this.categoryMatches = categoryMatches;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ import { CategoryStub } from '@tests/unit/shared/Stubs/CategoryStub';
|
||||
import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
|
||||
import { CategoryCollectionStub } from '@tests/unit/shared/Stubs/CategoryCollectionStub';
|
||||
import type { ICategoryCollection } from '@/domain/ICategoryCollection';
|
||||
import type { ICategory } from '@/domain/ICategory';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import type { Category } from '@/domain/Executables/Category/Category';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import type { FilterResult } from '@/application/Context/State/Filter/Result/FilterResult';
|
||||
import { LinearFilterStrategy } from '@/application/Context/State/Filter/Strategy/LinearFilterStrategy';
|
||||
|
||||
@@ -89,7 +89,7 @@ describe('LinearFilterStrategy', () => {
|
||||
interface ScriptMatchTestScenario {
|
||||
readonly description: string;
|
||||
readonly filter: string;
|
||||
readonly matchingScript: IScript;
|
||||
readonly matchingScript: Script;
|
||||
}
|
||||
const testScenarios: readonly ScriptMatchTestScenario[] = [
|
||||
{
|
||||
@@ -134,7 +134,7 @@ describe('LinearFilterStrategy', () => {
|
||||
it('returns multiple matching scripts', () => {
|
||||
// arrange
|
||||
const filter = 'matching filter';
|
||||
const matchingScripts: readonly IScript[] = [
|
||||
const matchingScripts: readonly Script[] = [
|
||||
createMatchingScript(filter),
|
||||
createMatchingScript(filter),
|
||||
];
|
||||
@@ -165,7 +165,7 @@ describe('LinearFilterStrategy', () => {
|
||||
interface CategoryMatchTestScenario {
|
||||
readonly description: string;
|
||||
readonly filter: string;
|
||||
readonly matchingCategory: ICategory;
|
||||
readonly matchingCategory: Category;
|
||||
}
|
||||
const testScenarios: readonly CategoryMatchTestScenario[] = [
|
||||
{
|
||||
@@ -200,7 +200,7 @@ describe('LinearFilterStrategy', () => {
|
||||
it('returns multiple matching categories', () => {
|
||||
// arrange
|
||||
const filter = 'matching filter';
|
||||
const matchingCategories: readonly ICategory[] = [
|
||||
const matchingCategories: readonly Category[] = [
|
||||
createMatchingCategory(filter),
|
||||
createMatchingCategory(filter),
|
||||
];
|
||||
@@ -237,7 +237,7 @@ function createMatchingCategory(
|
||||
|
||||
function expectCategoryMatches(
|
||||
actualFilter: FilterResult,
|
||||
expectedMatches: readonly ICategory[],
|
||||
expectedMatches: readonly Category[],
|
||||
): void {
|
||||
expect(actualFilter.hasAnyMatches()).be.equal(true);
|
||||
expect(actualFilter.categoryMatches).to.have.lengthOf(expectedMatches.length);
|
||||
@@ -246,7 +246,7 @@ function expectCategoryMatches(
|
||||
|
||||
function expectScriptMatches(
|
||||
actualFilter: FilterResult,
|
||||
expectedMatches: readonly IScript[],
|
||||
expectedMatches: readonly Script[],
|
||||
): void {
|
||||
expect(actualFilter.hasAnyMatches()).be.equal(true);
|
||||
expect(actualFilter.scriptMatches).to.have.lengthOf(expectedMatches.length);
|
||||
|
||||
@@ -8,7 +8,8 @@ import { ScriptSelectionStub } from '@tests/unit/shared/Stubs/ScriptSelectionStu
|
||||
import type { CategorySelectionChange } from '@/application/Context/State/Selection/Category/CategorySelectionChange';
|
||||
import type { ScriptSelectionChange, ScriptSelectionChangeCommand } from '@/application/Context/State/Selection/Script/ScriptSelectionChange';
|
||||
import { expectExists } from '@tests/shared/Assertions/ExpectExists';
|
||||
import type { ICategory, IScript } from '@/domain/ICategory';
|
||||
import type { Category } from '@/domain/Executables/Category/Category';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
|
||||
describe('ScriptToCategorySelectionMapper', () => {
|
||||
describe('areAllScriptsSelected', () => {
|
||||
@@ -64,8 +65,8 @@ describe('ScriptToCategorySelectionMapper', () => {
|
||||
readonly description: string;
|
||||
readonly changes: readonly CategorySelectionChange[];
|
||||
readonly categories: ReadonlyArray<{
|
||||
readonly categoryId: ICategory['id'],
|
||||
readonly scriptIds: readonly IScript['id'][],
|
||||
readonly categoryId: Category['id'],
|
||||
readonly scriptIds: readonly Script['id'][],
|
||||
}>;
|
||||
readonly expected: readonly ScriptSelectionChange[],
|
||||
}> = [
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { SelectedScript } from '@/application/Context/State/Selection/Scrip
|
||||
import { BatchedDebounceStub } from '@tests/unit/shared/Stubs/BatchedDebounceStub';
|
||||
import type { ScriptSelectionChange, ScriptSelectionChangeCommand } from '@/application/Context/State/Selection/Script/ScriptSelectionChange';
|
||||
import { expectExists } from '@tests/shared/Assertions/ExpectExists';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import { expectEqualSelectedScripts } from './ExpectEqualSelectedScripts';
|
||||
|
||||
type DebounceArg = ScriptSelectionChangeCommand;
|
||||
@@ -538,7 +538,7 @@ describe('DebouncedScriptSelection', () => {
|
||||
});
|
||||
});
|
||||
|
||||
function createCollectionWithScripts(...scripts: IScript[]): CategoryCollectionStub {
|
||||
function createCollectionWithScripts(...scripts: Script[]): CategoryCollectionStub {
|
||||
const category = new CategoryStub(1).withScripts(...scripts);
|
||||
const collection = new CategoryCollectionStub().withAction(category);
|
||||
return collection;
|
||||
|
||||
Reference in New Issue
Block a user