diff --git a/packages/core/src/server/service.test.ts b/packages/core/src/server/service.test.ts index b1d6a0131..a3f4bd55a 100644 --- a/packages/core/src/server/service.test.ts +++ b/packages/core/src/server/service.test.ts @@ -273,14 +273,7 @@ test("serves derived types correctly", async (context) => { expect(testEntitys).toHaveLength(1); expect(testEntitys[0]).toMatchObject({ id: "0", - derived: [ - { - id: "0", - }, - { - id: "1", - }, - ], + derived: [{ id: "0" }, { id: "1" }], }); await service.teardown(); @@ -351,9 +344,7 @@ test("filters on string field equals", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(1); - expect(testEntitys[0]).toMatchObject({ - id: "123", - }); + expect(testEntitys[0]).toMatchObject({ id: "123" }); await service.teardown(); await userStore.teardown(); @@ -378,12 +369,8 @@ test("filters on string field in", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "123", - }); - expect(testEntitys[1]).toMatchObject({ - id: "125", - }); + expect(testEntitys[0]).toMatchObject({ id: "123" }); + expect(testEntitys[1]).toMatchObject({ id: "125" }); await service.teardown(); await userStore.teardown(); @@ -408,9 +395,7 @@ test("filters on string field contains", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(1); - expect(testEntitys[0]).toMatchObject({ - id: "125", - }); + expect(testEntitys[0]).toMatchObject({ id: "125" }); await service.teardown(); await userStore.teardown(); @@ -435,12 +420,8 @@ test("filters on string field starts with", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "123", - }); - expect(testEntitys[1]).toMatchObject({ - id: "125", - }); + expect(testEntitys[0]).toMatchObject({ id: "123" }); + expect(testEntitys[1]).toMatchObject({ id: "125" }); await service.teardown(); await userStore.teardown(); @@ -465,12 +446,8 @@ test("filters on string field not ends with", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "123", - }); - expect(testEntitys[1]).toMatchObject({ - id: "130", - }); + expect(testEntitys[0]).toMatchObject({ id: "123" }); + expect(testEntitys[1]).toMatchObject({ id: "130" }); await service.teardown(); await userStore.teardown(); @@ -495,9 +472,7 @@ test("filters on integer field equals", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(1); - expect(testEntitys[0]).toMatchObject({ - id: "0", - }); + expect(testEntitys[0]).toMatchObject({ id: "0" }); await service.teardown(); await userStore.teardown(); @@ -522,9 +497,7 @@ test("filters on integer field greater than", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(1); - expect(testEntitys[0]).toMatchObject({ - id: "2", - }); + expect(testEntitys[0]).toMatchObject({ id: "2" }); await service.teardown(); await userStore.teardown(); @@ -549,12 +522,8 @@ test("filters on integer field less than or equal to", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "0", - }); - expect(testEntitys[1]).toMatchObject({ - id: "1", - }); + expect(testEntitys[0]).toMatchObject({ id: "0" }); + expect(testEntitys[1]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -579,12 +548,8 @@ test("filters on integer field in", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "0", - }); - expect(testEntitys[1]).toMatchObject({ - id: "2", - }); + expect(testEntitys[0]).toMatchObject({ id: "0" }); + expect(testEntitys[1]).toMatchObject({ id: "2" }); await service.teardown(); await userStore.teardown(); @@ -636,9 +601,7 @@ test("filters on float field greater than", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(1); - expect(testEntitys[0]).toMatchObject({ - id: "2", - }); + expect(testEntitys[0]).toMatchObject({ id: "2" }); await service.teardown(); await userStore.teardown(); @@ -664,12 +627,8 @@ test("filters on float field less than or equal to", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "0", - }); - expect(testEntitys[1]).toMatchObject({ - id: "1", - }); + expect(testEntitys[0]).toMatchObject({ id: "0" }); + expect(testEntitys[1]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -695,12 +654,8 @@ test("filters on float field in", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "0", - }); - expect(testEntitys[1]).toMatchObject({ - id: "2", - }); + expect(testEntitys[0]).toMatchObject({ id: "0" }); + expect(testEntitys[1]).toMatchObject({ id: "2" }); await service.teardown(); await userStore.teardown(); @@ -752,9 +707,7 @@ test.todo("filters on bigInt field greater than", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(1); - expect(testEntitys[0]).toMatchObject({ - id: "2", - }); + expect(testEntitys[0]).toMatchObject({ id: "2" }); await service.teardown(); await userStore.teardown(); @@ -780,12 +733,8 @@ test.todo("filters on bigInt field less than or equal to", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "0", - }); - expect(testEntitys[1]).toMatchObject({ - id: "1", - }); + expect(testEntitys[0]).toMatchObject({ id: "0" }); + expect(testEntitys[1]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -811,12 +760,8 @@ test.todo("filters on bigInt field in", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "0", - }); - expect(testEntitys[1]).toMatchObject({ - id: "2", - }); + expect(testEntitys[0]).toMatchObject({ id: "0" }); + expect(testEntitys[1]).toMatchObject({ id: "2" }); await service.teardown(); await userStore.teardown(); @@ -841,9 +786,7 @@ test("filters on string list field equals", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(1); - expect(testEntitys[0]).toMatchObject({ - id: "1", - }); + expect(testEntitys[0]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -868,9 +811,7 @@ test("filters on string list field contains", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(1); - expect(testEntitys[0]).toMatchObject({ - id: "2", - }); + expect(testEntitys[0]).toMatchObject({ id: "2" }); await service.teardown(); await userStore.teardown(); @@ -895,9 +836,7 @@ test("filters on enum field equals", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(1); - expect(testEntitys[0]).toMatchObject({ - id: "1", - }); + expect(testEntitys[0]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -922,12 +861,8 @@ test("filters on enum field in", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(2); - expect(testEntitys[0]).toMatchObject({ - id: "0", - }); - expect(testEntitys[1]).toMatchObject({ - id: "1", - }); + expect(testEntitys[0]).toMatchObject({ id: "0" }); + expect(testEntitys[1]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -988,12 +923,8 @@ test("filters on relationship field in", async (context) => { const { entityWithBigIntIds } = response.body.data; expect(entityWithBigIntIds).toHaveLength(2); - expect(entityWithBigIntIds[0]).toMatchObject({ - id: "0", - }); - expect(entityWithBigIntIds[1]).toMatchObject({ - id: "1", - }); + expect(entityWithBigIntIds[0]).toMatchObject({ id: "0" }); + expect(entityWithBigIntIds[1]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -1020,12 +951,8 @@ test("filters on relationship field in", async (context) => { const { entityWithBigIntIds } = response.body.data; expect(entityWithBigIntIds).toHaveLength(2); - expect(entityWithBigIntIds[0]).toMatchObject({ - id: "0", - }); - expect(entityWithBigIntIds[1]).toMatchObject({ - id: "1", - }); + expect(entityWithBigIntIds[0]).toMatchObject({ id: "0" }); + expect(entityWithBigIntIds[1]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -1050,15 +977,9 @@ test("orders by on int field ascending", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(3); - expect(testEntitys[0]).toMatchObject({ - id: "1", - }); - expect(testEntitys[1]).toMatchObject({ - id: "12", - }); - expect(testEntitys[2]).toMatchObject({ - id: "123", - }); + expect(testEntitys[0]).toMatchObject({ id: "1" }); + expect(testEntitys[1]).toMatchObject({ id: "12" }); + expect(testEntitys[2]).toMatchObject({ id: "123" }); await service.teardown(); await userStore.teardown(); @@ -1083,15 +1004,9 @@ test("orders by on int field descending", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(3); - expect(testEntitys[0]).toMatchObject({ - id: "123", - }); - expect(testEntitys[1]).toMatchObject({ - id: "12", - }); - expect(testEntitys[2]).toMatchObject({ - id: "1", - }); + expect(testEntitys[0]).toMatchObject({ id: "123" }); + expect(testEntitys[1]).toMatchObject({ id: "12" }); + expect(testEntitys[2]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -1116,15 +1031,9 @@ test("orders by on bigInt field ascending", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(3); - expect(testEntitys[0]).toMatchObject({ - id: "1", - }); - expect(testEntitys[1]).toMatchObject({ - id: "12", - }); - expect(testEntitys[2]).toMatchObject({ - id: "123", - }); + expect(testEntitys[0]).toMatchObject({ id: "1" }); + expect(testEntitys[1]).toMatchObject({ id: "12" }); + expect(testEntitys[2]).toMatchObject({ id: "123" }); await service.teardown(); await userStore.teardown(); @@ -1149,15 +1058,9 @@ test("orders by on bigInt field descending", async (context) => { const { testEntitys } = response.body.data; expect(testEntitys).toHaveLength(3); - expect(testEntitys[0]).toMatchObject({ - id: "123", - }); - expect(testEntitys[1]).toMatchObject({ - id: "12", - }); - expect(testEntitys[2]).toMatchObject({ - id: "1", - }); + expect(testEntitys[0]).toMatchObject({ id: "123" }); + expect(testEntitys[1]).toMatchObject({ id: "12" }); + expect(testEntitys[2]).toMatchObject({ id: "1" }); await service.teardown(); await userStore.teardown(); @@ -1395,3 +1298,58 @@ test("serves plural entities versioned at specified timestamp", async (context) await service.teardown(); await userStore.teardown(); }); + +test.only("serves derived entities versioned at provided timestamp", async (context) => { + const { userStore } = context; + const { service, gql, createTestEntity, createEntityWithBigIntId } = + await setup({ userStore }); + + await createTestEntity({ id: 0 }); + await createEntityWithBigIntId({ id: BigInt(0), testEntityId: "0" }); + + await userStore.update({ + modelName: "EntityWithBigIntId", + timestamp: 10, + id: BigInt(0), + data: { + testEntity: "2", + }, + }); + + const responseOld = await gql(` + testEntitys(timestamp: 5) { + id + derived { + id + } + } + `); + expect(responseOld.body.errors).toBe(undefined); + expect(responseOld.statusCode).toBe(200); + const testEntitysOld = responseOld.body.data.testEntitys; + expect(testEntitysOld).toHaveLength(1); + expect(testEntitysOld[0]).toMatchObject({ + id: "0", + derived: [{ id: "0" }], + }); + + const response = await gql(` + testEntitys { + id + derived { + id + } + } + `); + expect(response.body.errors).toBe(undefined); + expect(response.statusCode).toBe(200); + const { testEntitys } = response.body.data; + expect(testEntitys).toHaveLength(1); + expect(testEntitys[0]).toMatchObject({ + id: "0", + derived: [], + }); + + await service.teardown(); + await userStore.teardown(); +});