feat(app-config): update canConnect upon dependent changes

This commit is contained in:
Ali BARIN
2024-10-08 12:17:44 +00:00
committed by Faruk AYDIN
parent f5d796ea77
commit aed61209fa
4 changed files with 68 additions and 16 deletions

View File

@@ -66,24 +66,52 @@ describe('AppConfig model', () => {
});
describe('canConnect', () => {
it('should return true when app is enabled, shared and allows custom connection', async () => {
it('should return true when app is enabled, shared and allows custom connection with an active app auth client at least', async () => {
await createAppAuthClient({
appKey: 'deepl',
active: true,
});
let appConfig = await createAppConfig({
await createAppAuthClient({
appKey: 'deepl',
active: false,
});
const appConfig = await createAppConfig({
disabled: false,
allowCustomConnection: true,
shared: true,
key: 'deepl',
});
appConfig = await appConfig.$query().withGraphFetched({
appAuthClients: true,
expect(appConfig.canConnect).toBe(true);
});
it('should return true when app is enabled, shared and allows custom connection with no active app auth client', async () => {
await createAppAuthClient({
appKey: 'deepl',
active: false,
});
expect(appConfig.canConnect).toBe(true);
const appConfig = await createAppConfig({
disabled: false,
allowCustomConnection: true,
shared: true,
key: 'deepl',
});
expect(appConfig.canConnect).toBe(false);
});
it('should return false when app is enabled, shared and allows custom connection without any app auth clients', async () => {
const appConfig = await createAppConfig({
disabled: false,
allowCustomConnection: true,
shared: true,
key: 'deepl',
});
expect(appConfig.canConnect).toBe(false);
});
it('should return false when app is disabled', async () => {