@@ -136,7 +136,7 @@ describe('handleUpdateInformation', () => {
136136
137137 await handleUpdateInformation ( ) ;
138138
139- expect ( fetch ) . toHaveBeenCalledWith ( '.. /api/setup/check' , {
139+ expect ( fetch ) . toHaveBeenCalledWith ( '/api/setup/check' , {
140140 method : 'POST' ,
141141 headers : {
142142 Accept : 'application/json, text/plain, */*' ,
@@ -218,14 +218,15 @@ describe('handleUpdateInformation', () => {
218218
219219 global . fetch = vi . fn ( ) . mockResolvedValue ( {
220220 ok : false ,
221+ status : 404 ,
221222 headers : { get : ( ) => 'text/html' } ,
222223 text : ( ) => Promise . resolve ( 'Not Found' ) ,
223224 } ) ;
224225
225226 await handleUpdateInformation ( ) ;
226227
227228 const result = document . getElementById ( 'phpmyfaq-update-check-result' ) ;
228- expect ( result ?. innerText ) . toContain ( 'The requested resource was not found ' ) ;
229+ expect ( result ?. innerText ) . toContain ( 'The server returned an error (HTTP 404) ' ) ;
229230 expect ( result ?. innerText ) . toContain ( 'RewriteBase' ) ;
230231 } ) ;
231232
@@ -280,7 +281,7 @@ describe('handleConfigBackup', () => {
280281
281282 it ( 'should do nothing when URL does not match step 2' , async ( ) => {
282283 Object . defineProperty ( window , 'location' , {
283- value : { href : 'http://localhost/update?step=1' } ,
284+ value : { href : 'http://localhost/update?step=1' , pathname : '/update' } ,
284285 writable : true ,
285286 } ) ;
286287
@@ -293,7 +294,7 @@ describe('handleConfigBackup', () => {
293294
294295 it ( 'should do nothing when installed version input is missing' , async ( ) => {
295296 Object . defineProperty ( window , 'location' , {
296- value : { href : 'http://localhost/update?step=2' } ,
297+ value : { href : 'http://localhost/update?step=2' , pathname : '/update' } ,
297298 writable : true ,
298299 } ) ;
299300
@@ -307,7 +308,7 @@ describe('handleConfigBackup', () => {
307308
308309 it ( 'should call backup API on step 2' , async ( ) => {
309310 Object . defineProperty ( window , 'location' , {
310- value : { href : 'http://localhost/update?step=2' } ,
311+ value : { href : 'http://localhost/update?step=2' , pathname : '/update' } ,
311312 writable : true ,
312313 } ) ;
313314
@@ -320,7 +321,7 @@ describe('handleConfigBackup', () => {
320321
321322 await handleConfigBackup ( ) ;
322323
323- expect ( fetch ) . toHaveBeenCalledWith ( '.. /api/setup/backup' , {
324+ expect ( fetch ) . toHaveBeenCalledWith ( '/api/setup/backup' , {
324325 method : 'POST' ,
325326 headers : {
326327 Accept : 'application/json, text/plain, */*' ,
@@ -332,7 +333,7 @@ describe('handleConfigBackup', () => {
332333
333334 it ( 'should log error on failed backup response' , async ( ) => {
334335 Object . defineProperty ( window , 'location' , {
335- value : { href : 'http://localhost/update?step=2' } ,
336+ value : { href : 'http://localhost/update?step=2' , pathname : '/update' } ,
336337 writable : true ,
337338 } ) ;
338339
@@ -351,7 +352,7 @@ describe('handleConfigBackup', () => {
351352
352353 it ( 'should log error on network failure' , async ( ) => {
353354 Object . defineProperty ( window , 'location' , {
354- value : { href : 'http://localhost/update?step=2' } ,
355+ value : { href : 'http://localhost/update?step=2' , pathname : '/update' } ,
355356 writable : true ,
356357 } ) ;
357358
@@ -375,7 +376,7 @@ describe('handleDatabaseUpdate', () => {
375376
376377 it ( 'should do nothing when URL does not match step 3' , async ( ) => {
377378 Object . defineProperty ( window , 'location' , {
378- value : { href : 'http://localhost/update?step=1' } ,
379+ value : { href : 'http://localhost/update?step=1' , pathname : '/update' } ,
379380 writable : true ,
380381 } ) ;
381382
@@ -388,7 +389,7 @@ describe('handleDatabaseUpdate', () => {
388389
389390 it ( 'should do nothing when installed version input is missing' , async ( ) => {
390391 Object . defineProperty ( window , 'location' , {
391- value : { href : 'http://localhost/update?step=3' } ,
392+ value : { href : 'http://localhost/update?step=3' , pathname : '/update' } ,
392393 writable : true ,
393394 } ) ;
394395
@@ -402,7 +403,7 @@ describe('handleDatabaseUpdate', () => {
402403
403404 it ( 'should show success on successful database update' , async ( ) => {
404405 Object . defineProperty ( window , 'location' , {
405- value : { href : 'http://localhost/update?step=3' } ,
406+ value : { href : 'http://localhost/update?step=3' , pathname : '/update' } ,
406407 writable : true ,
407408 } ) ;
408409
@@ -419,7 +420,7 @@ describe('handleDatabaseUpdate', () => {
419420
420421 await handleDatabaseUpdate ( ) ;
421422
422- expect ( fetch ) . toHaveBeenCalledWith ( '.. /api/setup/update-database' , {
423+ expect ( fetch ) . toHaveBeenCalledWith ( '/api/setup/update-database' , {
423424 method : 'POST' ,
424425 headers : {
425426 Accept : 'application/json, text/plain, */*' ,
@@ -440,7 +441,7 @@ describe('handleDatabaseUpdate', () => {
440441
441442 it ( 'should show error on failed database update response' , async ( ) => {
442443 Object . defineProperty ( window , 'location' , {
443- value : { href : 'http://localhost/update?step=3' } ,
444+ value : { href : 'http://localhost/update?step=3' , pathname : '/update' } ,
444445 writable : true ,
445446 } ) ;
446447
@@ -471,7 +472,7 @@ describe('handleDatabaseUpdate', () => {
471472
472473 it ( 'should show error alert on network failure' , async ( ) => {
473474 Object . defineProperty ( window , 'location' , {
474- value : { href : 'http://localhost/update?step=3' } ,
475+ value : { href : 'http://localhost/update?step=3' , pathname : '/update' } ,
475476 writable : true ,
476477 } ) ;
477478
@@ -494,7 +495,7 @@ describe('handleDatabaseUpdate', () => {
494495
495496 it ( 'should work with URL ending in /update/?step=3' , async ( ) => {
496497 Object . defineProperty ( window , 'location' , {
497- value : { href : 'http://localhost/update/?step=3' } ,
498+ value : { href : 'http://localhost/update/?step=3' , pathname : '/update/' } ,
498499 writable : true ,
499500 } ) ;
500501
0 commit comments