From a3cd6cf8e73295bd92f478c6bad3b01907e77e43 Mon Sep 17 00:00:00 2001 From: ronitjadhav Date: Thu, 23 May 2024 12:59:56 +0200 Subject: [PATCH] Updated e2e test --- apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts | 4 ++-- .../record-api-form.component.spec.ts | 10 +++++----- .../record-api-form/record-api-form.component.ts | 16 ++++++++++------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts index 155e67a0c0..1b1d7da16f 100644 --- a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts +++ b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts @@ -684,7 +684,7 @@ describe('api form', () => { .find('gn-ui-copy-text-button') .find('input') .invoke('val') - .should('include', 'offset=87&limit=54&f=geojson') + .should('include', 'f=geojson&limit=54&offset=87') cy.get('@apiForm').children('div').first().find('button').first().click() @@ -699,7 +699,7 @@ describe('api form', () => { .find('gn-ui-copy-text-button') .find('input') .invoke('val') - .should('include', 'limit=-1&f=json') + .should('include', 'f=json&limit=-1') }) it('should close the panel on click', () => { cy.get('gn-ui-record-api-form').prev().find('button').click() diff --git a/libs/ui/elements/src/lib/record-api-form/record-api-form.component.spec.ts b/libs/ui/elements/src/lib/record-api-form/record-api-form.component.spec.ts index 32b83da28a..918df0cc5c 100644 --- a/libs/ui/elements/src/lib/record-api-form/record-api-form.component.spec.ts +++ b/libs/ui/elements/src/lib/record-api-form/record-api-form.component.spec.ts @@ -93,7 +93,7 @@ describe('RecordApFormComponent', () => { expect(component.format$.getValue()).toBe('json') const url = await firstValueFrom(component.apiQueryUrl$) expect(url).toBe( - 'https://api.example.com/data/collections/mockFeatureType/items?f=json' + 'https://api.example.com/data/collections/feature1/items?limit=-1&f=json' ) }) }) @@ -107,7 +107,7 @@ describe('RecordApFormComponent', () => { component.setFormat(mockFormat) const url = await firstValueFrom(component.apiQueryUrl$) expect(url).toBe( - `https://api.example.com/data/collections/mockFeatureType/items?limit=${mockLimit}&offset=${mockOffset}&f=${mockFormat}` + `https://api.example.com/data/collections/feature1/items?limit=${mockLimit}&offset=${mockOffset}&f=${mockFormat}` ) }) it('should remove the param in url if value is null', async () => { @@ -119,7 +119,7 @@ describe('RecordApFormComponent', () => { component.setFormat(mockFormat) const url = await firstValueFrom(component.apiQueryUrl$) expect(url).toBe( - `https://api.example.com/data/collections/mockFeatureType/items?limit=${mockLimit}&offset=${mockOffset}&f=${mockFormat}` + `https://api.example.com/data/collections/feature1/items?limit=${mockLimit}&offset=${mockOffset}&f=${mockFormat}` ) }) it('should remove the param in url if value is zero', async () => { @@ -131,7 +131,7 @@ describe('RecordApFormComponent', () => { component.setFormat(mockFormat) const url = await firstValueFrom(component.apiQueryUrl$) expect(url).toBe( - `https://api.example.com/data/collections/mockFeatureType/items?limit=${mockLimit}&offset=${mockOffset}&f=${mockFormat}` + `https://api.example.com/data/collections/feature1/items?limit=${mockLimit}&offset=${mockOffset}&f=${mockFormat}` ) }) }) @@ -177,7 +177,7 @@ describe('RecordApFormComponent', () => { expect(component.format$.getValue()).toBe('json') const url = await firstValueFrom(component.apiQueryUrl$) expect(url).toBe( - `https://api.example.com/data?type=mockFeatureType&options={"outputFormat":"json"}` + `https://api.example.com/data?type=mockFeatureType&options={"outputFormat":"json","limit":-1}` ) }) }) diff --git a/libs/ui/elements/src/lib/record-api-form/record-api-form.component.ts b/libs/ui/elements/src/lib/record-api-form/record-api-form.component.ts index 51e4d346cd..8a13579cdf 100644 --- a/libs/ui/elements/src/lib/record-api-form/record-api-form.component.ts +++ b/libs/ui/elements/src/lib/record-api-form/record-api-form.component.ts @@ -48,6 +48,7 @@ export class RecordApiFormComponent { accessServiceProtocol: ServiceProtocol | undefined outputFormats = [{ value: 'json', label: 'JSON' }] endpoint: WfsEndpoint | OgcApiEndpoint | undefined + firstCollection: string | undefined apiQueryUrl$ = combineLatest([ this.offset$, @@ -55,7 +56,7 @@ export class RecordApiFormComponent { this.format$, this.endpoint$, ]).pipe( - switchMap(([offset, limit, format, endpoint]) => + switchMap(([offset, limit, format]) => this.generateApiQueryUrl(offset, limit, format) ) ) @@ -121,9 +122,8 @@ export class RecordApiFormComponent { return this.endpoint.getServiceInfo() as OutputFormats } else { { - const firstCollection = (await this.endpoint.featureCollections)[0] return (await this.endpoint.getCollectionInfo( - firstCollection + this.firstCollection )) as OutputFormats } } @@ -136,6 +136,7 @@ export class RecordApiFormComponent { await (this.endpoint as WfsEndpoint).isReady() } else { this.endpoint = new OgcApiEndpoint(this.apiBaseUrl) + this.firstCollection = (await this.endpoint.featureCollections)[0] } this.endpoint$.next(this.endpoint) } @@ -151,15 +152,18 @@ export class RecordApiFormComponent { outputFormat: format, startIndex: offset ? Number(offset) : undefined, maxFeatures: limit !== '-1' ? Number(limit) : undefined, - limit: limit !== '-1' ? Number(limit) : undefined, + limit: limit !== '-1' ? Number(limit) : limit === '-1' ? -1 : undefined, offset: offset !== '' ? Number(offset) : undefined, } if (this.endpoint instanceof WfsEndpoint) { + options.maxFeatures = limit !== '-1' ? Number(limit) : undefined return this.endpoint.getFeatureUrl(this.apiFeatureType, options) } else { - const firstCollection = (await this.endpoint.featureCollections)[0] - return await this.endpoint.getCollectionItemsUrl(firstCollection, options) + return await this.endpoint.getCollectionItemsUrl( + this.firstCollection, + options + ) } } }