---
id: TASK-14.2
title: Add coverage tests for configurator parsing branches
status: Done
assignee:
  - codex
created_date: '2026-02-19 09:11'
updated_date: '2026-02-19 10:57'
labels: []
dependencies: []
references:
  - lua/zync/api/configurator.lua
  - spec/api_spec/configurator_spec.lua
  - luacov.report.out
parent_task_id: TASK-14
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Add tests that exercise uncovered parsing/ordering branches in `lua/zync/api/configurator.lua` based on the luacov report.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 New or updated specs cover the missing branches in configurator parsing/order logic reported by luacov.
- [x] #2 Profile order resolution remains correct for existing cases.
- [x] #3 Tests pass under `busted -c`.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1) Identify configurator.lua uncovered branches from luacov (comment/escape parsing helpers, no-profiles-block path, bracketed key parsing, fallback profile order insertion).
2) Add focused zconf fixtures/specs in spec/api_spec/configurator_spec.lua to trigger those branches without changing behavior.
3) Run `busted -c` and re-check luacov report for configurator coverage improvement.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Luacov gaps in configurator.lua include comment/escape parsing helpers (skip_string backslash path, skip_line_comment EOF, skip_block_comment EOF, skip_ws_and_comments comment branches), find_profiles_block comment handling, extract_profile_order branch when no profiles block, bracketed key with non-quoted index, and profile_order_from_config fallback insertion when profiles block is not a literal `{...}`. Add zconf fixtures to drive these branches.

Starting TASK-14.2; will propose targeted spec additions for configurator parsing branches. Awaiting approval to proceed with test changes.

Added helper-focused tests in spec/api_spec/configurator_spec.lua to hit missing configurator parser branches (block comment handling, skip_ws_and_comments end return, scan_string unterminated path, quoted key extraction, apply_profile non-table profiles via upvalue). Did not run busted/luacov per user request. Await updated luacov report to verify coverage changes.

Added spec to cover configurator init_conf branch where zconf returns nil (sets ws.conf invalid). Please run tests/luacov and share updated report to confirm configurator misses are cleared.

Updated luacov report shows configurator.lua at 100% (234 hits, 0 missed). Awaiting remaining acceptance criteria (behavior consistency/test run confirmation if needed).
<!-- SECTION:NOTES:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Added configurator parsing/ordering tests in spec/api_spec/configurator_spec.lua covering comment/escape helpers, quoted-key parsing, fallback order paths, apply_profile type errors, and nil-return zconf branch. User confirmed tests pass; luacov shows configurator.lua at 100% coverage.
<!-- SECTION:FINAL_SUMMARY:END -->
