Skip to content

Commit fbbff98

Browse files
committed
test
1 parent 1a385cc commit fbbff98

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

features/step_definitions/request_steps.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,30 @@ Given(/body from file "(.*)"/, function (this: World, filename: string) {
5151
Given(
5252
"request contains {string} parameter from {string}",
5353
function (this: World, parameterName: string, fixturePath: string) {
54-
this.opts[parameterName.toAttributeName()] = pathLookup(
55-
this.fixtures,
56-
fixturePath
57-
);
54+
const value = pathLookup(this.fixtures, fixturePath);
55+
this.opts[parameterName.toAttributeName()] = value;
56+
// Store in pathParameters for undo operations with naming variants
57+
this.pathParameters[parameterName] = value;
58+
this.pathParameters[parameterName.toAttributeName()] = value;
5859
}
5960
);
6061

6162
Given(
6263
/request contains "([^"]+)" parameter with value (.*)/,
6364
function (this: World, parameterName: string, value: string) {
64-
this.opts[parameterName.toAttributeName().toOperationName()] = JSON.parse(
65-
value.templated(this.fixtures)
66-
);
65+
const parsedValue = JSON.parse(value.templated(this.fixtures));
66+
const attrName = parameterName.toAttributeName().toOperationName();
67+
this.opts[attrName] = parsedValue;
68+
// Store in pathParameters for undo operations with naming variants
69+
this.pathParameters[parameterName] = parsedValue;
70+
this.pathParameters[attrName] = parsedValue;
6771
}
6872
);
6973

7074
Given("new {string} request", function (this: World, operationId: string) {
7175
this.operationId = operationId;
76+
this.opts = {};
77+
this.pathParameters = {}; // Clear path parameters for new request
7278
});
7379

7480
When("the request is sent", async function (this: World) {
@@ -155,7 +161,7 @@ When("the request is sent", async function (this: World) {
155161
this.operationId,
156162
this.response,
157163
this.opts,
158-
this.opts // Pass opts as pathParameters (contains all parameters including path ones)
164+
this.pathParameters
159165
)
160166
);
161167
}

features/support/given.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,25 @@ for (const apiVersion of Versions) {
8989
if (operation.parameters !== undefined) {
9090
for (const p of operation.parameters) {
9191
if (p.value !== undefined) {
92-
opts[p.name.toAttributeName()] = JSON.parse(
92+
const value = JSON.parse(
9393
p.value?.templated(this.fixtures),
9494
);
95+
opts[p.name.toAttributeName()] = value;
96+
97+
// Store in pathParameters for undo operations with naming variants
98+
this.pathParameters[p.name] = value;
99+
this.pathParameters[p.name.toAttributeName()] = value;
95100
}
96101
if (p.source !== undefined) {
97-
opts[p.name.toAttributeName()] = pathLookup(
102+
const value = pathLookup(
98103
this.fixtures,
99104
p.source
100105
);
106+
opts[p.name.toAttributeName()] = value;
107+
108+
// Store in pathParameters for undo operations with naming variants
109+
this.pathParameters[p.name] = value;
110+
this.pathParameters[p.name.toAttributeName()] = value;
101111
}
102112
if (p.origin === "request") {
103113
for (const key in opts[p.name]) {
@@ -140,7 +150,7 @@ for (const apiVersion of Versions) {
140150
// register undo method
141151
if (undoAction.undo.type == "unsafe") {
142152
this.undo.push(
143-
buildUndoFor(apiVersion, undoAction, operationName, result, opts)
153+
buildUndoFor(apiVersion, undoAction, operationName, result, opts, this.pathParameters)
144154
);
145155
}
146156

0 commit comments

Comments
 (0)