github-issue-tower-defence-management 1.187.1 → 1.187.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>TDPM Console</title>
7
- <script type="module" crossorigin src="/assets/index-wj6o8qvo.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-DfKDTGzS.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-yZy1TUOo.css">
9
9
  </head>
10
10
  <body>
@@ -652,6 +652,37 @@ describe('ProjectRequiredFieldCreateUseCase', () => {
652
652
  expect(projectRepository.updateAgentList).not.toHaveBeenCalled();
653
653
  });
654
654
 
655
+ it('removes agents not in agentNames by calling updateAgentList without them', async () => {
656
+ const project = buildProjectWithAgent([
657
+ { id: 'opt-impl', name: 'impl' },
658
+ { id: 'opt-old', name: 'old-agent' },
659
+ { id: 'opt-chore', name: 'chore' },
660
+ ]);
661
+ const { projectRepository, useCase } = createUseCase([], project);
662
+
663
+ await useCase.reconcileAgentOptions(project, ['impl', 'chore']);
664
+
665
+ expect(projectRepository.updateAgentList).toHaveBeenCalledWith(project, [
666
+ expect.objectContaining({ id: 'opt-impl', name: 'impl' }),
667
+ expect.objectContaining({ id: 'opt-chore', name: 'chore' }),
668
+ ]);
669
+ });
670
+
671
+ it('reorders agents to match agentNames order when order differs', async () => {
672
+ const project = buildProjectWithAgent([
673
+ { id: 'opt-chore', name: 'chore' },
674
+ { id: 'opt-impl', name: 'impl' },
675
+ ]);
676
+ const { projectRepository, useCase } = createUseCase([], project);
677
+
678
+ await useCase.reconcileAgentOptions(project, ['impl', 'chore']);
679
+
680
+ expect(projectRepository.updateAgentList).toHaveBeenCalledWith(project, [
681
+ expect.objectContaining({ id: 'opt-impl', name: 'impl' }),
682
+ expect.objectContaining({ id: 'opt-chore', name: 'chore' }),
683
+ ]);
684
+ });
685
+
655
686
  it('calls createField with AGENT_FIELD_NAME and initial agents when project has no agent field', async () => {
656
687
  const { projectRepository, useCase } = createUseCase(
657
688
  [],
@@ -106,26 +106,32 @@ export class ProjectRequiredFieldCreateUseCase {
106
106
  });
107
107
  return;
108
108
  }
109
- const existingOptions = project.agent.options;
110
- const existingNames = new Set(
111
- existingOptions.map((o) => normalizeProjectFieldName(o.name)),
109
+ const existingByNormalizedName = new Map(
110
+ project.agent.options.map((o) => [normalizeProjectFieldName(o.name), o]),
112
111
  );
113
- const toAdd = agentNames.filter(
114
- (name) => !existingNames.has(normalizeProjectFieldName(name)),
112
+ const targetOptions: OptionToSubmit[] = agentNames.map((name) => {
113
+ const existing = existingByNormalizedName.get(
114
+ normalizeProjectFieldName(name),
115
+ );
116
+ return existing
117
+ ? { ...existing }
118
+ : { id: null, name, color: 'GRAY' as const, description: '' };
119
+ });
120
+ const existingNormalizedNames = project.agent.options.map((o) =>
121
+ normalizeProjectFieldName(o.name),
122
+ );
123
+ const targetNormalizedNames = targetOptions.map((o) =>
124
+ normalizeProjectFieldName(o.name),
115
125
  );
116
- if (toAdd.length === 0) {
126
+ const needsUpdate =
127
+ existingNormalizedNames.length !== targetNormalizedNames.length ||
128
+ existingNormalizedNames.some(
129
+ (name, i) => name !== targetNormalizedNames[i],
130
+ );
131
+ if (!needsUpdate) {
117
132
  return;
118
133
  }
119
- const mergedOptions: OptionToSubmit[] = [
120
- ...existingOptions.map((o) => ({ ...o })),
121
- ...toAdd.map((name) => ({
122
- id: null,
123
- name,
124
- color: 'GRAY' as const,
125
- description: '',
126
- })),
127
- ];
128
- await this.projectRepository.updateAgentList(project, mergedOptions);
134
+ await this.projectRepository.updateAgentList(project, targetOptions);
129
135
  };
130
136
 
131
137
  private optionNameSatisfies = (
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectRequiredFieldCreateUseCase.d.ts","sourceRoot":"","sources":["../../../src/domain/usecases/ProjectRequiredFieldCreateUseCase.ts"],"names":[],"mappings":"AAAA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