You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add unit tests for the editor tab tracking helpers #20180
Six of the module's eight exports are untested. getTabType and getTabMetadata are pure classification over a tab object and are the interesting half; the track* functions wrap them and emit the analytics event.
While writing the test, run just this file so the feedback loop stays fast:
cd ui && npm run test:unit -- tests/unit/utils/tabTracking.spec.ts
Proof required in the PR
Important
The PR that closes this issue must include a screenshot of the test passing, pasted into the PR description. 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) and Tests N passed (N)). Then drag the image straight into the PR description field on GitHub, which uploads and embeds it.
What
ui/src/utils/tabTracking.tsalready has a spec, but the exports below have no coverage in it.Six of the module's eight exports are untested.
getTabTypeandgetTabMetadataare pure classification over a tab object and are the interesting half; thetrack*functions wrap them and emit the analytics event.What to do
Add cases to the existing
ui/tests/unit/utils/tabTracking.spec.tscovering:getTabTypeclassifies each kind of editor tab correctlygetTabTypereturns a sensible value for an unrecognised tab rather than throwinggetTabMetadatabuilds the expected payload for each tab typetrackTabOpen,trackTabClose,trackFileOpenandtrackBlueprintSelectioneach emit one event with the righttypeand metadataStub the api store and assert the payload it receives.
Reference
The spec file itself shows the house style;
ui/tests/unit/utils/splitTranslation.spec.tsis another example.How to run
Install once, then run the whole suite:
While writing the test, run just this file so the feedback loop stays fast:
Proof required in the
PRImportant
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.