fix: fix storybook coverage task (#5256)
- Fixes storybook coverage command: the coverage directory path was incorrect, but instead of failing `storybook:test --configuration=ci`, it was hanging indefinitely. - Switches back to `concurrently` to launch `storybook:static` and `storybook:test` in parallel, which allows to use options to explicitly kill `storybook:static` when `storybook:test` fails. - Moves `storybook:test --configuration=ci` to its own command `storybook:static:test`: used in the CI, and can be used locally to run storybook tests without having to launch `storybook:dev` first. - Creates command `storybook:coverage` and enables cache for this command. - Fixes Jest tests that were failing. - Improves caching conditions for some tasks (for instance, no need to invalidate Jest test cache if only Storybook story files were modified).
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
const globalCoverage = {
|
||||
branches: 45,
|
||||
statements: 60,
|
||||
lines: 60,
|
||||
functions: 60,
|
||||
@ -6,6 +7,7 @@ const globalCoverage = {
|
||||
};
|
||||
|
||||
const modulesCoverage = {
|
||||
branches: 45,
|
||||
statements: 70,
|
||||
lines: 70,
|
||||
functions: 65,
|
||||
@ -14,6 +16,7 @@ const modulesCoverage = {
|
||||
};
|
||||
|
||||
const pagesCoverage = {
|
||||
branches: 45,
|
||||
statements: 60,
|
||||
lines: 60,
|
||||
functions: 45,
|
||||
|
||||
@ -63,13 +63,12 @@
|
||||
"storybook:build:scope": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "STORYBOOK_SCOPE={args.scope} nx storybook:build twenty-front",
|
||||
"scope": "all"
|
||||
"command": "nx storybook:build twenty-front"
|
||||
},
|
||||
"configurations": {
|
||||
"docs": { "scope": "ui-docs" },
|
||||
"modules": { "scope": "modules" },
|
||||
"pages": { "scope": "pages" }
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
||||
}
|
||||
},
|
||||
"storybook:dev": {
|
||||
@ -78,13 +77,12 @@
|
||||
"storybook:dev:scope": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "STORYBOOK_SCOPE={args.scope} nx storybook:dev twenty-front",
|
||||
"scope": "all"
|
||||
"command": "nx storybook:dev twenty-front"
|
||||
},
|
||||
"configurations": {
|
||||
"docs": { "scope": "ui-docs" },
|
||||
"modules": { "scope": "modules" },
|
||||
"pages": { "scope": "pages" }
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
||||
}
|
||||
},
|
||||
"storybook:static": {
|
||||
@ -96,35 +94,39 @@
|
||||
"storybook:static:scope": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "STORYBOOK_SCOPE={args.scope} nx storybook:static twenty-front",
|
||||
"scope": "all"
|
||||
"command": "nx storybook:static twenty-front"
|
||||
},
|
||||
"configurations": {
|
||||
"docs": { "scope": "ui-docs" },
|
||||
"modules": { "scope": "modules" },
|
||||
"pages": { "scope": "pages" }
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
||||
}
|
||||
},
|
||||
"storybook:coverage": {
|
||||
"configurations": {
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
||||
}
|
||||
},
|
||||
"storybook:test": {
|
||||
"options": {
|
||||
"url": "http://localhost:6006",
|
||||
"port": 6006
|
||||
},
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"commands": [
|
||||
{
|
||||
"prefix": "[SB]",
|
||||
"command": "nx storybook:static {projectName} --port={args.port}",
|
||||
"forwardAllArgs": false
|
||||
},
|
||||
{
|
||||
"command": "STORYBOOK_SCOPE={args.scope} npx wait-on tcp:{args.port} && nx storybook:test {projectName}",
|
||||
"forwardAllArgs": false
|
||||
}
|
||||
],
|
||||
"parallel": true
|
||||
},
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
||||
}
|
||||
},
|
||||
"storybook:static:test": {
|
||||
"options": {
|
||||
"commands": [
|
||||
"npx concurrently --kill-others --success=first -n SB,TEST 'nx storybook:static {projectName} --port={args.port}' 'npx wait-on tcp:{args.port} && nx storybook:test {projectName} --port={args.port} --configuration={args.scope}'"
|
||||
],
|
||||
"port": 6006
|
||||
},
|
||||
"configurations": {
|
||||
"docs": { "scope": "ui-docs" },
|
||||
"modules": { "scope": "modules" },
|
||||
"pages": { "scope": "pages" }
|
||||
|
||||
@ -62,8 +62,8 @@ describe('generateCsv', () => {
|
||||
},
|
||||
];
|
||||
const csv = generateCsv({ columns, rows });
|
||||
expect(csv).toEqual(`Foo,Empty,Nested Foo,Nested Nested
|
||||
some field,,foo,nested`);
|
||||
expect(csv).toEqual(`Foo,Empty,Nested Foo,Nested Nested,Relation
|
||||
some field,,foo,nested,a relation`);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -36,14 +36,16 @@ export const generateCsv: GenerateExport = ({
|
||||
}: GenerateExportOptions): string => {
|
||||
const columnsToExport = columns.filter(
|
||||
(col) =>
|
||||
!('relationType' in col.metadata && col.metadata.relationType) ||
|
||||
!('relationType' in col.metadata) ||
|
||||
col.metadata.relationType === 'TO_ONE_OBJECT',
|
||||
);
|
||||
|
||||
const keys = columnsToExport.flatMap((col) => {
|
||||
const column = {
|
||||
field: `${col.metadata.fieldName}${col.type === 'RELATION' ? 'Id' : ''}`,
|
||||
title: `${col.label} ${col.type === 'RELATION' ? 'Id' : ''}`,
|
||||
title: [col.label, col.type === 'RELATION' ? 'Id' : null]
|
||||
.filter(isDefined)
|
||||
.join(' '),
|
||||
};
|
||||
|
||||
const fieldsWithSubFields = rows.find((row) => {
|
||||
|
||||
@ -2,6 +2,7 @@ import { useNavigate } from 'react-router-dom';
|
||||
import { Section } from '@react-email/components';
|
||||
|
||||
import { useDeleteOneDatabaseConnection } from '@/databases/hooks/useDeleteOneDatabaseConnection';
|
||||
import { SettingsIntegrationDatabaseConnectionSummaryCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSummaryCard';
|
||||
import { SettingsIntegrationDatabaseTablesListCard } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseTablesListCard';
|
||||
import { useDatabaseConnection } from '@/settings/integrations/database-connection/hooks/useDatabaseConnection';
|
||||
import { getConnectionDbName } from '@/settings/integrations/utils/getConnectionDbName';
|
||||
@ -9,7 +10,6 @@ import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
||||
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
||||
import { SettingsIntegrationDatabaseConnectionSummaryCard } from '~/pages/settings/integrations/SettingsIntegrationDatabaseConnectionSummaryCard';
|
||||
|
||||
export const SettingsIntegrationDatabaseConnectionShowContainer = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import {
|
||||
FieldMetadataType,
|
||||
ObjectEdge,
|
||||
ObjectMetadataItemsQuery,
|
||||
} from '~/generated-metadata/graphql';
|
||||
@ -3201,7 +3202,7 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
|
||||
node: {
|
||||
__typename: 'field',
|
||||
id: '7ada51cb-58be-42cd-86df-16c3f2bb8b58',
|
||||
type: 'TEXT',
|
||||
type: FieldMetadataType.Phone,
|
||||
name: 'phone',
|
||||
label: 'Phone',
|
||||
description: 'Contact’s phone number',
|
||||
|
||||
@ -11,11 +11,7 @@
|
||||
"generateBarrels": {
|
||||
"executor": "nx:run-commands",
|
||||
"cache": true,
|
||||
"inputs": [
|
||||
"{projectRoot}/src/**/*.{ts,tsx}",
|
||||
"!{projectRoot}/src/**/*.(spec|test).{ts,tsx}",
|
||||
"!{projectRoot}/src/**/*.stories.{ts,tsx}"
|
||||
],
|
||||
"inputs": ["production", "{projectRoot}/scripts/generateBarrels.js"],
|
||||
"outputs": ["{projectRoot}/src/index.ts", "{projectRoot}/src/*/index.ts"],
|
||||
"options": {
|
||||
"command": "node {projectRoot}/scripts/generateBarrels.js"
|
||||
@ -52,10 +48,12 @@
|
||||
"port": 6007
|
||||
}
|
||||
},
|
||||
"storybook:coverage": {},
|
||||
"storybook:test": {
|
||||
"options": {
|
||||
"url": "http://localhost:6007"
|
||||
}
|
||||
"options": { "port": 6007 }
|
||||
},
|
||||
"storybook:static:test": {
|
||||
"options": { "port": 6007 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user