@cosmicdrift/kumiko-testing 0.400.0 → 0.401.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-testing",
3
- "version": "0.400.0",
3
+ "version": "0.401.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": "MIT",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -103,9 +103,9 @@
103
103
  "kumiko-testing": "./bin/kumiko-testing.ts"
104
104
  },
105
105
  "dependencies": {
106
- "@cosmicdrift/kumiko-framework": "0.400.0",
107
- "@cosmicdrift/kumiko-guards": "0.400.0",
108
- "@cosmicdrift/kumiko-types": "0.400.0",
106
+ "@cosmicdrift/kumiko-framework": "0.401.0",
107
+ "@cosmicdrift/kumiko-guards": "0.401.0",
108
+ "@cosmicdrift/kumiko-types": "0.401.0",
109
109
  "zod": "^4.6.7"
110
110
  },
111
111
  "peerDependencies": {
@@ -129,8 +129,8 @@
129
129
  }
130
130
  },
131
131
  "devDependencies": {
132
- "@cosmicdrift/kumiko-bundled-features": "0.400.0",
133
- "@cosmicdrift/kumiko-dev-server": "0.400.0",
132
+ "@cosmicdrift/kumiko-bundled-features": "0.401.0",
133
+ "@cosmicdrift/kumiko-dev-server": "0.401.0",
134
134
  "@happy-dom/global-registrator": "^21.0.4",
135
135
  "@playwright/test": "^1.62.1",
136
136
  "@testing-library/dom": "^10.4.2",
package/src/changes.json CHANGED
@@ -1,4 +1,16 @@
1
1
  [
2
+ {
3
+ "version": "0.401.0",
4
+ "type": "fix",
5
+ "title": "drainJobs waits for consumer backlogs under row-level security",
6
+ "detail": "`stack.drainJobs()` compared every shared consumer's cursor with the event high-water mark, but read that mark through the tenant-enforced pool. With `rowLevelSecurity: \"on\"` (the default) the mark was 0, every consumer counted as caught up, and the drain resolved after two dispatcher batches (400 events). A test behind a longer backlog then saw event-triggered jobs that had not run yet, so its result depended on how many events earlier tests in the same file had written. The drain now reads through the same cross-tenant runner as `stack.db`."
7
+ },
8
+ {
9
+ "version": "0.401.0",
10
+ "type": "improvement",
11
+ "title": "dropTestDb drops a test database by name",
12
+ "detail": "`dropTestDb(baseUrl, dbName)` from `@cosmicdrift/kumiko-testing/stack` drops a database through an admin connection, for persistent databases made with `createTestDb({ persistent: true, dbName })`; the cleanup of `createTestDb` uses it too."
13
+ },
2
14
  {
3
15
  "version": "0.399.0",
4
16
  "type": "fix",
package/src/stack/db.ts CHANGED
@@ -172,22 +172,24 @@ export async function createTestDb(arg?: string | CreateTestDbOptions): Promise<
172
172
  cleanup: async () => {
173
173
  await conn.close();
174
174
  await outsideConn.close();
175
- if (!opts.persistent) {
176
- const admin2 = createDbConnection({
177
- url: adminUrl,
178
- maxConnections: 1,
179
- rowLevelSecurity: "off",
180
- });
181
- try {
182
- await dropDatabaseIfExists(admin2.db, dbName);
183
- } finally {
184
- await admin2.close();
185
- }
186
- }
175
+ if (!opts.persistent) await dropTestDb(url, dbName);
187
176
  },
188
177
  };
189
178
  }
190
179
 
180
+ export async function dropTestDb(baseUrl: string, dbName: string): Promise<void> {
181
+ const admin = createDbConnection({
182
+ url: adminUrlOf(baseUrl),
183
+ maxConnections: 1,
184
+ rowLevelSecurity: "off",
185
+ });
186
+ try {
187
+ await dropDatabaseIfExists(admin.db, dbName);
188
+ } finally {
189
+ await admin.close();
190
+ }
191
+ }
192
+
191
193
  const testDbTemplates = new Map<string, Promise<void>>();
192
194
 
193
195
  // One build per template and process; other workers of the run wait on the
@@ -19,6 +19,7 @@ export {
19
19
  type CreateTestDbOptions,
20
20
  createTestDb,
21
21
  DEFAULT_TEST_DB_POOL_MAX,
22
+ dropTestDb,
22
23
  TEST_APPLICATION_ROLE,
23
24
  type TestDb,
24
25
  } from "./db.ts";
@@ -623,12 +623,13 @@ function assembleTestStack(
623
623
  sessionCreator: options.authConfig.sessionCreator,
624
624
  }),
625
625
  });
626
+ // Test code and the drain see every tenant's rows; the services keep the enforced pool.
627
+ const crossTenantDb = testCodeDb(options, testDb.db);
626
628
  return {
627
629
  app: server.app,
628
630
  jwt: server.jwt,
629
631
  registry: services.registry,
630
- // Test code sees every tenant's rows; the services keep the enforced pool.
631
- db: testCodeDb(options, testDb.db),
632
+ db: crossTenantDb,
632
633
  unscopedDb: testDb.db,
633
634
  dbPoolMax: testDb.poolMax,
634
635
  redis: testRedis,
@@ -643,7 +644,8 @@ function assembleTestStack(
643
644
  ...(eventDispatcher ? { eventDispatcher } : {}),
644
645
  ...(server.lifecycle ? { lifecycle: server.lifecycle } : {}),
645
646
  ...(jobRunner ? { jobRunner } : {}),
646
- drainJobs: () => drainJobs({ db: testDb.db, eventDispatcher, jobRunner }, jobFailureTracker),
647
+ drainJobs: () =>
648
+ drainJobs({ db: crossTenantDb, eventDispatcher, jobRunner }, jobFailureTracker),
647
649
  cleanup: async () => {
648
650
  if (jobRunner) await jobRunner.stop();
649
651
  if (eventDispatcher) await eventDispatcher.stop();