feat: 🎸 Add related channel information (#162)
* feat: 🎸 Add related channel information
This commit is contained in:
1 parent
b9fea822d0
commit
e4944fac89
7 files changed
+64
-36
No files matched your search
@@ -28,7 +28,19 @@ export default class SessionRecordingModel extends GeneratedSessionRecordingMode
|
||||
return !TYPES_SESSION_RECORDING.includes(this.type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns scope name or scope id from the target that belongs to the session recording.
|
||||
* @type {string}
|
||||
*/
|
||||
get targetScopeDisplayName() {
|
||||
return this.target?.scope?.name || this.target?.scope?.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user name or user id that belongs to the session recording.
|
||||
* @type {string}
|
||||
*/
|
||||
get userDisplayName() {
|
||||
return this.user?.name || this.user?.id;
|
||||
}
|
||||
}
|
||||
@@ -56,32 +56,37 @@ module('Unit | Model | session-recording', function (hooks) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const fakeName = 'Scope name';
|
||||
const fakeId = 's_123456789';
|
||||
// Scope models: A has just name, B has just id.
|
||||
const scopeModelA = await store.createRecord('scope', {
|
||||
type: 'global',
|
||||
name: fakeName,
|
||||
id: 's_1234567890',
|
||||
});
|
||||
const scopeModelB = await store.createRecord('scope', {
|
||||
type: 'org',
|
||||
id: fakeId,
|
||||
});
|
||||
|
||||
const targetModelA = await store.createRecord('target', {
|
||||
scope: scopeModelA,
|
||||
});
|
||||
const targetModelB = await store.createRecord('target', {
|
||||
scope: scopeModelB,
|
||||
});
|
||||
|
||||
const modelA = store.createRecord('session-recording', {
|
||||
target: targetModelA,
|
||||
target: {
|
||||
scope: { name: fakeName, id: fakeId },
|
||||
},
|
||||
});
|
||||
const modelB = store.createRecord('session-recording', {
|
||||
target: targetModelB,
|
||||
target: {
|
||||
scope: { id: fakeId },
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(modelA.targetScopeDisplayName, fakeName);
|
||||
assert.strictEqual(modelB.targetScopeDisplayName, fakeId);
|
||||
});
|
||||
|
||||
test('it has userDisplayName and returns the expected values', async function (assert) {
|
||||
assert.expect(2);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const fakeUserName = 'User name';
|
||||
const fakeUserId = 'userid';
|
||||
|
||||
const userModelA = store.createRecord('session-recording', {
|
||||
user: { name: fakeUserName, id: fakeUserId },
|
||||
});
|
||||
|
||||
const userModelB = store.createRecord('session-recording', {
|
||||
user: { id: fakeUserId },
|
||||
});
|
||||
|
||||
assert.strictEqual(userModelA.userDisplayName, fakeUserName);
|
||||
assert.strictEqual(userModelB.userDisplayName, fakeUserId);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user