restbase icon indicating copy to clipboard operation
restbase copied to clipboard

Replace preq with api-testing REST client

Open kevinbazira opened this issue 5 years ago • 4 comments
trafficstars

Bug: T265846

I have been able to replace preq with the api-testing REST client within 11 out of 13 tests.

The two tests that are failing when I switch them to client.post are;

  1. The html2wt with scrub_wikitext test fails with error 400 whenever the scrub_wikitext: 1 parameter is added.

  2. The supports stashing content test fails at the second client.post.

Could there be something I am missing that is causing these two tests to fail?

kevinbazira avatar Nov 03 '20 05:11 kevinbazira

Could there be something I am missing that is causing these two tests to fail?

Can you add the changes you made for these tests into the PR too? It's hard to debug not knowing what you've done.

Pchelolo avatar Nov 03 '20 14:11 Pchelolo

The html2wt with scrub_wikitext test fails with error 400 whenever the scrub_wikitext: 1 parameter is added.

I've tried to change this one locally and it works for me.

The supports stashing content test fails at the second client.post.

So, this one requires you to set a if-match header and I haven't found a way to do it in api-testing. @clarakosi writes in the api-testing library under request jsdoc:

The request has not been sent when this method returns, and can still be modified like a superagent request.

So I've attempted to just use .set there, but to no success - since the 'api-testing.request' method is async, it returns a promise, and that JSDoc is incorrect. Thus, the api-testing library needs fixing - we need a way to set arbitrary headers to requests, at least in REST. You can work with @clarakosi on that.

Pchelolo avatar Nov 03 '20 14:11 Pchelolo

Can you add the changes you made for these tests into the PR too? It's hard to debug not knowing what you've done.

The two tests that are failing have been added into the PR.

Hope we can find a way to make them work with the api-testing REST client.

kevinbazira avatar Nov 04 '20 11:11 kevinbazira

@clarakosi and @Pchelolo, all instances of preq have been replaced with the api-testing REST client in transform.js and all 13 tests are passing. Thanks to both of you!

kevinbazira avatar Nov 06 '20 06:11 kevinbazira