@cosmicdrift/kumiko-testing 0.379.0 → 0.380.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/package.json +6 -6
- package/src/helpers/db-cleanup.ts +5 -19
- package/src/helpers/seed.ts +10 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.380.0",
|
|
4
4
|
"description": "Test template for Kumiko apps: per-flow seedTenant, app test stack, canonical test preloads, bunfig generator and integration runner.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
"kumiko-testing": "./bin/kumiko-testing.ts"
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
103
|
-
"@cosmicdrift/kumiko-guards": "0.
|
|
104
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
102
|
+
"@cosmicdrift/kumiko-framework": "0.380.0",
|
|
103
|
+
"@cosmicdrift/kumiko-guards": "0.380.0",
|
|
104
|
+
"@cosmicdrift/kumiko-types": "0.380.0",
|
|
105
105
|
"zod": "^4.4.3"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
@@ -125,8 +125,8 @@
|
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
|
-
"@cosmicdrift/kumiko-bundled-features": "0.
|
|
129
|
-
"@cosmicdrift/kumiko-dev-server": "0.
|
|
128
|
+
"@cosmicdrift/kumiko-bundled-features": "0.380.0",
|
|
129
|
+
"@cosmicdrift/kumiko-dev-server": "0.380.0",
|
|
130
130
|
"@happy-dom/global-registrator": "^20.11.2",
|
|
131
131
|
"@playwright/test": "^1.62.1",
|
|
132
132
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntityTableMeta } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
-
import { deleteMany } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import { deleteMany, requireEntityTableMeta } from "@cosmicdrift/kumiko-framework/db";
|
|
3
3
|
import type { AnyDb } from "@cosmicdrift/kumiko-framework/internal/stack-support";
|
|
4
4
|
import { withExecutorManagedWritesForTests } from "@cosmicdrift/kumiko-framework/internal/testing";
|
|
5
5
|
|
|
@@ -13,30 +13,16 @@ function tableFromName(name: string): EntityTableMeta {
|
|
|
13
13
|
return { tableName: name, columns: [], indexes: [], source: "unmanaged" };
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function resolveClearableTable(table: ClearableTable):
|
|
16
|
+
function resolveClearableTable(table: ClearableTable): EntityTableMeta {
|
|
17
17
|
if (typeof table === "string") return tableFromName(table);
|
|
18
|
-
|
|
19
|
-
typeof table === "object" &&
|
|
20
|
-
table !== null &&
|
|
21
|
-
"tableName" in table &&
|
|
22
|
-
typeof table.tableName === "string"
|
|
23
|
-
) {
|
|
24
|
-
return table;
|
|
25
|
-
}
|
|
26
|
-
return table;
|
|
18
|
+
return requireEntityTableMeta(table, "clearTables");
|
|
27
19
|
}
|
|
28
20
|
|
|
29
21
|
/** Delete all rows from each table (order preserved — FK-sensitive callers order explicitly). */
|
|
30
22
|
export async function clearTables(db: AnyDb, tables: readonly ClearableTable[]): Promise<void> {
|
|
31
23
|
for (const table of tables) {
|
|
32
|
-
// Test
|
|
33
|
-
|
|
34
|
-
// clearing a managed projection between tests is not a production write.
|
|
35
|
-
await deleteMany(
|
|
36
|
-
withExecutorManagedWritesForTests(db),
|
|
37
|
-
resolveClearableTable(table) as EntityTableMeta,
|
|
38
|
-
{},
|
|
39
|
-
);
|
|
24
|
+
// Test teardown: clearing a managed projection between tests is not a production write.
|
|
25
|
+
await deleteMany(withExecutorManagedWritesForTests(db), resolveClearableTable(table), {});
|
|
40
26
|
}
|
|
41
27
|
}
|
|
42
28
|
|
package/src/helpers/seed.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// Test-only ES-bypass: seed / mutate a managed projection directly, skipping
|
|
2
|
-
// the event log. Production code
|
|
3
|
-
//
|
|
4
|
-
// arrange a scenario without driving the full event path;
|
|
5
|
-
// is not part of the test lifecycle, so eventless writes
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// plain identifier rename.
|
|
2
|
+
// the event log. Production code cannot do this: the write helpers only accept
|
|
3
|
+
// a runner carrying the executor capability or a Writable table. Tests seed
|
|
4
|
+
// read-model state to arrange a scenario without driving the full event path;
|
|
5
|
+
// a projection rebuild is not part of the test lifecycle, so eventless writes
|
|
6
|
+
// are safe here. The signatures mirror the query helpers so a call-site
|
|
7
|
+
// migration is a plain identifier rename.
|
|
9
8
|
|
|
10
9
|
import type { EntityTable, EntityTableMeta } from "@cosmicdrift/kumiko-framework/db";
|
|
11
10
|
import {
|
|
@@ -25,7 +24,7 @@ export function seedRow<TRow = unknown>(
|
|
|
25
24
|
table: SeedTable,
|
|
26
25
|
values: Record<string, unknown>,
|
|
27
26
|
): Promise<TRow | undefined> {
|
|
28
|
-
return insertOne<TRow>(withExecutorManagedWritesForTests(db), table
|
|
27
|
+
return insertOne<TRow>(withExecutorManagedWritesForTests(db), table, values);
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
export function seedRows<TRow = unknown>(
|
|
@@ -33,7 +32,7 @@ export function seedRows<TRow = unknown>(
|
|
|
33
32
|
table: SeedTable,
|
|
34
33
|
rows: ReadonlyArray<Record<string, unknown>>,
|
|
35
34
|
): Promise<readonly TRow[]> {
|
|
36
|
-
return insertMany<TRow>(withExecutorManagedWritesForTests(db), table
|
|
35
|
+
return insertMany<TRow>(withExecutorManagedWritesForTests(db), table, rows);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export function updateRows<TRow = unknown>(
|
|
@@ -42,14 +41,9 @@ export function updateRows<TRow = unknown>(
|
|
|
42
41
|
set: Record<string, unknown>,
|
|
43
42
|
where: WhereObject,
|
|
44
43
|
): Promise<readonly TRow[]> {
|
|
45
|
-
return updateMany<TRow>(
|
|
46
|
-
withExecutorManagedWritesForTests(db),
|
|
47
|
-
table as EntityTableMeta,
|
|
48
|
-
set,
|
|
49
|
-
where,
|
|
50
|
-
);
|
|
44
|
+
return updateMany<TRow>(withExecutorManagedWritesForTests(db), table, set, where);
|
|
51
45
|
}
|
|
52
46
|
|
|
53
47
|
export function deleteRows(db: AnyDb, table: SeedTable, where: WhereObject): Promise<number> {
|
|
54
|
-
return deleteMany(withExecutorManagedWritesForTests(db), table
|
|
48
|
+
return deleteMany(withExecutorManagedWritesForTests(db), table, where);
|
|
55
49
|
}
|