Skip to content

Commit

Permalink
Add givenIdentifier for feature generation
Browse files Browse the repository at this point in the history
  • Loading branch information
bofalke committed Mar 28, 2024
1 parent 376f49c commit 4b9e886
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/be/cucumber.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// cucumber.js
let common = [
'features/**/*.feature', // Specify our feature files
'--require-module ts-node/register', //typescript cucumber
'--require-module tsconfig-paths/register', //typescript cucumber
'--require-module ts-node/register', // typescript cucumber
'--require-module tsconfig-paths/register', // typescript cucumber
'--require ./features/step_definitions/**/*.ts', // Load step definitions
'--publish-quiet' // Remove publish message from output
].join(' ');

process.env['NODE_ENV'] = "test";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class <%= feature %>Steps {

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

event = setMessageMetadata(event, AggregateMeta.ID, '<%= expectedIdentifier %>');
event = setMessageMetadata(event, AggregateMeta.ID, '<%= givenIdentifier %>');
event = setMessageMetadata(event, AggregateMeta.TYPE, '<%= givenAggregateMetaType %>');
event = setMessageMetadata(event, AggregateMeta.VERSION, 1);

Expand Down
5 changes: 2 additions & 3 deletions packages/cody/src/lib/hooks/on-feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export const onFeature: CodyHook<Context> = async (feature: Node, ctx: Context)
}

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

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

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

const aggregateIdentifierProperty = aggregateStateMeta.identifier as keyof typeof thenNodeDescriptionObject;
Expand All @@ -156,6 +154,7 @@ async function createTestFiles(featureName: string, featureMeta: any, givenNodes
"when": featureMeta[whenKey],
"then": featureMeta[thenKey],
"givenEvent": names(givenNode.getName()),
"givenIdentifier": givenNodeDescriptionObject[aggregateIdentifierProperty],
"givenAggregateMetaType": givenAggregateMetaType,
"whenEvent": names(whenCommand.getName()),
"thenEvent": names(thenNodes[0].getName()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!tsconfig.json

0 comments on commit 4b9e886

Please sign in to comment.