NEO-48: fix Bruno pre-request baseUrl for branch_already_chosen
Use getEnvVar fallback and axios like other collection scripts; Invalid URL when baseUrl was undefined in pre-request.pull/83/head
parent
3ba8300652
commit
d5b65c94f6
|
|
@ -10,39 +10,40 @@ docs {
|
|||
}
|
||||
|
||||
script:pre-request {
|
||||
const baseUrl = bru.getVar("baseUrl");
|
||||
const grant = await bru.sendRequest({
|
||||
method: "POST",
|
||||
url: `${baseUrl}/game/players/dev-local-1/skill-progression`,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: {
|
||||
const axios = require("axios");
|
||||
const baseUrl = bru.getEnvVar("baseUrl") || bru.getVar("baseUrl");
|
||||
const playerId = bru.getEnvVar("playerId") || bru.getVar("playerId");
|
||||
const jsonHeaders = { headers: { "Content-Type": "application/json" } };
|
||||
const grant = await axios.post(
|
||||
`${baseUrl}/game/players/${playerId}/skill-progression`,
|
||||
{
|
||||
schemaVersion: 1,
|
||||
skillId: "salvage",
|
||||
amount: 100,
|
||||
sourceKind: "activity",
|
||||
},
|
||||
});
|
||||
jsonHeaders,
|
||||
);
|
||||
if (grant.status !== 200) {
|
||||
throw new Error(`salvage grant failed: ${grant.status}`);
|
||||
}
|
||||
const firstPick = await bru.sendRequest({
|
||||
method: "POST",
|
||||
url: `${baseUrl}/game/players/dev-local-1/perk-state`,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: {
|
||||
const firstPick = await axios.post(
|
||||
`${baseUrl}/game/players/${playerId}/perk-state`,
|
||||
{
|
||||
schemaVersion: 1,
|
||||
skillId: "salvage",
|
||||
tierIndex: 1,
|
||||
branchId: "scrap_efficiency",
|
||||
},
|
||||
});
|
||||
jsonHeaders,
|
||||
);
|
||||
if (firstPick.status !== 200 || firstPick.data?.selected !== true) {
|
||||
throw new Error(`tier-1 pick failed: ${firstPick.status} ${JSON.stringify(firstPick.data)}`);
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{baseUrl}}/game/players/dev-local-1/perk-state
|
||||
url: {{baseUrl}}/game/players/{{playerId}}/perk-state
|
||||
body: json
|
||||
auth: none
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue