From 0ef9b9c842d44a2018e6a3c0040d62b2d20d631d Mon Sep 17 00:00:00 2001 From: alexeh Date: Mon, 5 Feb 2024 15:43:38 +0300 Subject: [PATCH] Update test expect assertions according to new queries --- api/src/modules/h3-data/h3-data.repository.ts | 4 - api/test/e2e/h3-data/h3-impact-map.spec.ts | 83 +++++++++---------- api/test/e2e/h3-data/h3-material-map.spec.ts | 9 +- 3 files changed, 42 insertions(+), 54 deletions(-) diff --git a/api/src/modules/h3-data/h3-data.repository.ts b/api/src/modules/h3-data/h3-data.repository.ts index 769bba839..d30e71878 100644 --- a/api/src/modules/h3-data/h3-data.repository.ts +++ b/api/src/modules/h3-data/h3-data.repository.ts @@ -307,10 +307,6 @@ export class H3DataRepository extends Repository { } /** Retrieves single crop data by a given resolution - * - * @param materialH3Data: H3 Data table and column name for a specific material - * @param resolution: An integer between 1 (min resolution) and 6 (max resolution). - * Resolution validation done at route handler * */ async getMaterialMapByResolution( diff --git a/api/test/e2e/h3-data/h3-impact-map.spec.ts b/api/test/e2e/h3-data/h3-impact-map.spec.ts index dd693fcdc..5e82a3cc1 100644 --- a/api/test/e2e/h3-data/h3-impact-map.spec.ts +++ b/api/test/e2e/h3-data/h3-impact-map.spec.ts @@ -110,19 +110,19 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect(response.body.data).toEqual( expect.arrayContaining([ - { h: '861203a6fffffff', v: '500.0000' }, + { h: '861203a6fffffff', v: '500' }, { h: '861203a5fffffff', - v: '617.0000', + v: '617', }, - { h: '861203a4fffffff', v: '1117.0000' }, + { h: '861203a4fffffff', v: '1117' }, ]), ); expect(response.body.metadata.unit).toEqual('tonnes'); expect( toBeCloseToArray( response.body.metadata.quantiles, - [0, 539.0078, 578.0858, 617, 783.699999, 950.7, 1117], + [0, 2.2, 9.3, 30, 100, 300, 1000], 5, ), ).toBeTruthy(); @@ -140,10 +140,10 @@ describe('H3 Data Module (e2e) - Impact map', () => { }); expect(response.body.data).toEqual( - expect.arrayContaining([{ h: '821207fffffffff', v: '2234.0000' }]), + expect.arrayContaining([{ h: '821207fffffffff', v: '2234' }]), ); expect(response.body.metadata).toEqual({ - quantiles: [0, 2234, 2234, 2234, 2234, 2234, 2234], + quantiles: [0, 2.6, 10, 50, 200, 600, 2000], unit: 'tonnes', }); }); @@ -159,10 +159,10 @@ describe('H3 Data Module (e2e) - Impact map', () => { }); expect(response.body.data).toEqual( - expect.arrayContaining([{ h: '841203bffffffff', v: '2234.0000' }]), + expect.arrayContaining([{ h: '841203bffffffff', v: '2234' }]), ); expect(response.body.metadata).toEqual({ - quantiles: [0, 2234, 2234, 2234, 2234, 2234, 2234], + quantiles: [0, 2.6, 10, 50, 200, 600, 2000], unit: 'tonnes', }); }); @@ -179,19 +179,19 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect(response.body.data).toEqual( expect.arrayContaining([ - { h: '861203a6fffffff', v: '500.0000' }, + { h: '861203a6fffffff', v: '500' }, { h: '861203a5fffffff', - v: '617.0000', + v: '617', }, - { h: '861203a4fffffff', v: '1117.0000' }, + { h: '861203a4fffffff', v: '1117' }, ]), ); expect(response.body.metadata.unit).toEqual('tonnes'); expect( toBeCloseToArray( response.body.metadata.quantiles, - [0, 539.0078, 578.0858, 617, 783.699999, 950.7, 1117], + [0, 2.2, 9.3, 30, 100, 300, 1000], 5, ), ).toBeTruthy(); @@ -212,12 +212,12 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect(response.body.data).toEqual( expect.arrayContaining([ - { h: '861203a5fffffff', v: '617.0000' }, - { h: '861203a4fffffff', v: '617.0000' }, + { h: '861203a5fffffff', v: '617' }, + { h: '861203a4fffffff', v: '617' }, ]), ); expect(response.body.metadata).toEqual({ - quantiles: [0, 617, 617, 617, 617, 617, 617], + quantiles: [0, 1.9, 7.5, 20, 70, 200, 600], unit: 'tonnes', materialsH3DataYears: [ { @@ -247,12 +247,12 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect(response.body.data).toEqual( expect.arrayContaining([ - { h: '861203a5fffffff', v: '617.0000' }, - { h: '861203a4fffffff', v: '617.0000' }, + { h: '861203a5fffffff', v: '617' }, + { h: '861203a4fffffff', v: '617' }, ]), ); expect(response.body.metadata).toEqual({ - quantiles: [0, 617, 617, 617, 617, 617, 617], + quantiles: [0, 1.9, 7.5, 20, 70, 200, 600], unit: 'tonnes', }); }); @@ -270,12 +270,12 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect(response.body.data).toEqual( expect.arrayContaining([ - { h: '861203a5fffffff', v: '617.0000' }, - { h: '861203a4fffffff', v: '617.0000' }, + { h: '861203a5fffffff', v: '617' }, + { h: '861203a4fffffff', v: '617' }, ]), ); expect(response.body.metadata).toEqual({ - quantiles: [0, 617, 617, 617, 617, 617, 617], + quantiles: [0, 1.9, 7.5, 20, 70, 200, 600], unit: 'tonnes', }); }); @@ -293,18 +293,12 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect(response.body.data).toEqual( expect.arrayContaining([ - { - h: '861203a5fffffff', - v: '617.0000', - }, - { - h: '861203a4fffffff', - v: '617.0000', - }, + { h: '861203a5fffffff', v: '617' }, + { h: '861203a4fffffff', v: '617' }, ]), ); expect(response.body.metadata).toEqual({ - quantiles: [0, 617, 617, 617, 617, 617, 617], + quantiles: [0, 1.9, 7.5, 20, 70, 200, 600], unit: 'tonnes', }); }); @@ -323,9 +317,12 @@ describe('H3 Data Module (e2e) - Impact map', () => { }); expect(response.body.data).toEqual( expect.arrayContaining([ - { h: '861203a6fffffff', v: '500.0000' }, - { h: '861203a5fffffff', v: '617.0000' }, - { h: '861203a4fffffff', v: '1117.0000' }, + { h: '861203a6fffffff', v: '500' }, + { + h: '861203a5fffffff', + v: '617', + }, + { h: '861203a4fffffff', v: '1117' }, ]), ); }); @@ -342,12 +339,12 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect(response.body.data).toEqual( expect.arrayContaining([ - { h: '861203a5fffffff', v: '617.0000' }, - { h: '861203a4fffffff', v: '617.0000' }, + { h: '861203a5fffffff', v: '617' }, + { h: '861203a4fffffff', v: '617' }, ]), ); expect(response.body.metadata).toEqual({ - quantiles: [0, 617, 617, 617, 617, 617, 617], + quantiles: [0, 1.9, 7.5, 20, 70, 200, 600], unit: 'tonnes', }); }); @@ -365,12 +362,12 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect(response.body.data).toEqual( expect.arrayContaining([ - { h: '861203a5fffffff', v: '617.0000' }, - { h: '861203a4fffffff', v: '617.0000' }, + { h: '861203a5fffffff', v: '617' }, + { h: '861203a4fffffff', v: '617' }, ]), ); expect(response.body.metadata).toEqual({ - quantiles: [0, 617, 617, 617, 617, 617, 617], + quantiles: [0, 1.9, 7.5, 20, 70, 200, 600], unit: 'tonnes', }); }); @@ -392,12 +389,12 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect(response.body.data).toEqual( expect.arrayContaining([ - { h: '861203a6fffffff', v: '450.0000' }, + { h: '861203a6fffffff', v: '450' }, { h: '861203a5fffffff', - v: '592.0000', + v: '592', }, - { h: '861203a4fffffff', v: '1042.0000' }, + { h: '861203a4fffffff', v: '1042' }, ]), ); expect(response.body.metadata).toBeDefined(); @@ -405,7 +402,7 @@ describe('H3 Data Module (e2e) - Impact map', () => { expect( toBeCloseToArray( response.body.metadata.quantiles, - [0, 497.3428, 544.7708, 592, 742.03, 892.329999, 1042], + [0, 2.2, 9.1, 30, 100, 300, 1000], 5, ), ).toBeTruthy(); diff --git a/api/test/e2e/h3-data/h3-material-map.spec.ts b/api/test/e2e/h3-data/h3-material-map.spec.ts index c8d3b34af..93486dba9 100644 --- a/api/test/e2e/h3-data/h3-material-map.spec.ts +++ b/api/test/e2e/h3-data/h3-material-map.spec.ts @@ -177,10 +177,7 @@ describe('H3 Data Module (e2e) - Material map', () => { ); expect(responseRes1.body.metadata).toEqual({ - quantiles: [ - 0, 615.037, 800.0275, 812.5, 825.0784999999998, 1218.3635000000002, - 1610, - ], + quantiles: [0, 2.4, 10, 40, 100, 500, 2000], unit: 'tonnes', }); @@ -197,9 +194,7 @@ describe('H3 Data Module (e2e) - Material map', () => { ); expect(responseRes3.body.metadata).toEqual({ - quantiles: [ - 0, 200.006, 231.1110000000001, 735, 750.01, 800.1320000000001, 860, - ], + quantiles: [0, 2.1, 8.5, 30, 90, 300, 900], unit: 'tonnes', }); });