Skip to content

Commit 4b9e886

Browse files
committed
Add givenIdentifier for feature generation
1 parent 376f49c commit 4b9e886

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/be/cucumber.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// cucumber.js
22
let common = [
33
'features/**/*.feature', // Specify our feature files
4-
'--require-module ts-node/register', //typescript cucumber
5-
'--require-module tsconfig-paths/register', //typescript cucumber
4+
'--require-module ts-node/register', // typescript cucumber
5+
'--require-module tsconfig-paths/register', // typescript cucumber
66
'--require ./features/step_definitions/**/*.ts', // Load step definitions
7+
'--publish-quiet' // Remove publish message from output
78
].join(' ');
89

910
process.env['NODE_ENV'] = "test";

packages/cody/src/lib/hooks/behaviour-test-files/features/step_definitions/__feature__Steps.ts__tmpl__

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class <%= feature %>Steps {
3535

3636
let event = <%= givenEvent.propertyName %>(payload);
3737

38-
event = setMessageMetadata(event, AggregateMeta.ID, '<%= expectedIdentifier %>');
38+
event = setMessageMetadata(event, AggregateMeta.ID, '<%= givenIdentifier %>');
3939
event = setMessageMetadata(event, AggregateMeta.TYPE, '<%= givenAggregateMetaType %>');
4040
event = setMessageMetadata(event, AggregateMeta.VERSION, 1);
4141

packages/cody/src/lib/hooks/on-feature.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export const onFeature: CodyHook<Context> = async (feature: Node, ctx: Context)
109109
}
110110

111111
async function createTestFiles(featureName: string, featureMeta: any, givenNodes : Array<Node>, whenCommand : Node, thenNodes : Array<Node>, ctx: Context): Promise<string> {
112-
// if using a service from another board (e.g. Fleet Management), make sure to set this up in the test feature's metadata!
113112
const service = withErrorCheck(detectService, [whenCommand, ctx]);
114113

115114
let aggregate: Node | undefined;
@@ -136,11 +135,10 @@ async function createTestFiles(featureName: string, featureMeta: any, givenNodes
136135
const syncedAggregate = withErrorCheck(getNodeFromSyncedNodes, [aggregate, ctx.syncedNodes]);
137136
const aggregateState = withErrorCheck(findAggregateState, [syncedAggregate, ctx]);
138137
const aggregateStateMeta = withErrorCheck(getVoMetadata, [aggregateState, ctx]);
139-
const aggregateStateNames = names(aggregateState.getName());
138+
const givenNodeDescriptionObject = JSON.parse('{'+givenNode.getDescription().replaceAll('\'', '"')+'}');
140139

141140
const thenNode = thenNodes[0];
142141
const body = '{'+thenNode.getDescription().replaceAll('\'', '"')+'}';
143-
console.log('Json body: '+ body);
144142
const thenNodeDescriptionObject = JSON.parse(body);
145143

146144
const aggregateIdentifierProperty = aggregateStateMeta.identifier as keyof typeof thenNodeDescriptionObject;
@@ -156,6 +154,7 @@ async function createTestFiles(featureName: string, featureMeta: any, givenNodes
156154
"when": featureMeta[whenKey],
157155
"then": featureMeta[thenKey],
158156
"givenEvent": names(givenNode.getName()),
157+
"givenIdentifier": givenNodeDescriptionObject[aggregateIdentifierProperty],
159158
"givenAggregateMetaType": givenAggregateMetaType,
160159
"whenEvent": names(whenCommand.getName()),
161160
"thenEvent": names(thenNodes[0].getName()),
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!tsconfig.json

0 commit comments

Comments
 (0)