2024-07-09 15:10:30 -05:00
|
|
|
/**
|
2026-01-28 17:09:06 -08:00
|
|
|
* Copyright IBM Corp. 2021, 2026
|
2024-07-09 15:10:30 -05:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
import { setupTest } from 'ember-qunit';
|
|
|
|
|
|
|
|
|
|
module('Unit | Abilities | Worker', function (hooks) {
|
|
|
|
|
setupTest(hooks);
|
|
|
|
|
|
2026-02-24 13:48:34 -05:00
|
|
|
let abilitiesService;
|
2024-07-09 15:10:30 -05:00
|
|
|
let store;
|
|
|
|
|
|
|
|
|
|
const instances = {
|
|
|
|
|
worker: null,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
hooks.beforeEach(function () {
|
2026-02-24 13:48:34 -05:00
|
|
|
abilitiesService = this.owner.lookup('service:abilities');
|
2024-07-09 15:10:30 -05:00
|
|
|
store = this.owner.lookup('service:store');
|
|
|
|
|
instances.worker = store.createRecord('worker');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can create worker-led', function (assert) {
|
|
|
|
|
const model = {
|
|
|
|
|
authorized_collection_actions: { workers: ['create:worker-led'] },
|
|
|
|
|
};
|
|
|
|
|
assert.true(
|
2026-02-24 13:48:34 -05:00
|
|
|
abilitiesService.can('createWorkerLed worker', model, {
|
2024-07-09 15:10:30 -05:00
|
|
|
collection: 'workers',
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('cannot create worker-led', function (assert) {
|
|
|
|
|
const model = {
|
|
|
|
|
authorized_collection_actions: { workers: [] },
|
|
|
|
|
};
|
|
|
|
|
assert.true(
|
2026-02-24 13:48:34 -05:00
|
|
|
abilitiesService.cannot('createWorkerLed worker', model, {
|
2024-07-09 15:10:30 -05:00
|
|
|
collection: 'workers',
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can set worker tags', function (assert) {
|
|
|
|
|
instances.worker.authorized_actions = ['set-worker-tags'];
|
2026-02-24 13:48:34 -05:00
|
|
|
assert.true(abilitiesService.can('setWorkerTags worker', instances.worker));
|
2024-07-09 15:10:30 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('cannot set worker tags', function (assert) {
|
|
|
|
|
instances.worker.authorized_actions = [];
|
2026-02-24 13:48:34 -05:00
|
|
|
assert.true(
|
|
|
|
|
abilitiesService.cannot('setWorkerTags worker', instances.worker),
|
|
|
|
|
);
|
2024-07-09 15:10:30 -05:00
|
|
|
});
|
|
|
|
|
});
|