Files
twenty/packages/twenty-front/scripts/mock-data/generate-billing-plans.ts
T
Charles BochetandGitHub 9342b16aad Fix more tests 2 (#18293)
## Summary
- Migrate more hand-written test mocks to auto-generated data from a
real Twenty instance
- Add generators for views, billing plans, API keys; extend record
generator for workspace members, favorites, connected accounts, calendar
events
- Remove 9 hand-written mock files replaced by generated equivalents
- Update 16 test/story files to use generated data
- Fix WorkflowEditActionEmailBase story assertion to match configured
recipient email

## Test plan
- [x] Lint, typecheck, unit tests pass
- [ ] Storybook tests pass in CI
2026-02-27 23:11:56 +01:00

69 lines
1.5 KiB
TypeScript

/* eslint-disable no-console */
import { graphqlRequest, writeGeneratedFile } from './utils.js';
const LIST_PLANS_QUERY = `
query listPlans {
listPlans {
planKey
licensedProducts {
name
description
images
metadata {
productKey
planKey
priceUsageBased
}
... on BillingLicensedProduct {
prices {
stripePriceId
unitAmount
recurringInterval
priceUsageType
}
}
}
meteredProducts {
name
description
images
metadata {
productKey
planKey
priceUsageBased
}
... on BillingMeteredProduct {
prices {
priceUsageType
recurringInterval
stripePriceId
tiers {
flatAmount
unitAmount
upTo
}
}
}
}
}
}
`;
export const generateBillingPlans = async (token: string) => {
console.log('Fetching billing plans from /metadata ...');
const data = (await graphqlRequest('/metadata', LIST_PLANS_QUERY, token)) as {
listPlans: Record<string, unknown>[];
};
console.log(` Got ${data.listPlans.length} billing plans.`);
writeGeneratedFile(
'metadata/billing-plans/mock-billing-plans-data.ts',
'mockedBillingPlans',
'Record<string, unknown>',
'',
{ listPlans: data.listPlans },
);
};