Skip to content

Commit fcb99e8

Browse files
authored
fix: multiple fixes for xano script generation, test runner (#143)
2 parents 0927a2b + 08e491c commit fcb99e8

File tree

7 files changed

+42
-8
lines changed

7 files changed

+42
-8
lines changed

.changeset/dirty-buses-yell.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@calycode/core": patch
3+
"@calycode/cli": patch
4+
---
5+
6+
fix: fixing xanoscript generation command, by including the `include_xanoscript` in the metadata api request

.changeset/social-cows-cover.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@calycode/core": patch
3+
"@calycode/cli": patch
4+
---
5+
6+
chore: set the initial value on the backup wizard to false to prevent accidential backup execution

.changeset/sour-grapes-mate.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@calycode/core": patch
3+
"@calycode/cli": patch
4+
---
5+
6+
fix: fixing some aspects of the test runner that were causing failing jobs, wrong dynamic data population and header setting

packages/cli/src/commands/backups.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ async function restorationWizard({ instance, workspace, sourceBackup, forceConfi
7676
);
7777
const restorationConfirmation = await confirm({
7878
message: `You are about to restore "${instanceConfig.name} > ${workspaceConfig.name}" from backup "${backupFilePath}". Continue?`,
79+
initialValue: false,
7980
});
8081

8182
if (!restorationConfirmation) {

packages/core/src/features/testing/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,15 @@ async function testRunner({
118118
// Actually run the test based on config (support runtime values)
119119
for (const endpoint of testConfig) {
120120
const testStart = Date.now();
121-
122-
const { path, method, headers, queryParams, requestBody, store, customAsserts } = endpoint;
121+
const {
122+
path,
123+
method,
124+
headers = {},
125+
queryParams,
126+
requestBody,
127+
store,
128+
customAsserts,
129+
} = endpoint;
123130

124131
// Setup all asserts that are available for this endpoint
125132
const assertsToRun: AssertOptions[] = [];
@@ -157,12 +164,13 @@ async function testRunner({
157164
return param;
158165
}
159166
);
160-
const resolvedHeaders = replaceDynamicValues(headers, {
161-
...DEFAULT_HEADERS,
162-
...runtimeValues,
163-
});
167+
const resolvedHeaders = replaceDynamicValues(
168+
{ ...headers, ...DEFAULT_HEADERS },
169+
{
170+
...runtimeValues,
171+
}
172+
);
164173
const resolvedRequestBody = replaceDynamicValues(requestBody, runtimeValues);
165-
166174
const preparedRequest = prepareRequest({
167175
baseUrl: `${instanceConfig.url}/api:${group.canonical}`,
168176
path,

packages/core/src/implementations/build-xanoscript-repo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ async function fetchAndProcessEntities({
2222
path: path,
2323
query: {
2424
branch: branchLabel,
25+
include_xanoscript: true,
2526
page: 1,
2627
per_page: 500,
2728
sort: 'name',

packages/utils/src/methods/prepare-request.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ export function prepareRequest({
8888
// 6. Prepare body
8989
let preparedBody: string | undefined = undefined;
9090
if (body && typeof body === 'object' && Object.keys(body).length > 0) {
91-
preparedBody = JSON.stringify(mockFromSchema(body));
91+
if (body.type || body.properties || body.items) {
92+
// Looks like a schema
93+
preparedBody = JSON.stringify(mockFromSchema(body));
94+
} else {
95+
// Looks like actual data
96+
preparedBody = JSON.stringify(body);
97+
}
9298
}
9399

94100
return {

0 commit comments

Comments
 (0)