Skip to content

Commit b9eb2c1

Browse files
committed
fix(requests): use waitForFetch instead of waitForPromise
`waitForFetch` does the same as `waitForPromise` but makes sure that methods on the response (`.json()` etc.) are awaited as well. https://github.com/emberjs/ember-test-waiters#waitforfetch-function
1 parent 37cad36 commit b9eb2c1

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

addon/authenticators/oidc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { later } from "@ember/runloop";
22
import { service } from "@ember/service";
3-
import { waitForPromise } from "@ember/test-waiters";
3+
import { waitForFetch } from "@ember/test-waiters";
44
import BaseAuthenticator from "ember-simple-auth/authenticators/base";
55
import { resolve } from "rsvp";
66
import { TrackedObject } from "tracked-built-ins";
@@ -47,7 +47,7 @@ export default class OidcAuthenticator extends BaseAuthenticator {
4747

4848
const body = this._buildBodyQuery(options);
4949

50-
const response = await waitForPromise(
50+
const response = await waitForFetch(
5151
fetch(getAbsoluteUrl(this.config.tokenEndpoint, this.config.host), {
5252
method: "POST",
5353
headers: {
@@ -167,7 +167,7 @@ export default class OidcAuthenticator extends BaseAuthenticator {
167167
customParams,
168168
});
169169

170-
const response = await waitForPromise(
170+
const response = await waitForFetch(
171171
fetch(getAbsoluteUrl(this.config.tokenEndpoint, this.config.host), {
172172
method: "POST",
173173
headers: {
@@ -217,7 +217,7 @@ export default class OidcAuthenticator extends BaseAuthenticator {
217217
* @returns {Object} Object containing the user information
218218
*/
219219
async _getUserinfo(accessToken) {
220-
const response = await waitForPromise(
220+
const response = await waitForFetch(
221221
fetch(getAbsoluteUrl(this.config.userinfoEndpoint, this.config.host), {
222222
headers: {
223223
Authorization: `${this.config.authPrefix} ${accessToken}`,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
},
106106
"peerDependencies": {
107107
"@ember-data/adapter": "~4.12.0 || >= 5.0.0 <= 5.3.11",
108+
"@ember/test-waiters": "^4.0.0",
108109
"@embroider/macros": ">= 1.0.0",
109110
"ember-data": "~4.12.0 || >= 5.0.0 <= 5.3.11",
110111
"ember-simple-auth": ">= 6.0.0",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)