## 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
41 lines
802 B
TypeScript
41 lines
802 B
TypeScript
/* eslint-disable no-console */
|
|
import { graphqlRequest, writeGeneratedFile } from './utils.js';
|
|
|
|
const API_KEYS_QUERY = `
|
|
query ApiKeys {
|
|
apiKeys {
|
|
__typename
|
|
id
|
|
name
|
|
expiresAt
|
|
createdAt
|
|
updatedAt
|
|
revokedAt
|
|
role {
|
|
__typename
|
|
id
|
|
label
|
|
icon
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
export const generateApiKeys = async (token: string) => {
|
|
console.log('Fetching API keys from /metadata ...');
|
|
|
|
const data = (await graphqlRequest('/metadata', API_KEYS_QUERY, token)) as {
|
|
apiKeys: Record<string, unknown>[];
|
|
};
|
|
|
|
console.log(` Got ${data.apiKeys.length} API keys.`);
|
|
|
|
writeGeneratedFile(
|
|
'metadata/api-keys/mock-api-keys-data.ts',
|
|
'mockedApiKeys',
|
|
'Record<string, unknown>[]',
|
|
'',
|
|
data.apiKeys,
|
|
);
|
|
};
|