From 6b79884c9901ab7c40f1a69be040297f1d36f814 Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:54:00 +0100 Subject: [PATCH] fix(demo): pause new demo (#1851) ## Describe your changes Fixes NAN-541 Update to reflect change in syncs name --- .../jobs/lib/crons/autoIdleDemo.integration.test.ts | 10 ++++++---- packages/shared/lib/services/sync/sync.service.ts | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/jobs/lib/crons/autoIdleDemo.integration.test.ts b/packages/jobs/lib/crons/autoIdleDemo.integration.test.ts index fdd3b72fbb..1b26fedb10 100644 --- a/packages/jobs/lib/crons/autoIdleDemo.integration.test.ts +++ b/packages/jobs/lib/crons/autoIdleDemo.integration.test.ts @@ -11,7 +11,9 @@ import { createSchedule, ScheduleStatus, SyncClient, - resultOk + resultOk, + DEMO_GITHUB_CONFIG_KEY, + DEMO_SYNC_NAME } from '@nangohq/shared'; import { exec } from './autoIdleDemo.js'; import { nanoid } from 'nanoid'; @@ -33,15 +35,15 @@ describe('Auto Idle Demo', () => { const connName = nanoid(); const env = await environmentService.createEnvironment(0, envName); await configService.createProviderConfig({ - unique_key: 'demo-github-integration', + unique_key: DEMO_GITHUB_CONFIG_KEY, provider: 'github', environment_id: env!.id, oauth_client_id: '', oauth_client_secret: '' }); - const conn = await connectionService.upsertConnection(connName, 'demo-github-integration', 'github', {} as any, {}, env!.id, 0); + const conn = await connectionService.upsertConnection(connName, DEMO_GITHUB_CONFIG_KEY, 'github', {} as any, {}, env!.id, 0); const connId = conn[0]!.id; - const sync = (await createSync(connId, 'github-issues-lite'))!; + const sync = (await createSync(connId, DEMO_SYNC_NAME))!; await createSchedule(sync.id!, '86400', 0, ScheduleStatus.RUNNING, nanoid()); const schedBefore = await getSchedule(sync.id!); expect(schedBefore?.status).toBe(ScheduleStatus.RUNNING); diff --git a/packages/shared/lib/services/sync/sync.service.ts b/packages/shared/lib/services/sync/sync.service.ts index 272acaa3a1..db50637c37 100644 --- a/packages/shared/lib/services/sync/sync.service.ts +++ b/packages/shared/lib/services/sync/sync.service.ts @@ -24,6 +24,7 @@ import { } from './config/config.service.js'; import syncOrchestrator from './orchestrator.service.js'; import connectionService from '../connection.service.js'; +import { DEMO_GITHUB_CONFIG_KEY, DEMO_SYNC_NAME } from '../onboarding.service.js'; const TABLE = dbNamespace + 'syncs'; const SYNC_JOB_TABLE = dbNamespace + 'sync_jobs'; @@ -729,9 +730,9 @@ export async function findPausableDemoSyncs(): Promise { }) .join('_nango_sync_schedules', '_nango_sync_schedules.sync_id', '_nango_syncs.id') .where({ - '_nango_syncs.name': 'github-issues-lite', + '_nango_syncs.name': DEMO_SYNC_NAME, '_nango_environments.name': 'dev', - '_nango_configs.unique_key': 'demo-github-integration', + '_nango_configs.unique_key': DEMO_GITHUB_CONFIG_KEY, '_nango_configs.provider': 'github', '_nango_syncs.deleted': false, '_nango_sync_schedules.status': ScheduleStatus.RUNNING