From 4a40a216d4fe02104fc5b5f8b8dfe4827883e0e3 Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Wed, 21 May 2025 13:23:28 +0200 Subject: [PATCH] test: Update app model tests to cover ee case --- .../src/models/__snapshots__/app.test.js.snap | 167 ++++++++++++++++++ packages/backend/src/models/app.test.js | 23 ++- 2 files changed, 186 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/models/__snapshots__/app.test.js.snap b/packages/backend/src/models/__snapshots__/app.test.js.snap index bec4c65a..c6b27e75 100644 --- a/packages/backend/src/models/__snapshots__/app.test.js.snap +++ b/packages/backend/src/models/__snapshots__/app.test.js.snap @@ -1,5 +1,172 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html +exports[`App model > list > should exclude enterprise apps when license is not valid 1`] = ` +[ + "airtable", + "anthropic", + "appwrite", + "azure-openai", + "brave-search", + "carbone", + "clickup", + "code", + "cryptography", + "datastore", + "deepl", + "delay", + "discord", + "disqus", + "dropbox", + "filter", + "flickr", + "flowers-software", + "formatter", + "freescout", + "ghost", + "gitea", + "github", + "gitlab", + "gmail", + "google-calendar", + "google-drive", + "google-forms", + "google-sheets", + "google-tasks", + "helix", + "http-request", + "hubspot", + "invoice-ninja", + "jotform", + "mailchimp", + "mailerlite", + "mattermost", + "miro", + "mistral-ai", + "monday", + "notion", + "ntfy", + "odoo", + "openai", + "openrouter", + "perplexity", + "pipedrive", + "placetel", + "postgresql", + "pushover", + "reddit", + "removebg", + "rss", + "salesforce", + "scheduler", + "self-hosted-llm", + "signalwire", + "slack", + "smtp", + "spotify", + "strava", + "stripe", + "telegram-bot", + "todoist", + "together-ai", + "trello", + "twilio", + "twitter", + "typeform", + "virtualq", + "vtiger-crm", + "webhook", + "wordpress", + "xero", + "you-need-a-budget", + "youtube", + "zendesk", +] +`; + +exports[`App model > list > should list all applications including enterprise ones when license is valid 1`] = ` +[ + "airtable", + "anthropic", + "appwrite", + "azure-openai", + "brave-search", + "carbone", + "clickup", + "code", + "cryptography", + "datastore", + "deepl", + "delay", + "discord", + "disqus", + "dropbox", + "filter", + "flickr", + "flowers-software", + "formatter", + "forms", + "freescout", + "ghost", + "gitea", + "github", + "gitlab", + "gmail", + "google-calendar", + "google-drive", + "google-forms", + "google-sheets", + "google-tasks", + "helix", + "http-request", + "hubspot", + "invoice-ninja", + "jotform", + "mailchimp", + "mailerlite", + "mattermost", + "miro", + "mistral-ai", + "monday", + "notion", + "ntfy", + "odoo", + "openai", + "openrouter", + "perplexity", + "pipedrive", + "placetel", + "postgresql", + "pushover", + "reddit", + "removebg", + "rss", + "salesforce", + "scheduler", + "self-hosted-llm", + "signalwire", + "slack", + "smtp", + "spotify", + "strava", + "stripe", + "telegram-bot", + "todoist", + "together-ai", + "trello", + "twilio", + "twitter", + "typeform", + "virtualq", + "vtiger-crm", + "webhook", + "wordpress", + "xero", + "you-need-a-budget", + "youtube", + "zendesk", +] +`; + exports[`App model > list should have list of applications keys 1`] = ` [ "airtable", diff --git a/packages/backend/src/models/app.test.js b/packages/backend/src/models/app.test.js index 656834c9..f19a013a 100644 --- a/packages/backend/src/models/app.test.js +++ b/packages/backend/src/models/app.test.js @@ -1,23 +1,38 @@ import { describe, it, expect, vi } from 'vitest'; - import App from './app.js'; import * as getAppModule from '../helpers/get-app.js'; import * as appInfoConverterModule from '../helpers/app-info-converter.js'; +import * as licenseModule from '../helpers/license.ee.js'; describe('App model', () => { it('folderPath should return correct path', () => { expect(App.folderPath.endsWith('/packages/backend/src/apps')).toBe(true); }); - it('list should have list of applications keys', () => { - expect(App.list).toMatchSnapshot(); + describe('list', () => { + it('should list all applications including enterprise ones when license is valid', async () => { + vi.spyOn(licenseModule, 'hasValidLicense').mockResolvedValue(true); + const appList = await App.list(); + + expect(appList).toMatchSnapshot(); + expect(appList).toContain('forms'); + }); + + it('should exclude enterprise apps when license is not valid', async () => { + vi.spyOn(licenseModule, 'hasValidLicense').mockResolvedValue(false); + const appList = await App.list(); + + expect(appList).toMatchSnapshot(); + expect(appList).not.toContain('forms'); + }); }); describe('findAll', () => { it('should return all applications', async () => { const apps = await App.findAll(); + const appList = await App.list(); - expect(apps.length).toBe(App.list.length); + expect(apps.length).toBe(appList.length); }); it('should return matching applications when name argument is given', async () => {