ddd-ts-kit 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.fr.md +42 -7
- package/README.md +38 -6
- package/dist/check/canonical/stray-entry.d.ts +8 -0
- package/dist/check/canonical/stray-entry.d.ts.map +1 -0
- package/dist/check/canonical/stray-entry.js +75 -0
- package/dist/check/canonical/stray-entry.js.map +1 -0
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +2 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/catalogue/default-severities.d.ts.map +1 -1
- package/dist/check/catalogue/default-severities.js +1 -0
- package/dist/check/catalogue/default-severities.js.map +1 -1
- package/dist/check/explain/clean-docs.js +1 -1
- package/dist/check/explain/clean-docs.js.map +1 -1
- package/dist/check/explain/persistence-docs.js +1 -1
- package/dist/check/explain/persistence-docs.js.map +1 -1
- package/dist/check/explain/tree-docs.d.ts.map +1 -1
- package/dist/check/explain/tree-docs.js +5 -0
- package/dist/check/explain/tree-docs.js.map +1 -1
- package/dist/check/fixtures/clean-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/clean-fixtures.js +16 -0
- package/dist/check/fixtures/clean-fixtures.js.map +1 -1
- package/dist/check/fixtures/tree-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tree-fixtures.js +17 -0
- package/dist/check/fixtures/tree-fixtures.js.map +1 -1
- package/dist/check/migrations/drizzle-history-findings.js +1 -1
- package/dist/check/migrations/drizzle-history-findings.js.map +1 -1
- package/dist/check/rules/clean-function-size.js +10 -2
- package/dist/check/rules/clean-function-size.js.map +1 -1
- package/dist/check/rules/tree-closed.d.ts.map +1 -1
- package/dist/check/rules/tree-closed.js +4 -68
- package/dist/check/rules/tree-closed.js.map +1 -1
- package/dist/check/rules/tree-documented-paths.d.ts +3 -0
- package/dist/check/rules/tree-documented-paths.d.ts.map +1 -0
- package/dist/check/rules/tree-documented-paths.js +54 -0
- package/dist/check/rules/tree-documented-paths.js.map +1 -0
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +15 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/drizzle-generate.d.ts +6 -1
- package/dist/commands/drizzle-generate.d.ts.map +1 -1
- package/dist/commands/drizzle-generate.js +39 -6
- package/dist/commands/drizzle-generate.js.map +1 -1
- package/dist/commands/plan-waves.d.ts +9 -0
- package/dist/commands/plan-waves.d.ts.map +1 -0
- package/dist/commands/plan-waves.js +36 -0
- package/dist/commands/plan-waves.js.map +1 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +4 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/doctor/diagnose.d.ts +9 -0
- package/dist/doctor/diagnose.d.ts.map +1 -0
- package/dist/doctor/diagnose.js +34 -0
- package/dist/doctor/diagnose.js.map +1 -0
- package/dist/doctor/doctor-finding.d.ts +11 -0
- package/dist/doctor/doctor-finding.d.ts.map +1 -0
- package/dist/doctor/doctor-finding.js +2 -0
- package/dist/doctor/doctor-finding.js.map +1 -0
- package/dist/doctor/format-diagnosis.d.ts +4 -0
- package/dist/doctor/format-diagnosis.d.ts.map +1 -0
- package/dist/doctor/format-diagnosis.js +25 -0
- package/dist/doctor/format-diagnosis.js.map +1 -0
- package/dist/doctor/package-findings.d.ts +8 -0
- package/dist/doctor/package-findings.d.ts.map +1 -0
- package/dist/doctor/package-findings.js +21 -0
- package/dist/doctor/package-findings.js.map +1 -0
- package/dist/doctor/permission-findings.d.ts +5 -0
- package/dist/doctor/permission-findings.d.ts.map +1 -0
- package/dist/doctor/permission-findings.js +16 -0
- package/dist/doctor/permission-findings.js.map +1 -0
- package/dist/doctor/script-findings.d.ts +5 -0
- package/dist/doctor/script-findings.d.ts.map +1 -0
- package/dist/doctor/script-findings.js +12 -0
- package/dist/doctor/script-findings.js.map +1 -0
- package/dist/help/notes.d.ts +1 -1
- package/dist/help/notes.d.ts.map +1 -1
- package/dist/help/notes.js +25 -4
- package/dist/help/notes.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +3 -0
- package/dist/help/usage.js.map +1 -1
- package/dist/init/agent-permissions.d.ts +8 -0
- package/dist/init/agent-permissions.d.ts.map +1 -0
- package/dist/init/agent-permissions.js +55 -0
- package/dist/init/agent-permissions.js.map +1 -0
- package/dist/init/files/persistence-files.d.ts.map +1 -1
- package/dist/init/files/persistence-files.js +7 -1
- package/dist/init/files/persistence-files.js.map +1 -1
- package/dist/init/manifest/versions.js +24 -24
- package/dist/init/write-agent-settings.d.ts.map +1 -1
- package/dist/init/write-agent-settings.js +1 -54
- package/dist/init/write-agent-settings.js.map +1 -1
- package/dist/migration/branch-migration.d.ts +9 -0
- package/dist/migration/branch-migration.d.ts.map +1 -0
- package/dist/migration/branch-migration.js +2 -0
- package/dist/migration/branch-migration.js.map +1 -0
- package/dist/migration/branch-migrations.d.ts +16 -0
- package/dist/migration/branch-migrations.d.ts.map +1 -0
- package/dist/migration/branch-migrations.js +48 -0
- package/dist/migration/branch-migrations.js.map +1 -0
- package/dist/migration/delete-branch-migrations.d.ts +9 -0
- package/dist/migration/delete-branch-migrations.d.ts.map +1 -0
- package/dist/migration/delete-branch-migrations.js +23 -0
- package/dist/migration/delete-branch-migrations.js.map +1 -0
- package/dist/migration/drizzle-run.d.ts +7 -0
- package/dist/migration/drizzle-run.d.ts.map +1 -0
- package/dist/migration/drizzle-run.js +2 -0
- package/dist/migration/drizzle-run.js.map +1 -0
- package/dist/migration/drizzle-silent-failures.js +1 -1
- package/dist/migration/drizzle-silent-failures.js.map +1 -1
- package/dist/migration/find-project-formatter.d.ts +8 -0
- package/dist/migration/find-project-formatter.d.ts.map +1 -0
- package/dist/migration/find-project-formatter.js +52 -0
- package/dist/migration/find-project-formatter.js.map +1 -0
- package/dist/migration/format-written-files.d.ts +9 -0
- package/dist/migration/format-written-files.d.ts.map +1 -0
- package/dist/migration/format-written-files.js +32 -0
- package/dist/migration/format-written-files.js.map +1 -0
- package/dist/migration/generate-and-read.d.ts +6 -0
- package/dist/migration/generate-and-read.d.ts.map +1 -0
- package/dist/migration/generate-and-read.js +14 -0
- package/dist/migration/generate-and-read.js.map +1 -0
- package/dist/migration/index.d.ts +4 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +4 -0
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/known-primary-keys.d.ts +3 -0
- package/dist/migration/known-primary-keys.d.ts.map +1 -0
- package/dist/migration/known-primary-keys.js +2 -0
- package/dist/migration/known-primary-keys.js.map +1 -0
- package/dist/migration/migration-files.d.ts +7 -0
- package/dist/migration/migration-files.d.ts.map +1 -0
- package/dist/migration/migration-files.js +29 -0
- package/dist/migration/migration-files.js.map +1 -0
- package/dist/migration/plan-replay.d.ts +9 -0
- package/dist/migration/plan-replay.d.ts.map +1 -0
- package/dist/migration/plan-replay.js +68 -0
- package/dist/migration/plan-replay.js.map +1 -0
- package/dist/migration/previous-primary-keys.d.ts +9 -0
- package/dist/migration/previous-primary-keys.d.ts.map +1 -0
- package/dist/migration/previous-primary-keys.js +55 -0
- package/dist/migration/previous-primary-keys.js.map +1 -0
- package/dist/migration/primary-key-order-finding.d.ts +12 -0
- package/dist/migration/primary-key-order-finding.d.ts.map +1 -0
- package/dist/migration/primary-key-order-finding.js +2 -0
- package/dist/migration/primary-key-order-finding.js.map +1 -0
- package/dist/migration/primary-key-order-findings.d.ts +12 -0
- package/dist/migration/primary-key-order-findings.d.ts.map +1 -0
- package/dist/migration/primary-key-order-findings.js +55 -0
- package/dist/migration/primary-key-order-findings.js.map +1 -0
- package/dist/migration/project-formatter.d.ts +9 -0
- package/dist/migration/project-formatter.d.ts.map +1 -0
- package/dist/migration/project-formatter.js +2 -0
- package/dist/migration/project-formatter.js.map +1 -0
- package/dist/migration/replay-drizzle-migrations.d.ts +15 -0
- package/dist/migration/replay-drizzle-migrations.d.ts.map +1 -0
- package/dist/migration/replay-drizzle-migrations.js +63 -0
- package/dist/migration/replay-drizzle-migrations.js.map +1 -0
- package/dist/migration/replay-plan.d.ts +11 -0
- package/dist/migration/replay-plan.d.ts.map +1 -0
- package/dist/migration/replay-plan.js +2 -0
- package/dist/migration/replay-plan.js.map +1 -0
- package/dist/migration/replayed-name.d.ts +7 -0
- package/dist/migration/replayed-name.d.ts.map +1 -0
- package/dist/migration/replayed-name.js +12 -0
- package/dist/migration/replayed-name.js.map +1 -0
- package/dist/migration/sql-statement.d.ts +6 -0
- package/dist/migration/sql-statement.d.ts.map +1 -0
- package/dist/migration/sql-statement.js +2 -0
- package/dist/migration/sql-statement.js.map +1 -0
- package/dist/migration/sql-statements.d.ts +4 -0
- package/dist/migration/sql-statements.d.ts.map +1 -0
- package/dist/migration/sql-statements.js +36 -0
- package/dist/migration/sql-statements.js.map +1 -0
- package/dist/migration/table-change.d.ts +12 -0
- package/dist/migration/table-change.d.ts.map +1 -0
- package/dist/migration/table-change.js +2 -0
- package/dist/migration/table-change.js.map +1 -0
- package/dist/migration/table-changes.d.ts +9 -0
- package/dist/migration/table-changes.d.ts.map +1 -0
- package/dist/migration/table-changes.js +55 -0
- package/dist/migration/table-changes.js.map +1 -0
- package/dist/migration/tidy-written-migration.d.ts +5 -0
- package/dist/migration/tidy-written-migration.d.ts.map +1 -0
- package/dist/migration/tidy-written-migration.js +8 -0
- package/dist/migration/tidy-written-migration.js.map +1 -0
- package/dist/migration/wait-for-next-second.d.ts +6 -0
- package/dist/migration/wait-for-next-second.d.ts.map +1 -0
- package/dist/migration/wait-for-next-second.js +11 -0
- package/dist/migration/wait-for-next-second.js.map +1 -0
- package/dist/migration/warn-primary-key-order.d.ts +5 -0
- package/dist/migration/warn-primary-key-order.d.ts.map +1 -0
- package/dist/migration/warn-primary-key-order.js +16 -0
- package/dist/migration/warn-primary-key-order.js.map +1 -0
- package/dist/migration/written-migration.d.ts +9 -0
- package/dist/migration/written-migration.d.ts.map +1 -0
- package/dist/migration/written-migration.js +2 -0
- package/dist/migration/written-migration.js.map +1 -0
- package/dist/migration/written-paths.d.ts +3 -0
- package/dist/migration/written-paths.d.ts.map +1 -0
- package/dist/migration/written-paths.js +5 -0
- package/dist/migration/written-paths.js.map +1 -0
- package/dist/plan/aggregates-of.d.ts +6 -0
- package/dist/plan/aggregates-of.d.ts.map +1 -0
- package/dist/plan/aggregates-of.js +13 -0
- package/dist/plan/aggregates-of.js.map +1 -0
- package/dist/plan/batched-waves.d.ts +18 -0
- package/dist/plan/batched-waves.d.ts.map +1 -0
- package/dist/plan/batched-waves.js +73 -0
- package/dist/plan/batched-waves.js.map +1 -0
- package/dist/plan/cycles-of.d.ts +8 -0
- package/dist/plan/cycles-of.d.ts.map +1 -0
- package/dist/plan/cycles-of.js +30 -0
- package/dist/plan/cycles-of.js.map +1 -0
- package/dist/plan/format-plan.d.ts +4 -0
- package/dist/plan/format-plan.d.ts.map +1 -0
- package/dist/plan/format-plan.js +53 -0
- package/dist/plan/format-plan.js.map +1 -0
- package/dist/plan/merge-order.d.ts +8 -0
- package/dist/plan/merge-order.d.ts.map +1 -0
- package/dist/plan/merge-order.js +32 -0
- package/dist/plan/merge-order.js.map +1 -0
- package/dist/plan/plan-problems.d.ts +8 -0
- package/dist/plan/plan-problems.d.ts.map +1 -0
- package/dist/plan/plan-problems.js +57 -0
- package/dist/plan/plan-problems.js.map +1 -0
- package/dist/plan/plan-waves.d.ts +16 -0
- package/dist/plan/plan-waves.d.ts.map +1 -0
- package/dist/plan/plan-waves.js +23 -0
- package/dist/plan/plan-waves.js.map +1 -0
- package/dist/plan/rows-to-plan.d.ts +7 -0
- package/dist/plan/rows-to-plan.d.ts.map +1 -0
- package/dist/plan/rows-to-plan.js +19 -0
- package/dist/plan/rows-to-plan.js.map +1 -0
- package/dist/plan/wave-numbers.d.ts +8 -0
- package/dist/plan/wave-numbers.d.ts.map +1 -0
- package/dist/plan/wave-numbers.js +27 -0
- package/dist/plan/wave-numbers.js.map +1 -0
- package/dist/plan/wave-plan.d.ts +48 -0
- package/dist/plan/wave-plan.d.ts.map +1 -0
- package/dist/plan/wave-plan.js +2 -0
- package/dist/plan/wave-plan.js.map +1 -0
- package/dist/progress/format-progress.d.ts.map +1 -1
- package/dist/progress/format-progress.js +16 -1
- package/dist/progress/format-progress.js.map +1 -1
- package/dist/progress/progress.d.ts +11 -1
- package/dist/progress/progress.d.ts.map +1 -1
- package/dist/progress/read-progress.d.ts +6 -2
- package/dist/progress/read-progress.d.ts.map +1 -1
- package/dist/progress/read-progress.js +10 -5
- package/dist/progress/read-progress.js.map +1 -1
- package/dist/progress/status-row-of.d.ts +16 -0
- package/dist/progress/status-row-of.d.ts.map +1 -0
- package/dist/progress/status-row-of.js +23 -0
- package/dist/progress/status-row-of.js.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4 -0
- package/dist/run.js.map +1 -1
- package/dist/slice/changed-entries.d.ts +7 -0
- package/dist/slice/changed-entries.d.ts.map +1 -0
- package/dist/slice/changed-entries.js +20 -0
- package/dist/slice/changed-entries.js.map +1 -0
- package/dist/slice/changed-entry.d.ts +6 -0
- package/dist/slice/changed-entry.d.ts.map +1 -0
- package/dist/slice/changed-entry.js +2 -0
- package/dist/slice/changed-entry.js.map +1 -0
- package/dist/slice/format-slice-verification.d.ts.map +1 -1
- package/dist/slice/format-slice-verification.js +10 -0
- package/dist/slice/format-slice-verification.js.map +1 -1
- package/dist/slice/plan-staging.d.ts +13 -0
- package/dist/slice/plan-staging.d.ts.map +1 -0
- package/dist/slice/plan-staging.js +52 -0
- package/dist/slice/plan-staging.js.map +1 -0
- package/dist/slice/slice-verification.d.ts +3 -0
- package/dist/slice/slice-verification.d.ts.map +1 -1
- package/dist/slice/staging-plan.d.ts +6 -0
- package/dist/slice/staging-plan.d.ts.map +1 -0
- package/dist/slice/staging-plan.js +2 -0
- package/dist/slice/staging-plan.js.map +1 -0
- package/dist/slice/verify-slice.d.ts.map +1 -1
- package/dist/slice/verify-slice.js +3 -2
- package/dist/slice/verify-slice.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/briefing-of.js +1 -1
- package/dist/worker/briefing-of.js.map +1 -1
- package/dist/worker/rows-on-branches.d.ts +8 -0
- package/dist/worker/rows-on-branches.d.ts.map +1 -0
- package/dist/worker/rows-on-branches.js +9 -0
- package/dist/worker/rows-on-branches.js.map +1 -0
- package/package.json +2 -2
- package/templates/e2e/e2e.spec.ts.tpl +2 -2
- package/templates/init/e2e/start-application.database.ts.tpl +30 -1
- package/templates/init/e2e/start-application.memory.ts.tpl +30 -1
- package/templates/init/e2e/vitest.e2e.config.ts.tpl +4 -0
- package/templates/init/platform/database/open-test-database.drizzle.ts.tpl +18 -1
- package/templates/init/platform/database/open-test-database.knex.ts.tpl +18 -1
- package/templates/init/platform/database/open-test-database.prisma.ts.tpl +18 -1
- package/templates/init/platform/database/open-test-database.typeorm.ts.tpl +18 -1
- package/templates/init/platform/database/test-database-template.ts.tpl +23 -0
- package/templates/init/rules/tests.md.tpl +1 -1
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/pipeline/vitest.config.ts.tpl +6 -0
- package/dist/slice/paths-to-stage.d.ts +0 -6
- package/dist/slice/paths-to-stage.d.ts.map +0 -1
- package/dist/slice/paths-to-stage.js +0 -13
- package/dist/slice/paths-to-stage.js.map +0 -1
|
@@ -7,7 +7,7 @@ import { InMemoryCachePurger, PurgingPublisher, type IntegrationEventSubscriber
|
|
|
7
7
|
{{#unless httpCache.varnish}}
|
|
8
8
|
import type { IntegrationEventSubscriber } from '@ddd-ts-kit/kernel';
|
|
9
9
|
{{/unless}}
|
|
10
|
-
import { createHttpClient, type HttpClient } from '@ddd-ts-kit/testing/e2e';
|
|
10
|
+
import { createHttpClient, settled, type HttpClient, type SettledOptions } from '@ddd-ts-kit/testing/e2e';
|
|
11
11
|
{{#if authz.rebac}}
|
|
12
12
|
import { relationTuples } from '{{alias.platform}}/auth/relation-tuples{{alias.ext}}';
|
|
13
13
|
{{/if}}
|
|
@@ -60,6 +60,25 @@ export interface RunningApplication {
|
|
|
60
60
|
|
|
61
61
|
/** A client presenting the credential of `actor`; `client` itself presents none. */
|
|
62
62
|
as(actor: TestActor): Promise<HttpClient>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
{{#if events.outbox}}
|
|
66
|
+
* Resolves once the work the requests so far started has settled: every event stored in the
|
|
67
|
+
* outbox relayed, and the handlers it reached run, with what they stored in turn. Await it
|
|
68
|
+
* before asserting what happens after the answer, instead of waiting a fixed time; it fails
|
|
69
|
+
* after `timeoutMs` (2 seconds by default) naming what is still pending, and how much of it
|
|
70
|
+
* failed and waits for a retry (a handler that throws, an adapter that cannot be reached).
|
|
71
|
+
{{#if broker.provided}}
|
|
72
|
+
* With a broker server (its URL in the environment), relayed means handed to the broker: what
|
|
73
|
+
* its consumers do next is awaited with `collectEvents(application.events, [...]).waitFor(...)`.
|
|
74
|
+
{{/if}}
|
|
75
|
+
{{/if}}
|
|
76
|
+
{{#unless events.outbox}}
|
|
77
|
+
* Resolves once the work the requests so far started has settled. Without an outbox, events go
|
|
78
|
+
* out with the commit and their handlers are awaited before the answer: nothing is left then.
|
|
79
|
+
{{/unless}}
|
|
80
|
+
*/
|
|
81
|
+
settled(options?: SettledOptions): Promise<void>;
|
|
63
82
|
{{#if authz.rebac}}
|
|
64
83
|
|
|
65
84
|
/** Stores a relationship, as the application does when an element is created or shared. */
|
|
@@ -93,6 +112,7 @@ export async function startApplication(): Promise<RunningApplication> {
|
|
|
93
112
|
{{#if authz.rebac}}
|
|
94
113
|
relate: (tuple) => relationTuples.write([tuple]),
|
|
95
114
|
{{/if}}
|
|
115
|
+
settled: (options) => current.settled(options),
|
|
96
116
|
reset: async () => {
|
|
97
117
|
await current.close();
|
|
98
118
|
current = await start(credentials);
|
|
@@ -108,6 +128,8 @@ interface Started {
|
|
|
108
128
|
readonly purges: InMemoryCachePurger;
|
|
109
129
|
{{/if}}
|
|
110
130
|
|
|
131
|
+
settled(options?: SettledOptions): Promise<void>;
|
|
132
|
+
|
|
111
133
|
close(): Promise<void>;
|
|
112
134
|
}
|
|
113
135
|
|
|
@@ -155,6 +177,13 @@ async function start(credentials: Credentials): Promise<Started> {
|
|
|
155
177
|
{{#if httpCache.varnish}}
|
|
156
178
|
purges,
|
|
157
179
|
{{/if}}
|
|
180
|
+
{{#if events.outbox}}
|
|
181
|
+
settled: (options) => settled({ outbox: () => persistence.outbox.stats() }, options),
|
|
182
|
+
{{/if}}
|
|
183
|
+
{{#unless events.outbox}}
|
|
184
|
+
// Without an outbox nothing runs after the answer: the events went out with the commit.
|
|
185
|
+
settled: (options) => settled({}, options),
|
|
186
|
+
{{/unless}}
|
|
158
187
|
close: async () => {
|
|
159
188
|
await server.close();
|
|
160
189
|
{{#if events.outbox}}
|
|
@@ -19,6 +19,10 @@ export default defineConfig({
|
|
|
19
19
|
// Each file starts its own application; on a shared server (DATABASE_URL) they would
|
|
20
20
|
// empty each other's tables, so they run one after the other there.
|
|
21
21
|
fileParallelism: (process.env['DATABASE_URL'] ?? '') === '',
|
|
22
|
+
{{#if persistence.hasDatabase}}
|
|
23
|
+
// Initialises PostgreSQL in process once: each application starts on a copy of that cluster, and creates its tables there.
|
|
24
|
+
globalSetup: ['test/support/test-database-template.ts'],
|
|
25
|
+
{{/if}}
|
|
22
26
|
testTimeout: 20_000,
|
|
23
27
|
hookTimeout: 30_000,
|
|
24
28
|
},
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
{{#if tests.vitest}}
|
|
2
|
+
import { openAsBlob } from 'node:fs';
|
|
3
|
+
{{/if}}
|
|
1
4
|
import { PGlite } from '@electric-sql/pglite';
|
|
2
5
|
import { is, sql, SQL } from 'drizzle-orm';
|
|
3
6
|
import { getTableConfig, PgDialect, PgTable } from 'drizzle-orm/pg-core';
|
|
@@ -30,7 +33,7 @@ export function openTestDatabase(url?: string): Promise<TestDatabase> {
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
async function openInProcess(): Promise<TestDatabase> {
|
|
33
|
-
const client =
|
|
36
|
+
const client = await {{#if tests.vitest}}startedPostgres(){{/if}}{{#if tests.jest}}PGlite.create(){{/if}};
|
|
34
37
|
|
|
35
38
|
{{#if audit.on}}
|
|
36
39
|
for (const statement of [...tables().flatMap(createStatements), ...auditGuardStatements(schema.AUDIT_SCHEMA)]) {
|
|
@@ -52,6 +55,20 @@ async function openInProcess(): Promise<TestDatabase> {
|
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
|
|
58
|
+
{{#if tests.vitest}}
|
|
59
|
+
/**
|
|
60
|
+
* PostgreSQL in process: a copy of the cluster the global setup of the run initialised once
|
|
61
|
+
* (test/support/test-database-template.ts), which spares each spec the initdb of its own; without
|
|
62
|
+
* one (a run that names no global setup), a cluster initialised here. The tables are created on it
|
|
63
|
+
* by the caller, every time, as the first migration creates them.
|
|
64
|
+
*/
|
|
65
|
+
async function startedPostgres(): Promise<PGlite> {
|
|
66
|
+
const template = process.env['TEST_DATABASE_TEMPLATE'];
|
|
67
|
+
|
|
68
|
+
return PGlite.create(template === undefined ? {} : { loadDataDir: await openAsBlob(template) });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
{{/if}}
|
|
55
72
|
async function openServer(url: string): Promise<TestDatabase> {
|
|
56
73
|
const connection = connectToDatabase(url);
|
|
57
74
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
{{#if tests.vitest}}
|
|
2
|
+
import { openAsBlob } from 'node:fs';
|
|
3
|
+
{{/if}}
|
|
1
4
|
import { PGlite } from '@electric-sql/pglite';
|
|
2
5
|
import { PGLiteSocketServer } from '@electric-sql/pglite-socket';
|
|
3
6
|
import type { Knex } from 'knex';
|
|
@@ -30,7 +33,7 @@ export function openTestDatabase(url?: string): Promise<TestDatabase> {
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
async function openInProcess(): Promise<TestDatabase> {
|
|
33
|
-
const engine = await PGlite.create();
|
|
36
|
+
const engine = await {{#if tests.vitest}}startedPostgres(){{/if}}{{#if tests.jest}}PGlite.create(){{/if}};
|
|
34
37
|
const server = new PGLiteSocketServer({ db: engine, host: '127.0.0.1', port: 0, maxConnections: 10 });
|
|
35
38
|
|
|
36
39
|
await server.start();
|
|
@@ -51,6 +54,20 @@ async function openInProcess(): Promise<TestDatabase> {
|
|
|
51
54
|
return { persistence: persistenceOver(connection.db, close), reset: () => truncateAll(connection.db), close };
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
{{#if tests.vitest}}
|
|
58
|
+
/**
|
|
59
|
+
* PostgreSQL in process: a copy of the cluster the global setup of the run initialised once
|
|
60
|
+
* (test/support/test-database-template.ts), which spares each spec the initdb of its own; without
|
|
61
|
+
* one (a run that names no global setup), a cluster initialised here. The tables are created on it
|
|
62
|
+
* by the caller, every time, as the first migration creates them.
|
|
63
|
+
*/
|
|
64
|
+
async function startedPostgres(): Promise<PGlite> {
|
|
65
|
+
const template = process.env['TEST_DATABASE_TEMPLATE'];
|
|
66
|
+
|
|
67
|
+
return PGlite.create(template === undefined ? {} : { loadDataDir: await openAsBlob(template) });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
{{/if}}
|
|
54
71
|
async function openServer(url: string): Promise<TestDatabase> {
|
|
55
72
|
const connection = connectToDatabase(url);
|
|
56
73
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
{{#if tests.vitest}}
|
|
2
|
+
import { openAsBlob } from 'node:fs';
|
|
3
|
+
{{/if}}
|
|
1
4
|
import { readFile } from 'node:fs/promises';
|
|
2
5
|
import { PGlite } from '@electric-sql/pglite';
|
|
3
6
|
import { PGLiteSocketServer } from '@electric-sql/pglite-socket';
|
|
@@ -27,7 +30,7 @@ export function openTestDatabase(url?: string): Promise<TestDatabase> {
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
async function openInProcess(): Promise<TestDatabase> {
|
|
30
|
-
const engine = await PGlite.create();
|
|
33
|
+
const engine = await {{#if tests.vitest}}startedPostgres(){{/if}}{{#if tests.jest}}PGlite.create(){{/if}};
|
|
31
34
|
const server = new PGLiteSocketServer({ db: engine, host: '127.0.0.1', port: 0, maxConnections: 10 });
|
|
32
35
|
|
|
33
36
|
await server.start();
|
|
@@ -48,6 +51,20 @@ async function openInProcess(): Promise<TestDatabase> {
|
|
|
48
51
|
return { persistence: persistenceOver(client), reset: () => truncateAll(client), close };
|
|
49
52
|
}
|
|
50
53
|
|
|
54
|
+
{{#if tests.vitest}}
|
|
55
|
+
/**
|
|
56
|
+
* PostgreSQL in process: a copy of the cluster the global setup of the run initialised once
|
|
57
|
+
* (test/support/test-database-template.ts), which spares each spec the initdb of its own; without
|
|
58
|
+
* one (a run that names no global setup), a cluster initialised here. The tables are created on it
|
|
59
|
+
* by the caller, every time, as the first migration creates them.
|
|
60
|
+
*/
|
|
61
|
+
async function startedPostgres(): Promise<PGlite> {
|
|
62
|
+
const template = process.env['TEST_DATABASE_TEMPLATE'];
|
|
63
|
+
|
|
64
|
+
return PGlite.create(template === undefined ? {} : { loadDataDir: await openAsBlob(template) });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
{{/if}}
|
|
51
68
|
async function openServer(url: string): Promise<TestDatabase> {
|
|
52
69
|
const client = createClient(url);
|
|
53
70
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
{{#if tests.vitest}}
|
|
2
|
+
import { openAsBlob } from 'node:fs';
|
|
3
|
+
{{/if}}
|
|
1
4
|
import { PGlite } from '@electric-sql/pglite';
|
|
2
5
|
import { PGLiteSocketServer } from '@electric-sql/pglite-socket';
|
|
3
6
|
import type { DataSource } from 'typeorm';
|
|
@@ -24,7 +27,7 @@ export function openTestDatabase(url?: string): Promise<TestDatabase> {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
async function openInProcess(): Promise<TestDatabase> {
|
|
27
|
-
const engine = await PGlite.create();
|
|
30
|
+
const engine = await {{#if tests.vitest}}startedPostgres(){{/if}}{{#if tests.jest}}PGlite.create(){{/if}};
|
|
28
31
|
const server = new PGLiteSocketServer({ db: engine, host: '127.0.0.1', port: 0, maxConnections: 10 });
|
|
29
32
|
|
|
30
33
|
await server.start();
|
|
@@ -48,6 +51,20 @@ async function openInProcess(): Promise<TestDatabase> {
|
|
|
48
51
|
return { persistence, reset: () => truncateAll(dataSource), close };
|
|
49
52
|
}
|
|
50
53
|
|
|
54
|
+
{{#if tests.vitest}}
|
|
55
|
+
/**
|
|
56
|
+
* PostgreSQL in process: a copy of the cluster the global setup of the run initialised once
|
|
57
|
+
* (test/support/test-database-template.ts), which spares each spec the initdb of its own; without
|
|
58
|
+
* one (a run that names no global setup), a cluster initialised here. The tables are created on it
|
|
59
|
+
* by the caller, every time, as the first migration creates them.
|
|
60
|
+
*/
|
|
61
|
+
async function startedPostgres(): Promise<PGlite> {
|
|
62
|
+
const template = process.env['TEST_DATABASE_TEMPLATE'];
|
|
63
|
+
|
|
64
|
+
return PGlite.create(template === undefined ? {} : { loadDataDir: await openAsBlob(template) });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
{{/if}}
|
|
51
68
|
async function openServer(url: string): Promise<TestDatabase> {
|
|
52
69
|
const dataSource = createDataSource(url);
|
|
53
70
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { PGlite } from '@electric-sql/pglite';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The global setup of the test runs (vitest.config.ts, vitest.e2e.config.ts): starts PostgreSQL in
|
|
8
|
+
* process once and saves its initialised cluster to a file. Each spec of the run opens a copy of it
|
|
9
|
+
* (open-test-database.ts) instead of running an initdb of its own, the slow part of starting, then
|
|
10
|
+
* creates its tables there, so that what creates them stays run and measured in every spec. What it
|
|
11
|
+
* resolves is the teardown, which deletes the file.
|
|
12
|
+
*/
|
|
13
|
+
export async function setup(): Promise<() => Promise<void>> {
|
|
14
|
+
const directory = await mkdtemp(path.join(tmpdir(), 'test-database-'));
|
|
15
|
+
const file = path.join(directory, 'cluster.tar');
|
|
16
|
+
const engine = await PGlite.create();
|
|
17
|
+
|
|
18
|
+
await writeFile(file, new Uint8Array(await (await engine.dumpDataDir('none')).arrayBuffer()));
|
|
19
|
+
await engine.close();
|
|
20
|
+
process.env['TEST_DATABASE_TEMPLATE'] = file;
|
|
21
|
+
|
|
22
|
+
return () => rm(directory, { recursive: true, force: true });
|
|
23
|
+
}
|
|
@@ -23,5 +23,5 @@ paths:
|
|
|
23
23
|
- Coverage is a floor per context and layer, read from `coverage` in `ddd-ts-kit.config.json` and held by `npm run verify` (`npm run test:coverage`): a layer under its threshold gets the test that is missing. No `exclude` in the runner config, no `v8 ignore` or `istanbul ignore` comment without `-- ADR-NNNN: <reason>` (`test/coverage-governed`); a rate proves that code ran, never that a test asserts anything.
|
|
24
24
|
- An `it.todo` left by the generator names a behaviour still to prove: replace it by a real test, do not delete it. `npx ddd-ts-kit todo <context>` lists what remains.
|
|
25
25
|
- A test never asserts on a private field; it observes results, recorded events and what the fakes received.
|
|
26
|
-
- `test/e2e/` (project root) drives the whole application through HTTP with generated, seeded data, never reads the database, and asserts the trace of a request with `expectSpanTree(storyOf(trace), [...])`.
|
|
26
|
+
- `test/e2e/` (project root) drives the whole application through HTTP with generated, seeded data, never reads the database, and asserts the trace of a request with `expectSpanTree(storyOf(trace), [...])`. What happens after the answer (the outbox relayed, the handlers it reaches) is asserted once `await application.settled()` has resolved, never after a fixed delay.
|
|
27
27
|
- Write tests with `/ddd-ts-kit:testing`; scaffold with `npx ddd-ts-kit generate builder|e2e`.
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@biomejs/biome": "2.5.15",
|
|
24
24
|
"@commitlint/cli": "^21.2.3",
|
|
25
25
|
"@commitlint/config-conventional": "^21.2.3",
|
|
26
|
-
"@ddd-ts-kit/eslint-plugin": "^0.
|
|
26
|
+
"@ddd-ts-kit/eslint-plugin": "^0.24.0",
|
|
27
27
|
"@eslint/js": "^10.0.1",
|
|
28
28
|
"@typescript/native": "npm:typescript@~7.0.2",
|
|
29
29
|
"@vitest/coverage-v8": "5.0.3",
|
|
@@ -45,7 +45,13 @@ export default defineConfig(({ mode }) => ({
|
|
|
45
45
|
name: INTEGRATION_MODE,
|
|
46
46
|
include: [INTEGRATION_SPECS],
|
|
47
47
|
exclude: NOT_AFFECTED,
|
|
48
|
+
{{#if persistence.hasDatabase}}
|
|
49
|
+
globalSetup: ['test/support/test-database-template.ts'],
|
|
50
|
+
// A hook opens a copy of the PostgreSQL cluster the global setup initialised once per run and creates its tables, or reaches a server: under coverage on a busy machine it can outlast the default 10 seconds.
|
|
51
|
+
{{/if}}
|
|
52
|
+
{{#unless persistence.hasDatabase}}
|
|
48
53
|
// A hook opens the test database (PGlite started and its tables created, or a server reached): under coverage on a busy machine it outlasts the default 10 seconds.
|
|
54
|
+
{{/unless}}
|
|
49
55
|
hookTimeout: 60_000,
|
|
50
56
|
},
|
|
51
57
|
},
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The paths a slice leaves to commit, modified or new, as `git add <path>` takes them one by one;
|
|
3
|
-
* the kit's own working files (`.ddd-ts-kit/`) are left out.
|
|
4
|
-
*/
|
|
5
|
-
export declare function pathsToStage(root: string): string[];
|
|
6
|
-
//# sourceMappingURL=paths-to-stage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths-to-stage.d.ts","sourceRoot":"","sources":["../../src/slice/paths-to-stage.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAMnD"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { runGit } from '../commit/run-git.js';
|
|
2
|
-
/**
|
|
3
|
-
* The paths a slice leaves to commit, modified or new, as `git add <path>` takes them one by one;
|
|
4
|
-
* the kit's own working files (`.ddd-ts-kit/`) are left out.
|
|
5
|
-
*/
|
|
6
|
-
export function pathsToStage(root) {
|
|
7
|
-
return (runGit(root, ['status', '--porcelain', '--untracked-files=all']) ?? '')
|
|
8
|
-
.split('\n')
|
|
9
|
-
.filter((line) => line.length > 3)
|
|
10
|
-
.map((line) => line.slice(3).replace(/^.* -> /, ''))
|
|
11
|
-
.filter((file) => !file.startsWith('.ddd-ts-kit/'));
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=paths-to-stage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths-to-stage.js","sourceRoot":"","sources":["../../src/slice/paths-to-stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,uBAAuB,CAAC,CAAC,IAAI,EAAE,CAAC;SAC5E,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;SACnD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;AACxD,CAAC"}
|