@spica-devkit/testing 0.18.42 → 0.18.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -7795,7 +7795,13 @@ function sanitizeSlug(slug) {
7795
7795
  function unwrapList(res) {
7796
7796
  if (Array.isArray(res))
7797
7797
  return res;
7798
- return res.data ?? [];
7798
+ if (res && typeof res === "object" && Array.isArray(res.data)) {
7799
+ return res.data;
7800
+ }
7801
+ const body = res;
7802
+ const got = typeof body === "string" ? `${body.slice(0, 80).replace(/\s+/g, " ")}…` : typeof body;
7803
+ throw new Error(`Expected a list response but got: ${got}. ` +
7804
+ `Check that your context URL points at the Spica API (e.g. ".../api"), not the panel.`);
7799
7805
  }
7800
7806
  async function readLocalSchemas(rootDir, moduleName) {
7801
7807
  const dir = path.join(rootDir, moduleName);
@@ -12069,7 +12075,8 @@ const functionModule = {
12069
12075
  return results;
12070
12076
  },
12071
12077
  async readRemote(http) {
12072
- const fns = await http.get("function");
12078
+ const res = await http.get("function");
12079
+ const fns = unwrapList(res);
12073
12080
  return Promise.all(fns.map(async (fn) => {
12074
12081
  const id = fn._id;
12075
12082
  const [indexRes, depsRes] = await Promise.all([
@@ -12327,7 +12334,7 @@ const policyModule = {
12327
12334
  },
12328
12335
  async readRemote(http) {
12329
12336
  const res = await http.get("passport/policy");
12330
- const items = Array.isArray(res) ? res : (res.data ?? []);
12337
+ const items = unwrapList(res);
12331
12338
  return items
12332
12339
  .filter(p => !p.system)
12333
12340
  .map(p => ({