test(measurements): a re-import that changes nothing keeps its syncVersion

The second import of the same export writes every column of the step row
as it already was (compared column by column), so the update is a no-op
and migration 0412 keeps updated_at and sync_version. The test expected the
version to move on every write; it now pins that it never goes backwards
and stays where the first import left it.
This commit is contained in:
Marc-André Bombeck committed 2026-10-20 09:45:19 +02:00
1 parent c782fa060a
commit 6eb7e508df
1 file changed
+6 -2
+6 -2
View File
@@ -1266,7 +1266,7 @@ describe("POST /api/measurements/batch (real Postgres)", () => {
});
});
it("re-imports an XML estimate onto one row with monotonic syncVersion", async () => {
it("re-imports an XML estimate onto one row without moving its syncVersion", async () => {
const prisma = getPrismaClient();
const xmlPath = writeCumulativeXml();
await streamParseExportXml({
@@ -1288,11 +1288,15 @@ describe("POST /api/measurements/batch (real Postgres)", () => {
externalId: "stats:HKQuantityTypeIdentifierStepCount:2026-07-20",
},
});
// The second import writes the same value, provenance and every other
// column, so the update changes nothing and migration 0412 keeps the
// row's stamps: the phone is not sent a row that did not change. The
// version never goes backwards; it stays where the first import left it.
expect(rows).toHaveLength(1);
expect(rows[0]).toMatchObject({
value: 8_526,
aggregationProvenance: "EXPORT_XML_SOURCE_MAX",
syncVersion: 2,
syncVersion: 1,
});
});