Files
twenty/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-update-skill.integration-spec.ts
T
Félix Malfait 514d0017ea Refactor application module architecture for clarity and explicitness (#18432)
## Summary

- **Module reorganization**: Moved `ApplicationUpgradeService` and cron
jobs to `application-upgrade/`, `ApplicationSyncService` to
`application-manifest/`, and
`runWorkspaceMigration`/`uninstallApplication` mutations to the manifest
resolver — each module now has a single clear responsibility.
- **Explicit install flow**: Removed implicit `ApplicationEntity`
creation from `ApplicationSyncService`. The install service and dev
resolver now explicitly create the `ApplicationEntity` before syncing.
npm packages are resolved at registration time to extract manifest
metadata (universalIdentifier, name, description, etc.), eliminating the
`reconcileUniversalIdentifier` hack.
- **Better error handling**: Frontend hooks now surface actual server
error messages in snackbars instead of swallowing them. Replaced the
ugly `ConfirmationModal` for transfer ownership with a proper form
modal. Fixed `SettingsAdminTableCard` row height overflow and corrected
the `yarn-engine` asset path.

## Test plan
- [ ] Register an npm package — verify manifest metadata (name,
description, universalIdentifier) is extracted correctly
- [ ] Install a registered npm app on a workspace — verify
ApplicationEntity is created and sync succeeds
- [ ] Test `app:dev` CLI flow — verify local app registration and sync
work
- [ ] Upload a tarball — verify registration and install flow
- [ ] Transfer ownership — verify the new modal UX works
- [ ] Verify error messages appear correctly in snackbars when
operations fail


Made with [Cursor](https://cursor.com)
2026-03-06 08:45:08 +01:00

231 lines
6.9 KiB
TypeScript

import { buildBaseManifest } from 'test/integration/metadata/suites/application/utils/build-base-manifest.util';
import { setupApplicationForSync } from 'test/integration/metadata/suites/application/utils/setup-application-for-sync.util';
import { syncApplication } from 'test/integration/metadata/suites/application/utils/sync-application.util';
import { uninstallApplication } from 'test/integration/metadata/suites/application/utils/uninstall-application.util';
import { findSkills } from 'test/integration/metadata/suites/skill/utils/find-skills.util';
import { type Manifest } from 'twenty-shared/application';
import { v4 as uuidv4 } from 'uuid';
const TEST_APP_ID = uuidv4();
const TEST_ROLE_ID = uuidv4();
const TEST_SKILL_ID = uuidv4();
const TEST_SECOND_SKILL_ID = uuidv4();
const SKILL_GQL_FIELDS = 'id name label description content icon applicationId';
const buildManifest = (overrides?: Partial<Pick<Manifest, 'skills'>>) =>
buildBaseManifest({ appId: TEST_APP_ID, roleId: TEST_ROLE_ID, overrides });
const findAppSkills = async () => {
const { data } = await findSkills({
gqlFields: SKILL_GQL_FIELDS,
expectToFail: false,
input: undefined,
});
return data.skills.filter(
(skill) => skill.name === 'enrichment' || skill.name === 'scoring',
);
};
describe('Manifest update - skills', () => {
beforeEach(async () => {
await setupApplicationForSync({
applicationUniversalIdentifier: TEST_APP_ID,
name: 'Test Application',
description: 'App for testing skill manifest updates',
sourcePath: 'test-manifest-update-skill',
});
}, 60000);
afterEach(async () => {
try {
await uninstallApplication({
universalIdentifier: TEST_APP_ID,
expectToFail: false,
});
} catch {
// May fail if the test didn't fully install/sync
}
await globalThis.testDataSource.query(
`DELETE FROM core."role" WHERE "universalIdentifier" = $1`,
[TEST_ROLE_ID],
);
await globalThis.testDataSource.query(
`DELETE FROM core."file" WHERE "applicationId" IN (
SELECT id FROM core."application" WHERE "universalIdentifier" = $1
)`,
[TEST_APP_ID],
);
await globalThis.testDataSource.query(
`DELETE FROM core."application"
WHERE "universalIdentifier" = $1`,
[TEST_APP_ID],
);
await globalThis.testDataSource.query(
`DELETE FROM core."applicationRegistration"
WHERE "universalIdentifier" = $1`,
[TEST_APP_ID],
);
});
it('should create a new skill when added to manifest on second sync', async () => {
await syncApplication({
manifest: buildManifest({ skills: [] }),
expectToFail: false,
});
const skillsAfterFirstSync = await findAppSkills();
expect(skillsAfterFirstSync).toHaveLength(0);
await syncApplication({
manifest: buildManifest({
skills: [
{
universalIdentifier: TEST_SKILL_ID,
name: 'enrichment',
label: 'Enrichment',
description: 'Enrich contact data',
icon: 'IconSparkles',
content: '# Enrichment\n\nEnrich your data.',
},
],
}),
expectToFail: false,
});
const skillsAfterSecondSync = await findAppSkills();
expect(skillsAfterSecondSync).toHaveLength(1);
expect(skillsAfterSecondSync[0]).toMatchObject({
name: 'enrichment',
label: 'Enrichment',
description: 'Enrich contact data',
icon: 'IconSparkles',
content: '# Enrichment\n\nEnrich your data.',
});
}, 60000);
it('should update a skill when properties change in manifest on second sync', async () => {
await syncApplication({
manifest: buildManifest({
skills: [
{
universalIdentifier: TEST_SKILL_ID,
name: 'enrichment',
label: 'Enrichment',
description: 'Enrich contact data',
icon: 'IconSparkles',
content: '# Enrichment\n\nEnrich your data.',
},
],
}),
expectToFail: false,
});
const skillsAfterFirstSync = await findAppSkills();
expect(skillsAfterFirstSync).toHaveLength(1);
expect(skillsAfterFirstSync[0]).toMatchObject({
label: 'Enrichment',
description: 'Enrich contact data',
});
await syncApplication({
manifest: buildManifest({
skills: [
{
universalIdentifier: TEST_SKILL_ID,
name: 'enrichment',
label: 'Data Enrichment',
description: 'Enrich contact and company data',
icon: 'IconSparkles',
content:
'# Data Enrichment\n\nEnrich your contact and company data from multiple sources.',
},
],
}),
expectToFail: false,
});
const skillsAfterSecondSync = await findAppSkills();
expect(skillsAfterSecondSync).toHaveLength(1);
expect(skillsAfterSecondSync[0]).toMatchObject({
name: 'enrichment',
label: 'Data Enrichment',
description: 'Enrich contact and company data',
content:
'# Data Enrichment\n\nEnrich your contact and company data from multiple sources.',
});
}, 60000);
it('should delete a skill when removed from manifest on second sync', async () => {
await syncApplication({
manifest: buildManifest({
skills: [
{
universalIdentifier: TEST_SKILL_ID,
name: 'enrichment',
label: 'Enrichment',
description: 'Enrich contact data',
icon: 'IconSparkles',
content: '# Enrichment\n\nEnrich your data.',
},
{
universalIdentifier: TEST_SECOND_SKILL_ID,
name: 'scoring',
label: 'Lead Scoring',
description: 'Score your leads',
icon: 'IconChartBar',
content: '# Lead Scoring\n\nScore leads automatically.',
},
],
}),
expectToFail: false,
});
const skillsAfterFirstSync = await findAppSkills();
expect(skillsAfterFirstSync).toHaveLength(2);
expect(
skillsAfterFirstSync.find((s) => s.name === 'enrichment'),
).toBeDefined();
expect(
skillsAfterFirstSync.find((s) => s.name === 'scoring'),
).toBeDefined();
await syncApplication({
manifest: buildManifest({
skills: [
{
universalIdentifier: TEST_SKILL_ID,
name: 'enrichment',
label: 'Enrichment',
description: 'Enrich contact data',
icon: 'IconSparkles',
content: '# Enrichment\n\nEnrich your data.',
},
],
}),
expectToFail: false,
});
const skillsAfterSecondSync = await findAppSkills();
expect(skillsAfterSecondSync).toHaveLength(1);
expect(skillsAfterSecondSync[0]).toMatchObject({
name: 'enrichment',
label: 'Enrichment',
});
expect(
skillsAfterSecondSync.find((s) => s.name === 'scoring'),
).toBeUndefined();
}, 60000);
});