Predefined seed data constants for testing and development. These constants provide consistent test data for organizations, users, projects, spaces, and groups.
const SEED_ORG_1: {
organization_uuid: string;
organization_name: string;
};
const SEED_ORG_2: {
organization_uuid: string;
organization_name: string;
};// Admin user
const SEED_ORG_1_ADMIN: {
user_uuid: string;
first_name: string;
last_name: string;
is_marketing_opted_in: boolean;
is_tracking_anonymized: boolean;
is_setup_complete: boolean;
is_active: boolean;
};
const SEED_ORG_1_ADMIN_EMAIL: {
email: string;
is_primary: boolean;
};
const SEED_ORG_1_ADMIN_PASSWORD: {
password: string;
};
const SEED_ORG_1_ADMIN_ROLE: OrganizationMemberRole;
// Editor user
const SEED_ORG_1_EDITOR: {
user_uuid: string;
first_name: string;
last_name: string;
is_marketing_opted_in: boolean;
is_tracking_anonymized: boolean;
is_setup_complete: boolean;
is_active: boolean;
};
const SEED_ORG_1_EDITOR_EMAIL: {
email: string;
is_primary: boolean;
};
const SEED_ORG_1_EDITOR_PASSWORD: {
password: string;
};
const SEED_ORG_1_EDITOR_ROLE: OrganizationMemberRole;
// Viewer user
const SEED_ORG_1_VIEWER: {
user_uuid: string;
first_name: string;
last_name: string;
is_marketing_opted_in: boolean;
is_tracking_anonymized: boolean;
is_setup_complete: boolean;
is_active: boolean;
};
const SEED_ORG_1_VIEWER_EMAIL: {
email: string;
is_primary: boolean;
};
const SEED_ORG_1_VIEWER_PASSWORD: {
password: string;
};
const SEED_ORG_1_VIEWER_ROLE: OrganizationMemberRole;const SEED_ORG_2_ADMIN: {
user_uuid: string;
first_name: string;
last_name: string;
is_marketing_opted_in: boolean;
is_tracking_anonymized: boolean;
is_setup_complete: boolean;
is_active: boolean;
};
const SEED_ORG_2_ADMIN_EMAIL: {
email: string;
is_primary: boolean;
};
const SEED_ORG_2_ADMIN_PASSWORD: {
password: string;
};
const SEED_ORG_2_ADMIN_ROLE: OrganizationMemberRole;const SEED_PROJECT: {
project_uuid: string;
name: string;
project_type: ProjectType;
dbt_connection_type: DbtProjectType;
dbt_connection: null;
copied_from_project_uuid: null;
organization_warehouse_credentials_uuid: null;
};
const SEED_SPACE: {
name: string;
};
const SEED_GROUP: {
groupUuid: string;
name: string;
};
const SEED_GROUP_2: {
groupUuid: string;
name: string;
};
const SEED_EMBED_SECRET: string;type TreeCreateSpace = CreateSpace & {
children?: TreeCreateSpace[];
groupAccess?: {
groupUuid: string;
role: SpaceMemberRole;
}[];
};
const SPACE_TREE_1: readonly TreeCreateSpace[];
const SPACE_TREE_2: readonly TreeCreateSpace[];The seed data contains these example values:
// Organization
SEED_ORG_1 = {
organization_uuid: '172a2270-000f-42be-9c68-c4752c23ae51',
organization_name: 'Jaffle Shop'
}
// Admin credentials
SEED_ORG_1_ADMIN_EMAIL.email = 'demo@lightdash.com'
SEED_ORG_1_ADMIN_PASSWORD.password = 'demo_password!'import {
SEED_ORG_1,
SEED_ORG_1_ADMIN,
SEED_ORG_1_ADMIN_EMAIL,
SEED_ORG_1_ADMIN_PASSWORD,
SEED_PROJECT,
SEED_SPACE,
SPACE_TREE_1,
} from '@lightdash/common';
// Use in tests
describe('Organization tests', () => {
it('should create organization with admin', () => {
const org = createOrganization({
uuid: SEED_ORG_1.organization_uuid,
name: SEED_ORG_1.organization_name,
});
const admin = createUser({
...SEED_ORG_1_ADMIN,
...SEED_ORG_1_ADMIN_EMAIL,
});
expect(org.uuid).toBe(SEED_ORG_1.organization_uuid);
expect(admin.user_uuid).toBe(SEED_ORG_1_ADMIN.user_uuid);
});
it('should create space hierarchy', () => {
const spaces = createSpaceTree(SEED_PROJECT.project_uuid, SPACE_TREE_1);
expect(spaces).toHaveLength(3); // 3 parent spaces
expect(spaces[0].children).toBeDefined();
});
});import {
SEED_ORG_1,
SEED_ORG_1_ADMIN,
SEED_ORG_1_ADMIN_EMAIL,
SEED_PROJECT,
SEED_SPACE,
SEED_GROUP,
SPACE_TREE_1,
} from '@lightdash/common';
// Use for development and seeding databases
async function seedDatabase() {
// Create organization
await db.insert(organizations).values(SEED_ORG_1);
// Create admin user
await db.insert(users).values({
...SEED_ORG_1_ADMIN,
email: SEED_ORG_1_ADMIN_EMAIL.email,
});
// Create project
await db.insert(projects).values(SEED_PROJECT);
// Create space hierarchy
for (const space of SPACE_TREE_1) {
await createSpaceTree(space);
}
}
// Alternative direct approach
async function seedDatabaseDirect() {
await createOrganization(SEED_ORG_1);
await createUser({
...SEED_ORG_1_ADMIN,
email: SEED_ORG_1_ADMIN_EMAIL.email,
});
await createProject({
...SEED_PROJECT,
organizationUuid: SEED_ORG_1.organization_uuid,
});
}import {
SEED_ORG_1,
SEED_ORG_2,
SEED_ORG_1_ADMIN,
SEED_ORG_2_ADMIN,
} from '@lightdash/common';
describe('Multi-organization tests', () => {
beforeEach(async () => {
// Setup two organizations
await createOrganization(SEED_ORG_1);
await createOrganization(SEED_ORG_2);
// Create admins for each
await createUser({
...SEED_ORG_1_ADMIN,
organizationUuid: SEED_ORG_1.organization_uuid,
});
await createUser({
...SEED_ORG_2_ADMIN,
organizationUuid: SEED_ORG_2.organization_uuid,
});
});
it('should isolate data between organizations', () => {
// Test cross-organization data isolation
});
});import {
SEED_ORG_1_ADMIN,
SEED_ORG_1_EDITOR,
SEED_ORG_1_VIEWER,
SEED_ORG_1_ADMIN_ROLE,
SEED_ORG_1_EDITOR_ROLE,
SEED_ORG_1_VIEWER_ROLE,
} from '@lightdash/common';
describe('Permission tests', () => {
it('should enforce admin permissions', async () => {
const admin = await createUser(SEED_ORG_1_ADMIN);
expect(admin.role).toBe(SEED_ORG_1_ADMIN_ROLE);
// Test admin-only operations
});
it('should enforce editor permissions', async () => {
const editor = await createUser(SEED_ORG_1_EDITOR);
expect(editor.role).toBe(SEED_ORG_1_EDITOR_ROLE);
// Test editor operations
});
it('should enforce viewer permissions', async () => {
const viewer = await createUser(SEED_ORG_1_VIEWER);
expect(viewer.role).toBe(SEED_ORG_1_VIEWER_ROLE);
// Test read-only operations
});
});import {
SEED_PROJECT,
SPACE_TREE_1,
SPACE_TREE_2,
} from '@lightdash/common';
describe('Space hierarchy tests', () => {
it('should create nested space structure', async () => {
const spaces = await createSpaceTree(
SEED_PROJECT.project_uuid,
SPACE_TREE_1
);
// Verify parent-child relationships
expect(spaces[0].children).toBeDefined();
expect(spaces[0].children.length).toBeGreaterThan(0);
});
it('should handle multiple space trees', async () => {
const tree1 = await createSpaceTree(
SEED_PROJECT.project_uuid,
SPACE_TREE_1
);
const tree2 = await createSpaceTree(
SEED_PROJECT.project_uuid,
SPACE_TREE_2
);
expect(tree1).not.toEqual(tree2);
});
});import {
SEED_ORG_1_ADMIN_EMAIL,
SEED_ORG_1_ADMIN_PASSWORD,
} from '@lightdash/common';
describe('Authentication tests', () => {
it('should authenticate with valid credentials', async () => {
const token = await authenticate(
SEED_ORG_1_ADMIN_EMAIL.email,
SEED_ORG_1_ADMIN_PASSWORD.password
);
expect(token).toBeDefined();
});
it('should reject invalid credentials', async () => {
await expect(
authenticate(
SEED_ORG_1_ADMIN_EMAIL.email,
'wrong_password'
)
).rejects.toThrow();
});
});constants.md for application-wide constants