chore: 🤖 Remove type on channel recordings (#155)

This commit is contained in:
Zhihe Li authored and GitHub committed 2023-03-28 16:08:15 +00:00
1 parent b3dc1f236d
commit 1f581fcc75
4 files changed
-56

No files matched your search

@@ -12,12 +12,6 @@ import { attr } from '@ember-data/model';
export default class GeneratedChannelRecordingModel extends BaseModel {
// =attributes
@attr('string', {
description: 'The type of the resource, to help differentiate schemas',
readOnly: true,
})
type;
@attr('number', {
description:
'The total number of bytes uploaded from the client in this Channel.',
@@ -1,30 +1,9 @@
import GeneratedChannelRecordingModel from '../generated/models/channel-recording';
import { belongsTo } from '@ember-data/model';
export const TYPE_CHANNEL_RECORDING_SESSION = 'session';
export const TYPES_CHANNEL_RECORDING = Object.freeze([
TYPE_CHANNEL_RECORDING_SESSION,
]);
export default class ChannelRecordingModel extends GeneratedChannelRecordingModel {
@belongsTo('connection-recording') connection_recording;
/**
* True if the channel type is `session`.
* @type {boolean}
*/
get isSession() {
return this.type === TYPE_CHANNEL_RECORDING_SESSION;
}
/**
* True if the channel is an unknown type.
* @type {boolean}
*/
get isUnknown() {
return !TYPES_CHANNEL_RECORDING.includes(this.type);
}
/**
* Download the ascii cast recording for this channel.
* @returns {Promise<string>}
@@ -5,9 +5,7 @@
import factory from '../generated/factories/channel-recording';
import generateId from '../helpers/id';
import { TYPES_CHANNEL_RECORDING as types } from 'api/models/channel-recording';
export default factory.extend({
id: () => generateId('chr_'),
type: (i) => types[i % types.length],
});
@@ -1,6 +1,5 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { TYPE_CHANNEL_RECORDING_SESSION } from 'api/models/channel-recording';
module('Unit | Model | channel-recording', function (hooks) {
setupTest(hooks);
@@ -10,30 +9,4 @@ module('Unit | Model | channel-recording', function (hooks) {
let model = store.createRecord('channel-recording', {});
assert.ok(model);
});
test('it has isUnknown property and returns the expected values', async function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');
const modelA = store.createRecord('channel-recording', {
type: TYPE_CHANNEL_RECORDING_SESSION,
});
const modelB = store.createRecord('channel-recording', {
type: 'no-such-type',
});
assert.false(modelA.isUnknown);
assert.true(modelB.isUnknown);
});
test('it has isSession property and returns the expected values', async function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');
const modelA = store.createRecord('channel-recording', {
type: TYPE_CHANNEL_RECORDING_SESSION,
});
const modelB = store.createRecord('channel-recording', {
type: 'random',
});
assert.true(modelA.isSession);
assert.false(modelB.isSession);
});
});