refactor: 💡 Add Project name to session-recordings list (#152)

* refactor: 💡 Add Project name to session-recordings list
This commit is contained in:
Carlos Alcaide Corvo authored and GitHub committed 2023-03-28 09:48:22 -07:00
1 parent 992be8c4fb
commit 502f04d02a
4 files changed
+49 -1

No files matched your search

@@ -27,4 +27,8 @@ export default class SessionRecordingModel extends GeneratedSessionRecordingMode
get isUnknown() {
return !TYPES_SESSION_RECORDING.includes(this.type);
}
get targetScopeDisplayName() {
return this.target?.scope?.name || this.target?.scope?.id;
}
}
@@ -50,4 +50,38 @@ module('Unit | Model | session-recording', function (hooks) {
const connection_recordings = await model.connection_recordings;
assert.strictEqual(connection_recordings.length, 1);
});
test('it has targetScopeDisplayName and returns the expected values', async function (assert) {
assert.expect(2);
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,
});
const modelB = store.createRecord('session-recording', {
target: targetModelB,
});
assert.strictEqual(modelA.targetScopeDisplayName, fakeName);
assert.strictEqual(modelB.targetScopeDisplayName, fakeId);
});
});