Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/field-types/single_reference.subtest.js
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | with_running_app(async ({ app, base_url, rest_api }) => { | ||||
const { id } = await rest_api.post(B, { number }); | const { id } = await rest_api.post(B, { number }); | ||||
await rest_api.post(A, { reference_to_b: id }); | await rest_api.post(A, { reference_to_b: id }); | ||||
} | } | ||||
const { items } = await rest_api.get( | const { items } = await rest_api.get( | ||||
`${A}?filter[reference_to_b][number]=3&format[reference_to_b]=expand` | `${A}?filter[reference_to_b][number]=3&format[reference_to_b]=expand` | ||||
); | ); | ||||
assert.deepEqual(items.length, 1); | assert.deepEqual(items.length, 1); | ||||
assert.deepEqual(items[0].body.reference_to_b.body.number, 3); | assert.deepEqual(items[0].reference_to_b.number, 3); | ||||
})); | })); | ||||
it("should be filterable by referenced collection field of referenced collection field", async () => | it("should be filterable by referenced collection field of referenced collection field", async () => | ||||
with_running_app(async ({ app, base_url, rest_api }) => { | with_running_app(async ({ app, base_url, rest_api }) => { | ||||
// A => B => C | // A => B => C | ||||
await app.createChip(app.Sealious.Collection, { | await app.createChip(app.Sealious.Collection, { | ||||
name: "A", | name: "A", | ||||
fields: [ | fields: [ | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | with_running_app(async ({ app, base_url, rest_api }) => { | ||||
const { items } = await rest_api | const { items } = await rest_api | ||||
.get( | .get( | ||||
`${A}?filter[reference_to_b][reference_to_c][number]=3&format[reference_to_b]=deep-expand:2` | `${A}?filter[reference_to_b][reference_to_c][number]=3&format[reference_to_b]=deep-expand:2` | ||||
) | ) | ||||
.catch(console.error); | .catch(console.error); | ||||
assert.deepEqual(items.length, 1); | assert.deepEqual(items.length, 1); | ||||
assert.deepEqual( | assert.deepEqual(items[0].reference_to_b.reference_to_c.number, 3); | ||||
items[0].body.reference_to_b.body.reference_to_c.body.number, | |||||
3 | |||||
); | |||||
})); | })); | ||||
}); | }); | ||||
describe("single_reference attachments", () => { | describe("single_reference attachments", () => { | ||||
const items = {}; | const items = {}; | ||||
async function setup(app, rest_api) { | async function setup(app, rest_api) { | ||||
app.createChip(app.Sealious.Collection, { | app.createChip(app.Sealious.Collection, { | ||||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |