4
0
Bernt Christian Egeland 1 сар өмнө
parent
commit
b10c544135

+ 9 - 1
src/__tests__/features/integrations/fiken-server.test.ts

@@ -1079,8 +1079,16 @@ describe('Fiken: the connection', () => {
     })
     expect(await connector.test(t.ctx)).toEqual({
       ok: false,
-      message: 'The API module is not switched on for Verksted AS in Fiken',
+      message:
+        'The API module is not activated for Verksted AS in Fiken. Activate it under Foretak, Tilleggstjenester.',
     })
+    const testCompany = makeCtx({
+      answer: (call) =>
+        call.path === BASE
+          ? { json: { slug: SLUG, name: 'Torqvoice Test', hasApiAccess: false, testCompany: true } }
+          : { json: { name: 'Kari' } },
+    })
+    expect(await connector.test(testCompany.ctx)).toEqual({ ok: true })
     const refused = makeCtx({ answer: () => ({ status: 403, json: { message: 'Ingen tilgang' } }) })
     const result = await connector.test(refused.ctx)
     expect(result.ok).toBe(false)

+ 5 - 4
src/integrations/fiken/server.ts

@@ -300,10 +300,11 @@ async function companyFacts(ctx: ConnectorContext, slug: string): Promise<Compan
     return known
   }
   const company = await read<FikenCompany>(ctx, companyPath(slug, ''))
-  if (company.hasApiAccess === false) {
+  // Fiken lets a test company use the API without the module.
+  if (company.hasApiAccess === false && company.testCompany !== true) {
     await ctx.log(
       'warn',
-      'The API module is not switched on for this company in Fiken, so Fiken may refuse what is sent. Order it in Fiken under the company settings, module access.'
+      'The API module is not activated for this company in Fiken, so Fiken refuses what is sent. Activate it in Fiken under Foretak, Tilleggstjenester.'
     )
   }
   const facts: CompanyFacts = {
@@ -934,10 +935,10 @@ export const connector: ConnectorServer = {
       const slug = settingsOf(ctx).companySlug
       if (!slug) return { ok: true }
       const company = await read<FikenCompany>(ctx, companyPath(slug, ''))
-      if (company.hasApiAccess === false) {
+      if (company.hasApiAccess === false && company.testCompany !== true) {
         return {
           ok: false,
-          message: `The API module is not switched on for ${company.name ?? slug} in Fiken`,
+          message: `The API module is not activated for ${company.name ?? slug} in Fiken. Activate it under Foretak, Tilleggstjenester.`,
         }
       }
       return { ok: true }