Skip to content

Commit eaec100

Browse files
committed
Fix test
1 parent be556f5 commit eaec100

File tree

6 files changed

+45
-65
lines changed

6 files changed

+45
-65
lines changed

packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__e2e__/applications-install-delete-reinstall.e2e-spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { getTestedApplicationPath } from '@/cli/__tests__/e2e/utils/get-tested-a
22
import { AppUninstallCommand } from '@/cli/commands/app/app-uninstall';
33
import { existsSync } from 'fs';
44
import { inspect } from 'util';
5-
import { AppDevCommand } from '@/cli/commands/app/app-dev';
65
import { join } from 'path';
6+
import { runAppDev } from '@/cli/__tests__/integration/utils/run-app-dev.util';
7+
import { OUTPUT_DIR } from '@/cli/utilities/build/common/constants';
78

89
inspect.defaultOptions.depth = 10;
910

1011
describe('Application: install delete and reinstall rich-app', () => {
1112
const applicationName = 'rich-app';
12-
const appDevCommand = new AppDevCommand();
1313
const deleteCommand = new AppUninstallCommand();
1414
const appPath = getTestedApplicationPath(applicationName);
1515

@@ -27,9 +27,9 @@ describe('Application: install delete and reinstall rich-app', () => {
2727
});
2828

2929
it(`should successfully install ${applicationName} application`, async () => {
30-
await appDevCommand.execute({ appPath });
30+
await runAppDev({ appPath });
3131

32-
expect(existsSync(join(appPath, 'manifest.json'))).toBe(true);
32+
expect(existsSync(join(appPath, OUTPUT_DIR, 'manifest.json'))).toBe(true);
3333
});
3434

3535
it(`should successfully delete ${applicationName} application`, async () => {
@@ -42,8 +42,8 @@ describe('Application: install delete and reinstall rich-app', () => {
4242
});
4343

4444
it(`should successfully re-install ${applicationName} application`, async () => {
45-
await appDevCommand.execute({ appPath });
45+
await runAppDev({ appPath });
4646

47-
expect(existsSync(join(appPath, 'manifest.json'))).toBe(true);
47+
expect(existsSync(join(appPath, OUTPUT_DIR, 'manifest.json'))).toBe(true);
4848
});
4949
});

packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/app-dev.integration.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { type RunCliCommandResult } from '@/cli/__tests__/integration/utils/run-
33
import { join } from 'path';
44

55
import { defineConsoleOutputTests } from './tests/console-output.tests';
6-
import { defineManifestTests } from '../app-dev/tests/manifest.tests';
7-
import { defineFrontComponentsTests } from '../app-dev/tests/front-components.tests';
8-
import { defineFunctionsTests } from '../app-dev/tests/functions.tests';
6+
import { defineManifestTests } from './tests/manifest.tests';
7+
import { defineEntitiesTests } from './tests/entities.tests';
98

109
const APP_PATH = join(__dirname, '../..');
1110

@@ -20,6 +19,5 @@ describe('rich-app app:dev', () => {
2019

2120
defineConsoleOutputTests(() => result);
2221
defineManifestTests(APP_PATH);
23-
defineFunctionsTests(APP_PATH);
24-
defineFrontComponentsTests(APP_PATH);
22+
defineEntitiesTests(APP_PATH);
2523
});

packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/expected-manifest.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const EXPECTED_MANIFEST: ApplicationManifest = {
2222
},
2323
frontComponents: [
2424
{
25-
builtComponentPath: 'front-components/src/root.front-component.mjs',
25+
builtComponentPath: 'src/root.front-component.mjs',
2626
builtComponentChecksum: '[checksum]',
2727
componentName: 'RootComponent',
2828
description: 'A root-level front component',
@@ -31,8 +31,7 @@ export const EXPECTED_MANIFEST: ApplicationManifest = {
3131
universalIdentifier: 'a0a1a2a3-a4a5-4000-8000-000000000001',
3232
},
3333
{
34-
builtComponentPath:
35-
'front-components/src/components/card.front-component.mjs',
34+
builtComponentPath: 'src/components/card.front-component.mjs',
3635
builtComponentChecksum: '[checksum]',
3736
componentName: 'CardDisplay',
3837
description: 'A component using an external component file',
@@ -41,8 +40,7 @@ export const EXPECTED_MANIFEST: ApplicationManifest = {
4140
universalIdentifier: 'i0i1i2i3-i4i5-4000-8000-000000000001',
4241
},
4342
{
44-
builtComponentPath:
45-
'front-components/src/components/greeting.front-component.mjs',
43+
builtComponentPath: 'src/components/greeting.front-component.mjs',
4644
builtComponentChecksum: '[checksum]',
4745
componentName: 'GreetingComponent',
4846
description: 'A component that uses greeting utility',
@@ -51,8 +49,7 @@ export const EXPECTED_MANIFEST: ApplicationManifest = {
5149
universalIdentifier: 'h0h1h2h3-h4h5-4000-8000-000000000001',
5250
},
5351
{
54-
builtComponentPath:
55-
'front-components/src/components/test.front-component.mjs',
52+
builtComponentPath: 'src/components/test.front-component.mjs',
5653
builtComponentChecksum: '[checksum]',
5754
componentName: 'TestComponent',
5855
description: 'A test front component',
@@ -294,8 +291,8 @@ export const EXPECTED_MANIFEST: ApplicationManifest = {
294291
functions: [
295292
{
296293
builtHandlerChecksum: '[checksum]',
297-
builtHandlerPath: 'functions/src/root.function.mjs',
298-
handlerName: 'rootHandler',
294+
builtHandlerPath: 'src/root.function.mjs',
295+
handlerName: 'default.handler',
299296
name: 'root-function',
300297
sourceHandlerPath: 'src/root.function.ts',
301298
timeoutSeconds: 5,
@@ -312,8 +309,8 @@ export const EXPECTED_MANIFEST: ApplicationManifest = {
312309
},
313310
{
314311
builtHandlerChecksum: '[checksum]',
315-
builtHandlerPath: 'functions/src/functions/greeting.function.mjs',
316-
handlerName: 'greetingHandler',
312+
builtHandlerPath: 'src/functions/greeting.function.mjs',
313+
handlerName: 'default.handler',
317314
name: 'greeting-function',
318315
sourceHandlerPath: 'src/functions/greeting.function.ts',
319316
timeoutSeconds: 5,
@@ -323,17 +320,17 @@ export const EXPECTED_MANIFEST: ApplicationManifest = {
323320
isAuthRequired: false,
324321
path: '/greet',
325322
type: 'route',
326-
universalIdentifier: 'g0g1g2g3-g4g5-4000-8000-000000000002',
323+
universalIdentifier: 'f7b12160-3d25-4c92-a13f-a325dd60eb04',
327324
},
328325
],
329-
universalIdentifier: 'g0g1g2g3-g4g5-4000-8000-000000000001',
326+
universalIdentifier: '9d412d9e-2caf-487c-8b66-d1585883dd4e',
330327
},
331328
{
332329
builtHandlerChecksum: '[checksum]',
333-
builtHandlerPath: 'functions/src/functions/test-function-2.function.mjs',
334-
handlerName: 'testFunction2',
330+
builtHandlerPath: 'src/functions/test-function-2.function.mjs',
331+
handlerName: 'config.handler',
335332
name: 'test-function-2',
336-
sourceHandlerPath: 'src/utils/test-function-2.util.ts',
333+
sourceHandlerPath: 'src/functions/test-function-2.function.ts',
337334
timeoutSeconds: 2,
338335
triggers: [
339336
{
@@ -346,8 +343,8 @@ export const EXPECTED_MANIFEST: ApplicationManifest = {
346343
},
347344
{
348345
builtHandlerChecksum: '[checksum]',
349-
builtHandlerPath: 'functions/src/functions/test-function.function.mjs',
350-
handlerName: 'handler',
346+
builtHandlerPath: 'src/functions/test-function.function.mjs',
347+
handlerName: 'default.handler',
351348
name: 'test-function',
352349
sourceHandlerPath: 'src/functions/test-function.function.ts',
353350
timeoutSeconds: 2,

packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/tests/functions.tests.ts renamed to packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/tests/entities.tests.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
11
import * as fs from 'fs-extra';
22
import { join } from 'path';
3+
import { OUTPUT_DIR } from '@/cli/utilities/build/common/constants';
34

4-
export const defineFunctionsTests = (appPath: string): void => {
5+
export const defineEntitiesTests = (appPath: string): void => {
6+
const outputDir = join(appPath, OUTPUT_DIR);
57
describe('functions', () => {
68
it('should have built functions preserving source path structure', async () => {
7-
const functionsDir = join(appPath, '.twenty/output/functions');
8-
const files = await fs.readdir(functionsDir, { recursive: true });
9+
const files = await fs.readdir(outputDir, { recursive: true });
910
const sortedFiles = files.map((f) => f.toString()).sort();
1011

1112
expect(sortedFiles).toEqual([
13+
'manifest.json',
1214
'src',
15+
'src/components',
16+
'src/components/card.front-component.mjs',
17+
'src/components/card.front-component.mjs.map',
18+
'src/components/greeting.front-component.mjs',
19+
'src/components/greeting.front-component.mjs.map',
20+
'src/components/test.front-component.mjs',
21+
'src/components/test.front-component.mjs.map',
1322
'src/functions',
1423
'src/functions/greeting.function.mjs',
1524
'src/functions/greeting.function.mjs.map',
1625
'src/functions/test-function-2.function.mjs',
1726
'src/functions/test-function-2.function.mjs.map',
1827
'src/functions/test-function.function.mjs',
1928
'src/functions/test-function.function.mjs.map',
29+
'src/root.front-component.mjs',
30+
'src/root.front-component.mjs.map',
2031
'src/root.function.mjs',
2132
'src/root.function.mjs.map',
2233
]);
2334
});
2435

2536
it('should not create shared chunk files for utilities', async () => {
26-
const functionsDir = join(appPath, '.twenty/output/functions');
27-
const files = await fs.readdir(functionsDir, { recursive: true });
37+
const files = await fs.readdir(outputDir, { recursive: true });
2838

2939
// Chunk files have a hash suffix like "greeting.util-CipJsYK0.mjs"
3040
const chunkFiles = files
3141
.map((f) => f.toString())
32-
.filter((f) => f.endsWith('.mjs') && !f.includes('.function.mjs'));
42+
.filter((f) => f.endsWith('.mjs') && !f.includes('.function.mjs'))
43+
.filter(
44+
(f) => f.endsWith('.mjs') && !f.includes('.front-component.mjs'),
45+
);
3346

3447
expect(chunkFiles).toEqual([]);
3548
});

packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/tests/front-components.tests.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/twenty-sdk/src/cli/__tests__/apps/rich-app/src/functions/greeting.function.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const greetingHandler = () => {
66
};
77

88
export default defineFunction({
9-
universalIdentifier: 'g0g1g2g3-g4g5-4000-8000-000000000001',
9+
universalIdentifier: '9d412d9e-2caf-487c-8b66-d1585883dd4e',
1010
name: 'greeting-function',
1111
timeoutSeconds: 5,
1212
handler: greetingHandler,
1313
triggers: [
1414
{
15-
universalIdentifier: 'g0g1g2g3-g4g5-4000-8000-000000000002',
15+
universalIdentifier: 'f7b12160-3d25-4c92-a13f-a325dd60eb04',
1616
type: 'route',
1717
path: '/greet',
1818
httpMethod: 'GET',

0 commit comments

Comments
 (0)