Add unit tests for rowKey
What
ui/packages/design-system/src/utils/rowKey.ts has no test yet.
It hands a stable v-for key to editable rows that have no id of their own. If it ever returned a different key for the same row object, every keystroke would remount the row and the input would lose focus.
What to do
Create ui/packages/design-system/tests/units/utils/rowKey.test.ts covering:
- the same object returns the same key across calls
- two different objects get different keys
- two objects that are deeply equal but not identical still get different keys
- the key matches the
row-<n>shape
The cache is a module-level WeakMap, so the counter carries across cases within a file. Assert relationships between keys rather than exact numbers.
Reference
ui/packages/design-system/tests/units/utils/lang.test.ts is an existing test of the same shape to copy from.
How to run
Install once, then run the whole suite:
cd ui/packages/design-system && npm install && npm run test:unitWhile writing the test, run just this file so the feedback loop stays fast:
cd ui/packages/design-system && npm run test:unit -- tests/units/utils/rowKey.test.tsProof required in the PR
[!IMPORTANT] The
PRthat closes this issue must include a screenshot of the test passing, pasted into thePRdescription. Pasted text output is not enough.To produce it, run the single-file command above and screenshot the terminal. The capture should show the command, the test file, and the green summary lines (
Test Files 1 passed (1)andTests N passed (N)). Then drag the image straight into thePRdescription field on GitHub, which uploads and embeds it.
Source: kestra-io/kestra