* refactor: 💡 add permission to read a session recording * test: 💍 remove a11yAudit from test temporarily * refactor: 💡 add aria-label to fix allyAudit violation (#168) * refactor: 💡 add aria-label to fix allyAudit violation * refactor: 💡 update standalone link to icon only button
104 lines
3.6 KiB
JavaScript
104 lines
3.6 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { visit, currentURL, click } from '@ember/test-helpers';
|
|
import { setupApplicationTest } from 'admin/tests/helpers';
|
|
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
|
import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
|
import { authenticateSession } from 'ember-simple-auth/test-support';
|
|
|
|
module('Acceptance | session recordings | read', function (hooks) {
|
|
setupApplicationTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
// Selectors
|
|
const LIST_SESSION_RECORDING_BUTTON =
|
|
'table > tbody > tr > td:last-child > a';
|
|
const LIST_CHANNEL_RECORDING_BUTTON =
|
|
'table > tbody > tr > td:last-child > a';
|
|
|
|
// Instances
|
|
const instances = {
|
|
scopes: {
|
|
global: null,
|
|
org: null,
|
|
},
|
|
sessionRecording: null,
|
|
};
|
|
// Urls
|
|
const urls = {
|
|
globalScope: null,
|
|
sessionRecordings: null,
|
|
sessionRecording: null,
|
|
channelRecording: null,
|
|
};
|
|
|
|
hooks.beforeEach(function () {
|
|
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
|
instances.scopes.org = this.server.create('scope', {
|
|
type: 'org',
|
|
scope: { id: 'global', type: 'global' },
|
|
});
|
|
instances.sessionRecording = this.server.create('session-recording', {
|
|
scope: instances.scopes.global,
|
|
});
|
|
instances.connectionRecording = this.server.create('connection-recording', {
|
|
session_recording: instances.sessionRecording,
|
|
});
|
|
instances.channelRecording = this.server.create('channel-recording', {
|
|
connection_recording: instances.connectionRecording,
|
|
});
|
|
urls.globalScope = `/scopes/global`;
|
|
urls.sessionRecordings = `${urls.globalScope}/session-recordings`;
|
|
urls.sessionRecording = `${urls.sessionRecordings}/${instances.sessionRecording.id}`;
|
|
urls.channelRecording = `${urls.sessionRecording}/channels-by-connection/${instances.channelRecording.id}`;
|
|
authenticateSession({});
|
|
});
|
|
|
|
test('visiting a session recording', async function (assert) {
|
|
assert.expect(1);
|
|
// Visit session recordings
|
|
await visit(urls.sessionRecordings);
|
|
await a11yAudit();
|
|
|
|
// Click a session recording and check it navigates properly
|
|
await click(LIST_SESSION_RECORDING_BUTTON);
|
|
await a11yAudit();
|
|
|
|
assert.strictEqual(currentURL(), urls.sessionRecording);
|
|
});
|
|
|
|
test('user can navigate to a session recording with proper authorization', async function (assert) {
|
|
assert.expect(3);
|
|
// Visit session recordings
|
|
await visit(urls.sessionRecordings);
|
|
|
|
assert.true(instances.sessionRecording.authorized_actions.includes('read'));
|
|
assert.dom(`[href="${urls.sessionRecording}"]`).exists();
|
|
// Click a session recording and check it navigates properly
|
|
await click(LIST_SESSION_RECORDING_BUTTON);
|
|
assert.strictEqual(currentURL(), urls.sessionRecording);
|
|
});
|
|
|
|
test('user cannot navigate to a session recording without the read action', async function (assert) {
|
|
assert.expect(1);
|
|
instances.sessionRecording.authorized_actions =
|
|
instances.sessionRecording.authorized_actions.filter(
|
|
(item) => item !== 'read'
|
|
);
|
|
|
|
// Visit session recordings
|
|
await visit(urls.sessionRecordings);
|
|
assert.dom(LIST_SESSION_RECORDING_BUTTON).doesNotExist();
|
|
});
|
|
|
|
test('user can navigate to a channel recording', async function (assert) {
|
|
assert.expect(2);
|
|
|
|
// Visit session recording
|
|
await visit(urls.sessionRecording);
|
|
assert.dom('table').hasClass('hds-table');
|
|
// Click a channel recording and check it navigates properly
|
|
await click(LIST_CHANNEL_RECORDING_BUTTON);
|
|
assert.strictEqual(currentURL(), urls.channelRecording);
|
|
});
|
|
});
|