Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/access-strategy-types/when.subtest.js
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | it("should only use 'when_true' access strategy when the item passes the filter", async () => | ||||
with_stopped_app(async ({ app, base_url, rest_api }) => { | with_stopped_app(async ({ app, base_url, rest_api }) => { | ||||
await create_resources(app); | await create_resources(app); | ||||
const session = await rest_api.login({ | const session = await rest_api.login({ | ||||
username: "user", | username: "user", | ||||
password: "password", | password: "password", | ||||
}); | }); | ||||
const { items: resources_when_logged_in } = await rest_api.get( | const { items: resources_when_logged_in } = await rest_api.get( | ||||
"/api/v1/collections/numbers?sort[body.number]=asc", | "/api/v1/collections/numbers?sort[number]=asc", | ||||
session | session | ||||
); | ); | ||||
assert.equal(resources_when_logged_in.length, 3); | assert.equal(resources_when_logged_in.length, 3); | ||||
assert.equal(resources_when_logged_in[0].body.number, -1); | assert.equal(resources_when_logged_in[0].number, -1); | ||||
})); | })); | ||||
it("should only use 'when_false' access strategy when the item doesn't pass the filter", async () => | it("should only use 'when_false' access strategy when the item doesn't pass the filter", async () => | ||||
with_stopped_app(async ({ app, base_url, rest_api }) => { | with_stopped_app(async ({ app, base_url, rest_api }) => { | ||||
await create_resources(app); | await create_resources(app); | ||||
const { items: public_resources } = await rest_api.get( | const { items: public_resources } = await rest_api.get( | ||||
"/api/v1/collections/numbers?sort[body.number]=asc" | "/api/v1/collections/numbers?sort[number]=asc" | ||||
); | ); | ||||
assert.equal(public_resources.length, 2); | assert.equal(public_resources.length, 2); | ||||
})); | })); | ||||
}); | }); |