@@ -72,27 +72,6 @@ describe('DspaceRestResponseParsingService', () => {
7272 expect ( response . payload . _links . self . href ) . toBe ( 'https://rest.api/core/items/eba1c085/bundles' ) ;
7373 } ) ;
7474
75- it ( 'should not warn when the REST API reduced the requested page size' , ( ) => {
76- // https://github.com/dataquest-dev/dspace-customers/issues/862
77- const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?embed=primaryBitstream&size=9999' ) ;
78- const response = service . callEnsureSelfLink ( request , responseWithSelfLink (
79- 'https://rest.api/core/items/eba1c085/bundles?embed=primaryBitstream&size=1000' ,
80- { number : 0 , size : 1000 , totalPages : 1 , totalElements : 2 } ) ) ;
81-
82- expect ( console . warn ) . not . toHaveBeenCalled ( ) ;
83- expect ( response . payload . _links . self . href ) . toBe ( 'https://rest.api/core/items/eba1c085/bundles?size=9999' ) ;
84- } ) ;
85-
86- it ( 'should not warn when the REST API reduced the page size and no embeds are involved' , ( ) => {
87- const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?size=9999' ) ;
88- const response = service . callEnsureSelfLink ( request , responseWithSelfLink (
89- 'https://rest.api/core/items/eba1c085/bundles?size=1000' ,
90- { number : 0 , size : 1000 , totalPages : 1 , totalElements : 2 } ) ) ;
91-
92- expect ( console . warn ) . not . toHaveBeenCalled ( ) ;
93- expect ( response . payload . _links . self . href ) . toBe ( 'https://rest.api/core/items/eba1c085/bundles?size=9999' ) ;
94- } ) ;
95-
9675 it ( 'should not warn when the self link only percent decoded a param value' , ( ) => {
9776 // https://github.com/dataquest-dev/dspace-customers/issues/862
9877 const request = requestFor ( 'https://rest.api/statistics/usagereports/search/object?page=-1&size=10&uri=https%3A%2F%2Frest.api%2Fcore%2Fsites%2F8f842a80' ) ;
@@ -118,20 +97,13 @@ describe('DspaceRestResponseParsingService', () => {
11897
11998 describe ( 'differences that point at a problem with the endpoint' , ( ) => {
12099
121- it ( 'should warn when the page size shrank but the page block contradicts the self link' , ( ) => {
122- const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?size=100' ) ;
100+ it ( 'should warn when the REST API reduced the requested page size' , ( ) => {
101+ // callers are expected to stay within MAX_PAGE_SIZE, so a reduced size means a caller asked
102+ // for a page the API was never going to serve
103+ const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?size=9999' ) ;
123104 service . callEnsureSelfLink ( request , responseWithSelfLink (
124- 'https://rest.api/core/items/eba1c085/bundles?size=20' ,
125- { number : 0 , size : 100 , totalPages : 1 , totalElements : 2 } ) ) ;
126-
127- expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
128- expect ( console . warn ) . toHaveBeenCalledWith ( MISMATCH ) ;
129- } ) ;
130-
131- it ( 'should warn when the page size shrank but the response has no page block to confirm it' , ( ) => {
132- const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?size=100' ) ;
133- service . callEnsureSelfLink ( request ,
134- responseWithSelfLink ( 'https://rest.api/core/items/eba1c085/bundles?size=20' ) ) ;
105+ 'https://rest.api/core/items/eba1c085/bundles?size=1000' ,
106+ { number : 0 , size : 1000 , totalPages : 1 , totalElements : 2 } ) ) ;
135107
136108 expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
137109 expect ( console . warn ) . toHaveBeenCalledWith ( MISMATCH ) ;
@@ -147,16 +119,6 @@ describe('DspaceRestResponseParsingService', () => {
147119 expect ( console . warn ) . toHaveBeenCalledWith ( MISMATCH ) ;
148120 } ) ;
149121
150- it ( 'should warn when the url is ambiguous about the page size' , ( ) => {
151- const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?size=5&size=10' ) ;
152- service . callEnsureSelfLink ( request , responseWithSelfLink (
153- 'https://rest.api/core/items/eba1c085/bundles?size=3' ,
154- { number : 0 , size : 3 , totalPages : 1 , totalElements : 2 } ) ) ;
155-
156- expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
157- expect ( console . warn ) . toHaveBeenCalledWith ( MISMATCH ) ;
158- } ) ;
159-
160122 it ( 'should still warn when a param value differs beyond its encoding' , ( ) => {
161123 const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?uri=https%3A%2F%2Frest.api%2Fcore%2Fsites%2Faaa' ) ;
162124 service . callEnsureSelfLink ( request ,
@@ -166,46 +128,6 @@ describe('DspaceRestResponseParsingService', () => {
166128 expect ( console . warn ) . toHaveBeenCalledWith ( MISMATCH ) ;
167129 } ) ;
168130
169- it ( 'should warn when a reduced page size hides another param that differs' , ( ) => {
170- const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?page=0&size=9999' ) ;
171- service . callEnsureSelfLink ( request , responseWithSelfLink (
172- 'https://rest.api/core/items/eba1c085/bundles?page=3&size=1000' ,
173- { number : 3 , size : 1000 , totalPages : 4 , totalElements : 3200 } ) ) ;
174-
175- expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
176- expect ( console . warn ) . toHaveBeenCalledWith ( MISMATCH ) ;
177- } ) ;
178-
179- it ( 'should warn when the self link claims an empty page' , ( ) => {
180- const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?size=10' ) ;
181- service . callEnsureSelfLink ( request , responseWithSelfLink (
182- 'https://rest.api/core/items/eba1c085/bundles?size=0' ,
183- { number : 0 , size : 0 , totalPages : 0 , totalElements : 0 } ) ) ;
184-
185- expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
186- expect ( console . warn ) . toHaveBeenCalledWith ( MISMATCH ) ;
187- } ) ;
188-
189- it ( 'should not treat a param that merely ends in `size` as the page size' , ( ) => {
190- const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?pagesize=9999' ) ;
191- service . callEnsureSelfLink ( request , responseWithSelfLink (
192- 'https://rest.api/core/items/eba1c085/bundles?pagesize=1000' ,
193- { number : 0 , size : 1000 , totalPages : 1 , totalElements : 2 } ) ) ;
194-
195- expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
196- expect ( console . warn ) . toHaveBeenCalledWith ( MISMATCH ) ;
197- } ) ;
198-
199- it ( 'should not accept a page block that confirms the reduced size only as a string' , ( ) => {
200- const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?size=9999' ) ;
201- service . callEnsureSelfLink ( request , responseWithSelfLink (
202- 'https://rest.api/core/items/eba1c085/bundles?size=1000' ,
203- { number : 0 , size : '1000' , totalPages : 1 , totalElements : 2 } ) ) ;
204-
205- expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
206- expect ( console . warn ) . toHaveBeenCalledWith ( MISMATCH ) ;
207- } ) ;
208-
209131 it ( 'should report the normalized request url and the raw self link in the warning' , ( ) => {
210132 const request = requestFor ( 'https://rest.api/core/items/eba1c085/bundles?page=0&embed=primaryBitstream&size=5' ) ;
211133 service . callEnsureSelfLink ( request ,
0 commit comments