0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

chore: fix tests

This commit is contained in:
Gao Sun 2024-06-22 14:51:42 +08:00
parent 5e0a4401f6
commit bcd2ac7c09
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
3 changed files with 15 additions and 6 deletions

View file

@ -71,8 +71,14 @@ devFeatureTest.describe('organization application APIs', () => {
const organizationId = organizationApi.organizations[0]!.id; const organizationId = organizationApi.organizations[0]!.id;
const app = applications[0]!; const app = applications[0]!;
const roles = await Promise.all([ const roles = await Promise.all([
organizationApi.roleApi.create({ name: generateTestName() }), organizationApi.roleApi.create({
organizationApi.roleApi.create({ name: generateTestName() }), name: generateTestName(),
type: RoleType.MachineToMachine,
}),
organizationApi.roleApi.create({
name: generateTestName(),
type: RoleType.MachineToMachine,
}),
]); ]);
const roleIds = roles.map(({ id }) => id); const roleIds = roles.map(({ id }) => id);
await organizationApi.addApplicationRoles(organizationId, app.id, roleIds); await organizationApi.addApplicationRoles(organizationId, app.id, roleIds);
@ -203,7 +209,10 @@ devFeatureTest.describe('organization application APIs', () => {
it('should be able to add and delete organization application role', async () => { it('should be able to add and delete organization application role', async () => {
const organization = await organizationApi.create({ name: 'test' }); const organization = await organizationApi.create({ name: 'test' });
const role = await organizationApi.roleApi.create({ name: `test-${generateTestName()}` }); const role = await organizationApi.roleApi.create({
name: `test-${generateTestName()}`,
type: RoleType.MachineToMachine,
});
const application = await createApplication( const application = await createApplication(
generateTestName(), generateTestName(),
ApplicationType.MachineToMachine ApplicationType.MachineToMachine

View file

@ -5,7 +5,7 @@ import { HTTPError } from 'ky';
import { OrganizationApiTest } from '#src/helpers/organization.js'; import { OrganizationApiTest } from '#src/helpers/organization.js';
import { UserApiTest } from '#src/helpers/user.js'; import { UserApiTest } from '#src/helpers/user.js';
import { generateTestName } from '#src/utils.js'; import { devFeatureTest, generateTestName } from '#src/utils.js';
describe('organization user APIs', () => { describe('organization user APIs', () => {
describe('organization get users', () => { describe('organization get users', () => {
@ -289,7 +289,7 @@ describe('organization user APIs', () => {
); );
}); });
it('should fail when try to add role that is not user type', async () => { devFeatureTest.it('should fail when try to add role that is not user type', async () => {
const organization = await organizationApi.create({ name: 'test' }); const organization = await organizationApi.create({ name: 'test' });
const user = await userApi.create({ username: generateTestName() }); const user = await userApi.create({ username: generateTestName() });
const role = await roleApi.create({ const role = await roleApi.create({

View file

@ -46,7 +46,7 @@ export const createM2mRoleAndAssignPermissions = async (
await expectModalWithTitle(page, 'Create role'); await expectModalWithTitle(page, 'Create role');
await expect(page).toClick('div[class*=radioGroup][class$=roleTypes] div[class$=content]', { await expect(page).toClick('div[class*=radioGroup][class$=roleTypes] div[class$=content]', {
text: 'Machine-to-machine role', text: 'Machine-to-machine',
}); });
await expect(page).toFillForm('.ReactModalPortal form', { await expect(page).toFillForm('.ReactModalPortal form', {