Skip to content

Commit

Permalink
Adding test coverage on initial Roles and Groups
Browse files Browse the repository at this point in the history
  • Loading branch information
aHenryJard authored and marieflorescontact committed Oct 2, 2024
1 parent 4e72091 commit 7fb7cfd
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { listAllEntities } from '../../../src/database/middleware-loader';
import { ENTITY_TYPE_CAPABILITY } from '../../../src/schema/internalObject';
import {ENTITY_TYPE_CAPABILITY, ENTITY_TYPE_GROUP, ENTITY_TYPE_ROLE} from '../../../src/schema/internalObject';
import { ADMIN_USER, testContext } from '../../utils/testQuery';
import type { BasicStoreEntity } from '../../../src/types/store';

Expand Down Expand Up @@ -51,4 +51,22 @@ describe('Data initialization test', () => {
];
expect(capabilitiesNames).toEqual(allExpectedNames);
});

it('should create all initial roles', async () => {
const allRoles = await listAllEntities<BasicStoreEntity>(testContext, ADMIN_USER, [ENTITY_TYPE_ROLE]);
const allRolesNames = allRoles.map((role) => role.name).sort();
const allExpectedRoles = ['Administrator', 'Connector', 'Default'];
for (let i = 0; i < allExpectedRoles.length; i = i+1) {
expect(allRolesNames, `${allExpectedRoles[i]} Role is missing from initialization`).toContain(allExpectedRoles[i]);
}
});

it('should create all initial Groups', async () => {
const allGroups = await listAllEntities<BasicStoreEntity>(testContext, ADMIN_USER, [ENTITY_TYPE_GROUP]);
const allGroupsNames = allGroups.map((group) => group.name).sort();
const allExpectedGroups = ['Administrators', 'Connectors', 'Default'];
for (let i = 0; i < allExpectedGroups.length; i = i+1) {
expect(allGroupsNames, `${allExpectedGroups[i]} Group is missing from initialization`).toContain(allExpectedGroups[i]);
}
});
});

0 comments on commit 7fb7cfd

Please sign in to comment.