@entifix/testing-e2e 0.11.0 → 0.12.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-infrastructure.d.ts","sourceRoot":"","sources":["../../src/fixtures/fake-infrastructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAsB,MAAM,eAAe,CAAC;AACnE,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,SAAS,EAIf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,EAAE,QAAQ;IACnD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;CACvC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,OAAM,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAM,KACnD,kBAAkB,CACnB,WAAW,EACX,cAAc,GAAG,gBAAgB,GAAG,yBAAyB,CAgC9D,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAMvE,CAAC;AAEF;;;;;;GAMG;AACH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;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAO,kBAAuB,KAC7B,KAAK,CAAC,KAAK,CAAC,0BAA0B,CAItC,CAAC"}
|
|
@@ -54,14 +54,21 @@ export const fakeRedisLayer = ()=>{
|
|
|
54
54
|
* type through a cast and then fail at the first `withChannel` call.
|
|
55
55
|
*/ export const fakeAmqpLayer = ()=>{
|
|
56
56
|
const channel = makeFakeAmqpChannel();
|
|
57
|
+
let stopped = false;
|
|
57
58
|
const connector = {
|
|
58
59
|
withChannel: (use)=>use(channel.channel),
|
|
59
60
|
addConsumer: async (setup)=>{
|
|
60
|
-
await setup(channel.channel
|
|
61
|
+
await setup(channel.channel, {
|
|
62
|
+
replaceTags: ()=>undefined,
|
|
63
|
+
cancelled: ()=>stopped
|
|
64
|
+
});
|
|
61
65
|
},
|
|
62
66
|
// The mock profile boots and closes services in-process, so the drain runs
|
|
63
|
-
// for real against this — it simply has one channel and no broker to tell
|
|
64
|
-
|
|
67
|
+
// for real against this — it simply has one channel and no broker to tell,
|
|
68
|
+
// and a consumer paused on a breaker is told not to resume.
|
|
69
|
+
cancelConsumers: async ()=>{
|
|
70
|
+
stopped = true;
|
|
71
|
+
}
|
|
65
72
|
};
|
|
66
73
|
return {
|
|
67
74
|
driver: channel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fixtures/fake-infrastructure.ts"],"sourcesContent":["import { AmqpChannelTag, type AmqpConnector } from '@entifix/amqp';\nimport {\n ConfigurationRepositoryTag,\n TenantDatabaseResolverTag,\n} from '@entifix/business';\nimport {\n ConfigurationClientInMemory,\n type ConfigurationPlain,\n} from '@entifix/core';\nimport { MongoClientTag, MongoDatabaseTag } from '@entifix/mongo';\nimport { RedisTag } from '@entifix/redis';\nimport {\n type FakeAmqpChannel,\n type FakeMongoDb,\n type FakeRedis,\n makeFakeAmqpChannel,\n makeFakeMongoDb,\n makeFakeRedis,\n} from '@entifix/testing-unit/drivers';\nimport { Effect, Layer } from 'effect';\n\nimport type { BackendRow } from './entity-backend.js';\n\n/**\n * The driver fakes, wired as the Layers a service's composition root provides.\n *\n * These stand in for the *connections*, one level below the adapters — so the\n * Mongo repository, the Redis lock and sequence services and the AMQP event bus\n * all still run their own code. Substituting at the port level instead would\n * leave the filter translation, the `SET NX PX` and the envelope framing\n * unexecuted while the suite reported the service as covered.\n *\n * Each helper returns the fake alongside its Layer, because a spec usually\n * wants both: the Layer to boot with, the fake to seed, inspect or break.\n *\n * The casts are `never` on purpose: it keeps this package free of the mongodb,\n * ioredis and amqplib type packages while staying honest that these are not\n * real drivers.\n */\n\n/**\n * A driver fake and the Layer that provides it. `TService` is the tag the Layer\n * satisfies, so `Effect.provide` actually discharges the requirement — typing\n * the Layer's output as `never` would leave every consumer still asking for it.\n */\nexport interface FakeInfrastructure<TDriver, TService> {\n readonly driver: TDriver;\n readonly layer: Layer.Layer<TService>;\n}\n\n/**\n * The Mongo fake, provided under all three tags a service may ask for: the\n * shared `Db`, the `MongoClient` (the pool), and the tenant resolver.\n *\n * Every organization resolves to the **same** in-memory store, which is the\n * honest mock of db-per-organization: there is one fake, so isolation is not\n * what this profile tests. That is deliberate — a `mock` run proves routing,\n * guards and query translation; only a live run against real Mongo can prove\n * that two organizations' collections actually live apart, and that is what the\n * `mongosh` check in the tenancy verification does.\n */\nexport const fakeMongoLayer = (\n seed: Record<string, ReadonlyArray<BackendRow>> = {},\n): FakeInfrastructure<\n FakeMongoDb,\n MongoClientTag | MongoDatabaseTag | TenantDatabaseResolverTag\n> => {\n const db = makeFakeMongoDb(\n Object.fromEntries(\n Object.entries(seed).map(([collection, rows]) => [\n collection,\n rows.map(row => ({ ...row })),\n ]),\n ),\n );\n\n return {\n driver: db,\n layer: Layer.mergeAll(\n Layer.succeed(MongoDatabaseTag, db.db as never),\n // `client.db(name)` ignores the name for the same reason.\n //\n // `startSession` is forwarded rather than stubbed: a service that writes\n // a row and folds it into a counter does both inside one transaction, so\n // a client without it fails at the first write with a `TypeError` — and\n // a stub that returned a no-op session would commit the two halves\n // independently, which is precisely the crash-between-them state the\n // transaction exists to rule out.\n Layer.succeed(MongoClientTag, {\n db: () => db.db,\n startSession: () => db.startSession(),\n } as never),\n Layer.succeed(TenantDatabaseResolverTag, {\n forOrganization: () => Effect.succeed(db.db),\n }),\n ),\n };\n};\n\nexport const fakeRedisLayer = (): FakeInfrastructure<FakeRedis, RedisTag> => {\n const redis = makeFakeRedis();\n return {\n driver: redis,\n layer: Layer.succeed(RedisTag, redis.redis as never),\n };\n};\n\n/**\n * The tag carries an `AmqpConnector`, not a channel — a held channel does not\n * survive the broker restarting, so the real adapter asks for one per call. The\n * fixture therefore has to supply that indirection rather than handing the fake\n * channel over directly: a layer that provided the channel would satisfy the\n * type through a cast and then fail at the first `withChannel` call.\n */\nexport const fakeAmqpLayer = (): FakeInfrastructure<\n FakeAmqpChannel,\n AmqpChannelTag\n> => {\n const channel = makeFakeAmqpChannel();\n const connector: AmqpConnector = {\n withChannel: use => use(channel.channel as never),\n addConsumer: async setup => {\n await setup(channel.channel as never);\n },\n // The mock profile boots and closes services in-process, so the drain runs\n // for real against this — it simply has one channel and no broker to tell.\n cancelConsumers: async () =>
|
|
1
|
+
{"version":3,"sources":["../../src/fixtures/fake-infrastructure.ts"],"sourcesContent":["import { AmqpChannelTag, type AmqpConnector } from '@entifix/amqp';\nimport {\n ConfigurationRepositoryTag,\n TenantDatabaseResolverTag,\n} from '@entifix/business';\nimport {\n ConfigurationClientInMemory,\n type ConfigurationPlain,\n} from '@entifix/core';\nimport { MongoClientTag, MongoDatabaseTag } from '@entifix/mongo';\nimport { RedisTag } from '@entifix/redis';\nimport {\n type FakeAmqpChannel,\n type FakeMongoDb,\n type FakeRedis,\n makeFakeAmqpChannel,\n makeFakeMongoDb,\n makeFakeRedis,\n} from '@entifix/testing-unit/drivers';\nimport { Effect, Layer } from 'effect';\n\nimport type { BackendRow } from './entity-backend.js';\n\n/**\n * The driver fakes, wired as the Layers a service's composition root provides.\n *\n * These stand in for the *connections*, one level below the adapters — so the\n * Mongo repository, the Redis lock and sequence services and the AMQP event bus\n * all still run their own code. Substituting at the port level instead would\n * leave the filter translation, the `SET NX PX` and the envelope framing\n * unexecuted while the suite reported the service as covered.\n *\n * Each helper returns the fake alongside its Layer, because a spec usually\n * wants both: the Layer to boot with, the fake to seed, inspect or break.\n *\n * The casts are `never` on purpose: it keeps this package free of the mongodb,\n * ioredis and amqplib type packages while staying honest that these are not\n * real drivers.\n */\n\n/**\n * A driver fake and the Layer that provides it. `TService` is the tag the Layer\n * satisfies, so `Effect.provide` actually discharges the requirement — typing\n * the Layer's output as `never` would leave every consumer still asking for it.\n */\nexport interface FakeInfrastructure<TDriver, TService> {\n readonly driver: TDriver;\n readonly layer: Layer.Layer<TService>;\n}\n\n/**\n * The Mongo fake, provided under all three tags a service may ask for: the\n * shared `Db`, the `MongoClient` (the pool), and the tenant resolver.\n *\n * Every organization resolves to the **same** in-memory store, which is the\n * honest mock of db-per-organization: there is one fake, so isolation is not\n * what this profile tests. That is deliberate — a `mock` run proves routing,\n * guards and query translation; only a live run against real Mongo can prove\n * that two organizations' collections actually live apart, and that is what the\n * `mongosh` check in the tenancy verification does.\n */\nexport const fakeMongoLayer = (\n seed: Record<string, ReadonlyArray<BackendRow>> = {},\n): FakeInfrastructure<\n FakeMongoDb,\n MongoClientTag | MongoDatabaseTag | TenantDatabaseResolverTag\n> => {\n const db = makeFakeMongoDb(\n Object.fromEntries(\n Object.entries(seed).map(([collection, rows]) => [\n collection,\n rows.map(row => ({ ...row })),\n ]),\n ),\n );\n\n return {\n driver: db,\n layer: Layer.mergeAll(\n Layer.succeed(MongoDatabaseTag, db.db as never),\n // `client.db(name)` ignores the name for the same reason.\n //\n // `startSession` is forwarded rather than stubbed: a service that writes\n // a row and folds it into a counter does both inside one transaction, so\n // a client without it fails at the first write with a `TypeError` — and\n // a stub that returned a no-op session would commit the two halves\n // independently, which is precisely the crash-between-them state the\n // transaction exists to rule out.\n Layer.succeed(MongoClientTag, {\n db: () => db.db,\n startSession: () => db.startSession(),\n } as never),\n Layer.succeed(TenantDatabaseResolverTag, {\n forOrganization: () => Effect.succeed(db.db),\n }),\n ),\n };\n};\n\nexport const fakeRedisLayer = (): FakeInfrastructure<FakeRedis, RedisTag> => {\n const redis = makeFakeRedis();\n return {\n driver: redis,\n layer: Layer.succeed(RedisTag, redis.redis as never),\n };\n};\n\n/**\n * The tag carries an `AmqpConnector`, not a channel — a held channel does not\n * survive the broker restarting, so the real adapter asks for one per call. The\n * fixture therefore has to supply that indirection rather than handing the fake\n * channel over directly: a layer that provided the channel would satisfy the\n * type through a cast and then fail at the first `withChannel` call.\n */\nexport const fakeAmqpLayer = (): FakeInfrastructure<\n FakeAmqpChannel,\n AmqpChannelTag\n> => {\n const channel = makeFakeAmqpChannel();\n let stopped = false;\n const connector: AmqpConnector = {\n withChannel: use => use(channel.channel as never),\n addConsumer: async setup => {\n await setup(channel.channel as never, {\n replaceTags: () => undefined,\n cancelled: () => stopped,\n });\n },\n // The mock profile boots and closes services in-process, so the drain runs\n // for real against this — it simply has one channel and no broker to tell,\n // and a consumer paused on a breaker is told not to resume.\n cancelConsumers: async () => {\n stopped = true;\n },\n };\n return {\n driver: channel,\n layer: Layer.succeed(AmqpChannelTag, connector),\n };\n};\n\n/**\n * The configuration a service would otherwise fetch from config-service at\n * boot, provided directly. The `mock` profile has no config-service, and going\n * through one would test the platform rather than the service under test.\n */\nexport const fakeConfigurationLayer = (\n plain: ConfigurationPlain = {},\n): Layer.Layer<ConfigurationRepositoryTag> =>\n Layer.succeed(\n ConfigurationRepositoryTag,\n new ConfigurationClientInMemory(plain),\n );\n"],"names":["AmqpChannelTag","ConfigurationRepositoryTag","TenantDatabaseResolverTag","ConfigurationClientInMemory","MongoClientTag","MongoDatabaseTag","RedisTag","makeFakeAmqpChannel","makeFakeMongoDb","makeFakeRedis","Effect","Layer","fakeMongoLayer","seed","db","Object","fromEntries","entries","map","collection","rows","row","driver","layer","mergeAll","succeed","startSession","forOrganization","fakeRedisLayer","redis","fakeAmqpLayer","channel","stopped","connector","withChannel","use","addConsumer","setup","replaceTags","undefined","cancelled","cancelConsumers","fakeConfigurationLayer","plain"],"mappings":";AAAA,SAASA,cAAc,QAA4B,gBAAgB;AACnE,SACEC,0BAA0B,EAC1BC,yBAAyB,QACpB,oBAAoB;AAC3B,SACEC,2BAA2B,QAEtB,gBAAgB;AACvB,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,iBAAiB;AAClE,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAIEC,mBAAmB,EACnBC,eAAe,EACfC,aAAa,QACR,gCAAgC;AACvC,SAASC,MAAM,EAAEC,KAAK,QAAQ,SAAS;AA+BvC;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,iBAAiB,CAC5BC,OAAkD,CAAC,CAAC;IAKpD,MAAMC,KAAKN,gBACTO,OAAOC,WAAW,CAChBD,OAAOE,OAAO,CAACJ,MAAMK,GAAG,CAAC,CAAC,CAACC,YAAYC,KAAK,GAAK;YAC/CD;YACAC,KAAKF,GAAG,CAACG,CAAAA,MAAQ,aAAKA;SACvB;IAIL,OAAO;QACLC,QAAQR;QACRS,OAAOZ,MAAMa,QAAQ,CACnBb,MAAMc,OAAO,CAACpB,kBAAkBS,GAAGA,EAAE,GACrC,0DAA0D;QAC1D,EAAE;QACF,yEAAyE;QACzE,yEAAyE;QACzE,wEAAwE;QACxE,mEAAmE;QACnE,qEAAqE;QACrE,kCAAkC;QAClCH,MAAMc,OAAO,CAACrB,gBAAgB;YAC5BU,IAAI,IAAMA,GAAGA,EAAE;YACfY,cAAc,IAAMZ,GAAGY,YAAY;QACrC,IACAf,MAAMc,OAAO,CAACvB,2BAA2B;YACvCyB,iBAAiB,IAAMjB,OAAOe,OAAO,CAACX,GAAGA,EAAE;QAC7C;IAEJ;AACF,EAAE;AAEF,OAAO,MAAMc,iBAAiB;IAC5B,MAAMC,QAAQpB;IACd,OAAO;QACLa,QAAQO;QACRN,OAAOZ,MAAMc,OAAO,CAACnB,UAAUuB,MAAMA,KAAK;IAC5C;AACF,EAAE;AAEF;;;;;;CAMC,GACD,OAAO,MAAMC,gBAAgB;IAI3B,MAAMC,UAAUxB;IAChB,IAAIyB,UAAU;IACd,MAAMC,YAA2B;QAC/BC,aAAaC,CAAAA,MAAOA,IAAIJ,QAAQA,OAAO;QACvCK,aAAa,OAAMC;YACjB,MAAMA,MAAMN,QAAQA,OAAO,EAAW;gBACpCO,aAAa,IAAMC;gBACnBC,WAAW,IAAMR;YACnB;QACF;QACA,2EAA2E;QAC3E,2EAA2E;QAC3E,4DAA4D;QAC5DS,iBAAiB;YACfT,UAAU;QACZ;IACF;IACA,OAAO;QACLV,QAAQS;QACRR,OAAOZ,MAAMc,OAAO,CAACzB,gBAAgBiC;IACvC;AACF,EAAE;AAEF;;;;CAIC,GACD,OAAO,MAAMS,yBAAyB,CACpCC,QAA4B,CAAC,CAAC,GAE9BhC,MAAMc,OAAO,CACXxB,4BACA,IAAIE,4BAA4BwC,QAChC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entifix/testing-e2e",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "End-to-end testing with one set of journeys and two profiles: mocked backends by default, real infrastructure on demand.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@swc/helpers": "0.5.23",
|
|
70
|
-
"@entifix/
|
|
71
|
-
"@entifix/
|
|
72
|
-
"@entifix/
|
|
70
|
+
"@entifix/core": "0.12.0",
|
|
71
|
+
"@entifix/business": "0.12.0",
|
|
72
|
+
"@entifix/testing-unit": "0.12.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@nx/devkit": ">=23 <24",
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
"msw": ">=3",
|
|
81
81
|
"@msw/playwright": ">=0.7",
|
|
82
82
|
"vitest": "*",
|
|
83
|
-
"@entifix/
|
|
84
|
-
"@entifix/
|
|
85
|
-
"@entifix/
|
|
83
|
+
"@entifix/amqp": "0.12.0",
|
|
84
|
+
"@entifix/mongo": "0.12.0",
|
|
85
|
+
"@entifix/redis": "0.12.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependenciesMeta": {
|
|
88
88
|
"@msw/playwright": {
|
|
@@ -120,8 +120,8 @@
|
|
|
120
120
|
"@nx/devkit": "23.3.0",
|
|
121
121
|
"@nx/playwright": "23.3.0",
|
|
122
122
|
"effect": "4.0.6",
|
|
123
|
-
"@entifix/amqp": "0.
|
|
124
|
-
"@entifix/mongo": "0.
|
|
125
|
-
"@entifix/redis": "0.
|
|
123
|
+
"@entifix/amqp": "0.12.0",
|
|
124
|
+
"@entifix/mongo": "0.12.0",
|
|
125
|
+
"@entifix/redis": "0.12.0"
|
|
126
126
|
}
|
|
127
127
|
}
|