Provide custom workspace id while seeding (#21721)

# Introduction
Currently working on e2e test ci that will iterate over dedicated twenty
instance.
In order to allow multi concurrent tests to be performed we need to
isolate testing context
Allowing to provide custom workspaceId allow easy isolation and post
test cleanup on aws related account

close https://github.com/twentyhq/core-team-issues/issues/2556

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/21721?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
This commit is contained in:
Paul Rastoin
2026-06-17 16:29:27 +02:00
committed by GitHub
parent 66c860574f
commit 60b559a659
10 changed files with 31 additions and 11 deletions
@@ -18,7 +18,10 @@ export type CreateWorkspaceInput = Pick<
(typeof WORKSPACE_FIELDS_TO_SEED)[number]
>;
export const SEED_APPLE_WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
const DEFAULT_SEED_APPLE_WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
export const SEED_APPLE_WORKSPACE_ID = (process.env.E2E_SEED_WORKSPACE_ID ??
DEFAULT_SEED_APPLE_WORKSPACE_ID) as typeof DEFAULT_SEED_APPLE_WORKSPACE_ID;
export const SEED_YCOMBINATOR_WORKSPACE_ID =
'3b8e6458-5fc1-4e63-8563-008ccddaa6db';
export const SEED_EMPTY_WORKSPACE_3_ID = '506915ec-21ca-431b-a04a-257eb216865e';
@@ -1,3 +1,5 @@
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
export type RandomUserData = {
id: string;
firstName: string;
@@ -523,7 +525,7 @@ export function generateRandomUsers(): {
userWorkspaces.push({
id: userWorkspaceId,
userId,
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419', // SEED_APPLE_WORKSPACE_ID
workspaceId: SEED_APPLE_WORKSPACE_ID,
});
workspaceMembers.push({
@@ -8,6 +8,7 @@ import {
import gql from 'graphql-tag';
import { OBJECT_RECORD_CREATED_EVENT } from 'src/engine/core-modules/event-logs/emit/events/object-event/object-record-created';
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
import { PERSON_GQL_FIELDS } from 'test/integration/constants/person-gql-fields.constants';
import { createManyOperationFactory } from 'test/integration/graphql/utils/create-many-operation-factory.util';
@@ -20,7 +21,7 @@ import { deleteAllRecords } from 'test/integration/utils/delete-all-records';
describe('Object event write (integration)', () => {
let clickHouseClient: ClickHouseClient;
let personObjectMetadataId: string;
const testWorkspaceId = '20202020-1c25-4d02-bf25-6aeccf7ea419';
const testWorkspaceId = SEED_APPLE_WORKSPACE_ID;
beforeAll(async () => {
jest.useRealTimers();
@@ -8,7 +8,9 @@ import * as tar from 'tar';
import { type DataSource } from 'typeorm';
import { uploadAppTarball } from 'test/integration/metadata/suites/application/utils/upload-app-tarball.util';
const TEST_WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
const TEST_WORKSPACE_ID = SEED_APPLE_WORKSPACE_ID;
const createTestTarball = async (
files: Record<string, string>,
@@ -9,8 +9,10 @@ import {
} from 'twenty-shared/testing';
import { v4 as uuidv4 } from 'uuid';
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
const TEST_APP_UID = uuidv4();
const TEST_WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
const TEST_WORKSPACE_ID = SEED_APPLE_WORKSPACE_ID;
const UNKNOWN_WORKSPACE_ID = uuidv4();
const UNKNOWN_APPLICATION_ID = uuidv4();
@@ -8,7 +8,9 @@ import * as tar from 'tar';
import { cleanupApplicationAndAppRegistration } from 'test/integration/metadata/suites/application/utils/cleanup-application-and-app-registration.util';
import { type DataSource } from 'typeorm';
const TEST_WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
const TEST_WORKSPACE_ID = SEED_APPLE_WORKSPACE_ID;
const MARKETPLACE_QUERY = `
query {
@@ -4,8 +4,10 @@ import { setupApplicationForSync } from 'test/integration/metadata/suites/applic
import { uploadApplicationFile } from 'test/integration/metadata/suites/application/utils/upload-application-file.util';
import { v4 as uuidv4 } from 'uuid';
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
const TEST_APP_UID = uuidv4();
const TEST_WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
const TEST_WORKSPACE_ID = SEED_APPLE_WORKSPACE_ID;
const PUBLIC_ASSET_PATH = 'assets/logo.svg';
const PUBLIC_ASSET_CONTENT = '<svg><circle r="10" /></svg>';
@@ -6,8 +6,10 @@ import { setupApplicationForSync } from 'test/integration/metadata/suites/applic
import { uploadApplicationFile } from 'test/integration/metadata/suites/application/utils/upload-application-file.util';
import { v4 as uuidv4 } from 'uuid';
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
const TEST_APP_ID = uuidv4();
const TEST_WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
const TEST_WORKSPACE_ID = SEED_APPLE_WORKSPACE_ID;
const STORAGE_LOCAL_PATH = join(process.cwd(), '.local-storage');
const MALICIOUS_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" onload="alert(1)">
@@ -2,7 +2,9 @@ import crypto from 'crypto';
import { uploadApplicationFile } from 'test/integration/metadata/suites/application/utils/upload-application-file.util';
const TEST_WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
const TEST_WORKSPACE_ID = SEED_APPLE_WORKSPACE_ID;
export const setupApplicationForSync = async ({
applicationUniversalIdentifier,
@@ -6,9 +6,11 @@ import { base64UrlEncode } from 'twenty-shared/utils';
import { type DataSource } from 'typeorm';
import { AppTokenType } from 'src/engine/core-modules/app-token/app-token.entity';
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
import { USER_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/core/utils/seed-users.util';
const TEST_WORKSPACE_ID = '20202020-1c25-4d02-bf25-6aeccf7ea419';
const TEST_USER_ID = '20202020-e6b5-4680-8a32-b8209737156b';
const TEST_WORKSPACE_ID = SEED_APPLE_WORKSPACE_ID;
const TEST_USER_ID = USER_DATA_SEED_IDS.JANE;
type TestRegistration = {
id: string;