Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Test version-sensitive storage guarantees on the supported backend
For storage changes that rely on backend response shapes, atomicity or error semantics, run focused contract tests against the supported server version using the production adapter.
Bad example
| 1 | client.updateAliases.mockResolvedValue({ acknowledged: true }); |
| 2 | await store.publish(candidate); |
| 3 | expect(client.updateAliases).toHaveBeenCalled(); |
Explanation (EN)
This sequence does not enforce the required storage guarantee.
Objašnjenje (HR)
Ovaj slijed ne osigurava potrebnu garanciju pohrane.
Good example
| 1 | const before = await readPublishedTarget(testClient); |
| 2 | await invalidateOldOwner(testClient); |
| 3 | await expect(oldStore.publish(candidate)).rejects.toThrow(); |
| 4 | expect(await readPublishedTarget(testClient)).toEqual(before); |
Explanation (EN)
The storage operation and its observable result enforce the stated contract. Helper names denote required backend guarantees, not guarantees supplied by TypeScript.
Objašnjenje (HR)
Operacija i njezin vidljivi rezultat provode zadani ugovor. Nazivi helpera predstavljaju potrebne garancije baze, a ne TypeScripta.
Notes (EN)
The good example runs against an isolated real backend using the production storage adapter. Pin and report the tested engine/version. Cover the specific guarantee relied upon, such as all-or-nothing alias changes, stale-owner rejection, missing-document versus missing-index errors, or mapping/settings serialization. Client typings and mocks do not prove server behavior. Use synthetic data and disposable resources, then clean them up. Keep unit tests for fast logic coverage. Report untested deployment differences such as managed-service permissions and engine upgrades rather than claiming production compatibility.
Bilješke (HR)
Za ponasanje ovisno o verziji baze koristi stvarni podrzani backend i produkcijski adapter. Testiraj tocnu garanciju na izoliranim podacima. Navedi testiranu verziju i sto jos nije provjereno na ciljnom okruzenju.
Exceptions / Tradeoffs (EN)
Routine pure logic changes do not require a live service test. Existing contract coverage can be reused when the relevant adapter, engine and guarantee are unchanged. If the backend is unavailable, state the validation gap instead of treating mocks as equivalent.
Iznimke / Tradeoffi (HR)
Primijeni samo kada postoje navedeni uvjeti. Jednostavniji pristup je valjan ako sustav vec jamci isti rezultat.