@spica-devkit/testing 0.18.42 → 0.18.45

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.mjs CHANGED
@@ -7774,7 +7774,13 @@ function sanitizeSlug(slug) {
7774
7774
  function unwrapList(res) {
7775
7775
  if (Array.isArray(res))
7776
7776
  return res;
7777
- return res.data ?? [];
7777
+ if (res && typeof res === "object" && Array.isArray(res.data)) {
7778
+ return res.data;
7779
+ }
7780
+ const body = res;
7781
+ const got = typeof body === "string" ? `${body.slice(0, 80).replace(/\s+/g, " ")}…` : typeof body;
7782
+ throw new Error(`Expected a list response but got: ${got}. ` +
7783
+ `Check that your context URL points at the Spica API (e.g. ".../api"), not the panel.`);
7778
7784
  }
7779
7785
  async function readLocalSchemas(rootDir, moduleName) {
7780
7786
  const dir = path.join(rootDir, moduleName);
@@ -12048,7 +12054,8 @@ const functionModule = {
12048
12054
  return results;
12049
12055
  },
12050
12056
  async readRemote(http) {
12051
- const fns = await http.get("function");
12057
+ const res = await http.get("function");
12058
+ const fns = unwrapList(res);
12052
12059
  return Promise.all(fns.map(async (fn) => {
12053
12060
  const id = fn._id;
12054
12061
  const [indexRes, depsRes] = await Promise.all([
@@ -12306,7 +12313,7 @@ const policyModule = {
12306
12313
  },
12307
12314
  async readRemote(http) {
12308
12315
  const res = await http.get("passport/policy");
12309
- const items = Array.isArray(res) ? res : (res.data ?? []);
12316
+ const items = unwrapList(res);
12310
12317
  return items
12311
12318
  .filter(p => !p.system)
12312
12319
  .map(p => ({