Icu 15181 add pagination to session recordings (#2502)
* refactor: 💡 move model hook to session-recordings/index route ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15130 * test: 💍 add missing tests for session recordings controller ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15130 * feat: 🎸 paginate session-recordings and search ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15130 * refactor: 💡 fix failing redirect and tests ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15130 * test: 💍 add search tests for session recordings ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15130 * feat: 🎸 add user filtering for session recordings ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15130 * feat: 🎸 add more attributes to indexed-db session recordings ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15130 * feat: 🎸 add target filter for session recordings ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15130 * refactor: 💡 update filterOptions method ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15130 * feat: 🎸 add scopes filtering to session recording ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * feat: 🎸 add time filter to session recordings ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * refactor: 💡 add no filter results text ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * refactor: 💡 update Exist variables to doExist ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * refactor: 💡 updates from PR feedback ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * refactor: 💡 remove scope_id filter ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * refactor: 💡 change session recording placeholder text ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * chore: 🤖 increment indexedDB version ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * test: 💍 add Date object tests for indexed-db ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * refactor: 💡 small changes from PR feedback ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * refactor: 💡 change times filter array to time date object ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * test: 💍 add more date specific indexed-db test ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * refactor: 💡 change Today time shortcut to "Last 24 hours" ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181 * test: 💍 fix date mock in session-recording controller tests ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15181
This commit is contained in:
1 parent
15727f61fd
commit
d3c789c66c
13 files changed
+1034
-191
No files matched your search
@@ -11,6 +11,7 @@ import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
|
||||
import { pluralize } from 'ember-inflector';
|
||||
import { camelize } from '@ember/string';
|
||||
import { TYPE_TARGET_TCP, TYPE_TARGET_SSH } from 'api/models/target';
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
const seedIndexDb = async (resource, store, indexedDb, server) => {
|
||||
const resourceData =
|
||||
@@ -529,4 +530,80 @@ module('Unit | Utility | indexed-db-query', function (hooks) {
|
||||
|
||||
assert.strictEqual(result.length, 0);
|
||||
});
|
||||
|
||||
test('it filters on date type fields and returns results', async function (assert) {
|
||||
const pastDate = new Date('2024-09-19T10:00:00.000Z');
|
||||
const createdTime = new Date('2024-09-23T10:00:00.000Z');
|
||||
this.server.create('session-recording', {
|
||||
created_time: createdTime,
|
||||
});
|
||||
await seedIndexDb('session-recording', store, indexedDb, this.server);
|
||||
const query = { filters: { created_time: [{ gte: pastDate }] } };
|
||||
|
||||
const result = await queryIndexedDb(
|
||||
indexedDb.db,
|
||||
'session-recording',
|
||||
query,
|
||||
);
|
||||
|
||||
assert.strictEqual(result.length, 1);
|
||||
});
|
||||
|
||||
test('it filters on date type fields and returns results - from and to', async function (assert) {
|
||||
const from = new Date('2024-09-19T10:00:00.000Z');
|
||||
const to = new Date('2024-09-25T10:00:00.000Z');
|
||||
const createdTime = new Date('2024-09-23T10:00:00.000Z');
|
||||
const createdTime2 = new Date('2024-09-28T10:00:00.000Z');
|
||||
this.server.create('session-recording', {
|
||||
created_time: createdTime,
|
||||
});
|
||||
this.server.create('session-recording', {
|
||||
created_time: createdTime2,
|
||||
});
|
||||
await seedIndexDb('session-recording', store, indexedDb, this.server);
|
||||
const query = {
|
||||
filters: {
|
||||
created_time: {
|
||||
logicalOperator: 'and',
|
||||
values: [{ gte: from }, { lte: to }],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const result = await queryIndexedDb(
|
||||
indexedDb.db,
|
||||
'session-recording',
|
||||
query,
|
||||
);
|
||||
|
||||
assert.strictEqual(result.length, 1);
|
||||
assert.strictEqual(
|
||||
result[0].attributes.created_time.toISOString(),
|
||||
createdTime.toISOString(),
|
||||
);
|
||||
});
|
||||
|
||||
test('it filters on date type fields and returns no results', async function (assert) {
|
||||
const createdTime = faker.date.between({
|
||||
from: '2024-09-19T00:00:00.000Z',
|
||||
to: '2024-09-20T00:00:00.000Z',
|
||||
});
|
||||
const pastDate = faker.date.between({
|
||||
from: '2024-09-23T00:00:00.000Z',
|
||||
to: '2024-09-24T00:00:00.000Z',
|
||||
});
|
||||
this.server.create('session-recording', {
|
||||
created_time: createdTime,
|
||||
});
|
||||
await seedIndexDb('session-recording', store, indexedDb, this.server);
|
||||
const query = { filters: { created_time: [{ gte: pastDate }] } };
|
||||
|
||||
const result = await queryIndexedDb(
|
||||
indexedDb.db,
|
||||
'session-recording',
|
||||
query,
|
||||
);
|
||||
|
||||
assert.strictEqual(result.length, 0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user