Skip to content

test(cqn4sql): refactor calculated elements test suite - #1643

Open
patricebender wants to merge 6 commits into
mainfrom
patrice/refactor-calculated-elements-tests
Open

test(cqn4sql): refactor calculated elements test suite#1643
patricebender wants to merge 6 commits into
mainfrom
patrice/refactor-calculated-elements-tests

Conversation

@patricebender

@patricebender patricebender commented Jun 11, 2026

Copy link
Copy Markdown
Member

Splits the 1,254-line calculated-elements.test.js into a calculated-elements.test/ directory of topic-based specs, grouped by what aspect of the unfolder each test exercises: basics, nesting, functions, ternary, joins (with a join node reuse describe), filters, exists, variable-replacements, wildcard, nested-projections, query-clauses, plus localized, drafts, and stored.

Test bodies are moved verbatim — no semantic changes. Same 75 passing + 1 pre-existing skip as before.

Split the monolithic calculated-elements.test.js (1,254 lines, 76 tests)
into a calculated-elements.test/ directory with topic-based spec files,
mirroring the pattern from assoc2join.test/, exists.test/, and
nested-projections.test/.

- select-list.spec.js  (50 tests)
- other-places.spec.js (17 tests)
- localized.spec.js    (4 tests)
- exists.spec.js       (2 tests)
- drafts.spec.js       (2 tests)
- stored.spec.js       (1 test)

Adopt the shared loadModel/expectCqn helpers, rename query → transformed,
and indent cds.ql template literals to match the surrounding JS context.
The localized describe verifies the SELECT.localized flag with a separate
standard assertion since expectCqn's normalize drops inherited enumerable
props.
Rename other-places.spec.js → outside-select-list.spec.js and fold the
two exists tests into it as a nested describe — they're a special case
of calc elements unfolding outside the select list, not a standalone
topic worth its own file.
@patricebender
patricebender marked this pull request as draft June 11, 2026 15:32
The placement-based split (`select-list` vs `outside-select-list`)
mixed several distinct concerns inside a single 889-line file. Reorganize
into content-focused specs, each grouping tests by the unfolder aspect
they exercise:

- basics.spec.js              - trivial alias/val/scalar xpr
- nesting.spec.js             - calc element references calc element
- functions.spec.js           - function calls, named params, native fns
- ternary.spec.js             - CASE / ternary unfolding
- joins.spec.js               - join generation (incl. nested describe
                                for join-node reuse)
- filters.spec.js             - infix filters in / on calc elements
- exists.spec.js              - EXISTS-rejection + calc-elem-with-exists
- variable-replacements.spec.js - $now / $user preservation
- wildcard.spec.js            - {*} / excluding interactions
- nested-projections.spec.js  - inline / expand / subquery
- placements.spec.js          - where/from/group by/having/order by

Test bodies are moved verbatim; no semantics changed.
@patricebender
patricebender marked this pull request as ready for review June 21, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant