test: Update app model tests to cover ee case

This commit is contained in:
Faruk AYDIN
2025-05-21 13:23:28 +02:00
parent 6b362b6643
commit 4a40a216d4
2 changed files with 186 additions and 4 deletions

View File

@@ -1,5 +1,172 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html // 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`] = ` exports[`App model > list should have list of applications keys 1`] = `
[ [
"airtable", "airtable",

View File

@@ -1,23 +1,38 @@
import { describe, it, expect, vi } from 'vitest'; import { describe, it, expect, vi } from 'vitest';
import App from './app.js'; import App from './app.js';
import * as getAppModule from '../helpers/get-app.js'; import * as getAppModule from '../helpers/get-app.js';
import * as appInfoConverterModule from '../helpers/app-info-converter.js'; import * as appInfoConverterModule from '../helpers/app-info-converter.js';
import * as licenseModule from '../helpers/license.ee.js';
describe('App model', () => { describe('App model', () => {
it('folderPath should return correct path', () => { it('folderPath should return correct path', () => {
expect(App.folderPath.endsWith('/packages/backend/src/apps')).toBe(true); expect(App.folderPath.endsWith('/packages/backend/src/apps')).toBe(true);
}); });
it('list should have list of applications keys', () => { describe('list', () => {
expect(App.list).toMatchSnapshot(); 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', () => { describe('findAll', () => {
it('should return all applications', async () => { it('should return all applications', async () => {
const apps = await App.findAll(); 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 () => { it('should return matching applications when name argument is given', async () => {