@cqa-lib/cqa-ui 1.1.399 → 1.1.400

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.
@@ -25138,7 +25138,8 @@ class TestCaseConditionStepComponent {
25138
25138
  }
25139
25139
  buildElseIfBranch(index) {
25140
25140
  // Initialize ELSE IF form with empty values or from existing ELSE IF branch if available
25141
- const elseIfBranches = this.branches?.filter(b => b.type === 'else-if') || [];
25141
+ // Use getAllBranchesFlat to include chained nextBranch ELSE IFs
25142
+ const elseIfBranches = this.getAllBranchesFlat().filter(b => b.type === 'else-if');
25142
25143
  const branchIndex = index !== undefined ? index : elseIfBranches.length;
25143
25144
  const elseIfBranch = elseIfBranches[branchIndex];
25144
25145
  const elseCondition = elseIfBranch?.action || '';
@@ -25466,8 +25467,25 @@ class TestCaseConditionStepComponent {
25466
25467
  }
25467
25468
  /** Count and summarize condition branches using their display step numbers.
25468
25469
  * Example: IF + 2x ELSE IF + ELSE → "Steps 6-9 (4 steps)". */
25470
+ /**
25471
+ * Returns a flat list of all branches including those chained via nextBranch.
25472
+ * Used for counting, badge display, and summary when the condition uses a chained structure.
25473
+ */
25474
+ getAllBranchesFlat() {
25475
+ const result = [];
25476
+ const traverse = (branches) => {
25477
+ for (const b of branches) {
25478
+ result.push(b);
25479
+ if (b.nextBranch)
25480
+ traverse([b.nextBranch]);
25481
+ }
25482
+ };
25483
+ traverse(this.branches || []);
25484
+ return result;
25485
+ }
25469
25486
  getStepsSummary() {
25470
- const branchCount = this.branches?.length ?? 0;
25487
+ const allBranches = this.getAllBranchesFlat();
25488
+ const branchCount = allBranches.length;
25471
25489
  if (branchCount === 0) {
25472
25490
  return '0 steps';
25473
25491
  }
@@ -25481,7 +25499,8 @@ class TestCaseConditionStepComponent {
25481
25499
  /** Branch type badges for step row: IF, ELSE IF (with count if multiple), ELSE */
25482
25500
  getBranchTypeBadges() {
25483
25501
  const badges = [];
25484
- const elseIfCount = this.branches?.filter(b => b.type === 'else-if').length ?? 0;
25502
+ const allBranches = this.getAllBranchesFlat();
25503
+ const elseIfCount = allBranches.filter(b => b.type === 'else-if').length;
25485
25504
  const hasElse = this.hasElseBranch;
25486
25505
  badges.push({ label: 'IF', type: 'if', badgeClass: 'cqa-bg-[#0DBD7D1A] cqa-text-[#0D542B] cqa-border cqa-border-solid cqa-border-[#0DBD7D]' });
25487
25506
  if (elseIfCount > 0) {
@@ -25700,7 +25719,7 @@ class TestCaseConditionStepComponent {
25700
25719
  }
25701
25720
  /** True when condition already has an ELSE branch (disables Add ELSE IF / Add ELSE). */
25702
25721
  get hasElseBranch() {
25703
- return this.branches?.some(b => b.type === 'else') ?? false;
25722
+ return this.getAllBranchesFlat().some(b => b.type === 'else');
25704
25723
  }
25705
25724
  onOpenExternal() {
25706
25725
  // Not used in condition step, but needed for recursive step groups
@@ -25908,6 +25927,7 @@ class TestCaseConditionStepComponent {
25908
25927
  let updatedConfig;
25909
25928
  if (isEditingElseIfBranch && branchForEdit && branchForEdit.id != null) {
25910
25929
  // Editing existing ELSE IF branch: target that branch's step ID and send raw condition so backend updates the branch only.
25930
+ // Any new ELSE IF added here chains off this specific ELSE IF (handled by step-list since updatedConfig.id = this branch's id).
25911
25931
  updatedConfig = {
25912
25932
  ...updatedConfigBase,
25913
25933
  id: String(branchForEdit.id),
@@ -25917,10 +25937,15 @@ class TestCaseConditionStepComponent {
25917
25937
  };
25918
25938
  }
25919
25939
  else {
25920
- // IF condition edit (step row or IF branch row): use formatted condition for display
25940
+ // IF condition edit (step row or IF branch row): use formatted condition for display.
25941
+ // When editing from the IF TRUE branch row (branchIndex === 0), any new ELSE IFs must be
25942
+ // inserted directly after the IF branch — not at the end of the chain.
25943
+ // Pass insertAfterBranchId so step-list knows the exact insertion point.
25944
+ const isEditingIfBranchRow = isEditingBranchRow && branchForEdit?.type === 'if' && branchForEdit.id != null;
25921
25945
  updatedConfig = {
25922
25946
  ...updatedConfigBase,
25923
25947
  condition: this.condition,
25948
+ ...(isEditingIfBranchRow && { insertAfterBranchId: String(branchForEdit.id) }),
25924
25949
  };
25925
25950
  }
25926
25951
  // Emit individual change event