Files
threshold-ui/ui/admin/tests/unit/abilities/channel-recording-test.js
T
Cameron Perera b01d5f0271 refactor: 💡 Show View instead of Play if channel not asciicast (#325)
* refactor: 💡 Show View instead of Play if channel not asciicast

✅ Closes: ICU-9524

* refactor: 💡 every third channel is missing mime_types

* refactor: 💡 create new abilities for channel-recording

* refactor: 💡 use abilities for button logic for channels

* test: 💍 update channel-recording ability tests

* refactor: 💡 fix ChannelRecording ability import name

* refactor: 💡 change ability name to canPlay from canPlayChannel

* refactor: 💡 update OverrideChannelRecording ability methods
2023-06-07 14:15:55 -05:00

61 lines
1.8 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { STATE_SESSION_RECORDING_AVAILABLE } from 'api/models/session-recording';
import { MIME_TYPE_ASCIICAST } from 'api/models/channel-recording';
module('Unit | Abilities | channel-recording', function (hooks) {
setupTest(hooks);
let canService;
let store;
let sessionRecording;
let connectionRecording;
let asciicastChannel;
let noneAsciicastChannel;
hooks.beforeEach(function () {
canService = this.owner.lookup('service:can');
store = this.owner.lookup('service:store');
sessionRecording = store.createRecord('session-recording', {
state: STATE_SESSION_RECORDING_AVAILABLE,
});
connectionRecording = store.createRecord('connection-recording', {
session_recording: sessionRecording,
});
asciicastChannel = store.createRecord('channel-recording', {
mime_types: [MIME_TYPE_ASCIICAST],
connection_recording: connectionRecording,
});
noneAsciicastChannel = store.createRecord('channel-recording', {
mime_types: null,
connection_recording: connectionRecording,
});
});
test('returns true if session recording complete and channel mime type is asciicast', function (assert) {
assert.expect(2);
assert.true(canService.can('play channel-recording', asciicastChannel));
assert.false(
canService.can('play channel-recording', noneAsciicastChannel)
);
});
test('returns false if session recording complete and channel mime type is not asciicast', function (assert) {
assert.expect(2);
assert.true(
canService.can('viewOnly channel-recording', noneAsciicastChannel)
);
assert.false(
canService.can('viewOnly channel-recording', asciicastChannel)
);
});
});