feat: complete current GoChat updates

This commit is contained in:
2026-09-13 00:13:55 +08:00
parent 6e62f5094f
commit 0dd188c46f
58 changed files with 2662 additions and 1503 deletions
@@ -4,6 +4,14 @@ class CustomRole extends ApiClient {
constructor() {
super('custom_roles', { accountScoped: true });
}
create(data) {
return super.create({ custom_role: data });
}
update(id, data) {
return super.update(id, { custom_role: data });
}
}
export default new CustomRole();
@@ -0,0 +1,36 @@
import customRole from '../customRole';
describe('#CustomRoleAPI', () => {
const originalAxios = window.axios;
const axiosMock = {
post: vi.fn(() => Promise.resolve()),
patch: vi.fn(() => Promise.resolve()),
};
beforeEach(() => {
window.axios = axiosMock;
});
afterEach(() => {
window.axios = originalAxios;
vi.clearAllMocks();
});
it('wraps create and update payloads for the backend contract', () => {
const payload = {
name: 'Support',
description: 'Support role',
permissions: ['contact_manage'],
};
customRole.create(payload);
customRole.update(7, payload);
expect(axiosMock.post).toHaveBeenCalledWith('/api/v1/custom_roles', {
custom_role: payload,
});
expect(axiosMock.patch).toHaveBeenCalledWith('/api/v1/custom_roles/7', {
custom_role: payload,
});
});
});