Skip to content

Commit

Permalink
Test new behavior of scheduling binding
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienmaillard committed Sep 18, 2023
1 parent 86de6f9 commit 59f18bb
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion e2e-tests/src/tests/bindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,68 @@ test.describe.serial('Scheduler Bindings', () => {
reason: 'No mission model exists with id `MissionModelId[id=-1]`'
});

response = await request.post(`${urls.SCHEDULER_URL}/schedulingDslTypescript`, {
data: {
action: {name: "schedulingDslTypescript"},
input: {missionModelId: mission_model_id, planId:-1},
request_query: "",
session_variables: admin.session}});
expect(response.status()).toEqual(200);
expect(await response.json()).toEqual({
status: 'failure',
reason: 'No plan exists with id `PlanId[id=-1]`'
});

//verify that when inserting an external dataset, the resource is generated in the constraints edsl
await request.post(`${urls.MERLIN_URL}/addExternalDataset`, {
data: {
action: {name: "addExternalDataset"},
input: {
planId: plan_id,
datasetStart:'2021-001T06:00:00.000',
profileSet: {'/my_other_boolean':{schema:{type:'boolean'},segments:[{duration:3600000000,dynamics:true}],type:'discrete'}},
simulationDatasetId: null
},
request_query: "",
session_variables: admin.session}});

let resourceTypesWithExternalResource = `export type Resource = {
"/peel": number,
"/fruit": {initial: number, rate: number, },
"/data/line_count": number,
"/my_other_boolean": boolean,
"/flag/conflicted": boolean,
"/plant": number,
"/flag": ( | "A" | "B"),
"/producer": string,
};
`
response = await request.post(`${urls.SCHEDULER_URL}/schedulingDslTypescript`, {
data: {
action: {name: "schedulingDslTypescript"},
input: {missionModelId: mission_model_id, planId:plan_id},
request_query: "",
session_variables: admin.session}});
let respBody = await response.json();
let found = false;
for(let file of respBody.typescriptFiles){
if(file.filePath == "file:///mission-model-generated-code.ts"){
expect(file.content.includes(resourceTypesWithExternalResource)).toEqual(true);
found = true;
}
}
expect(found).toEqual(true);
expect(response.status()).toEqual(200);
expect(respBody.status).toEqual('success');

// Returns a 200 with a success status if the ID is valid
response = await request.post(`${urls.SCHEDULER_URL}/schedulingDslTypescript`, {
data: {
action: {name: "schedulingDslTypescript"},
input: {missionModelId: mission_model_id},
request_query: "",
session_variables: admin.session}});
let respBody = await response.json();
respBody = await response.json();
expect(response.status()).toEqual(200);
expect(respBody.status).toEqual('success');
expect(respBody.typescriptFiles).not.toBeNull();
Expand Down

0 comments on commit 59f18bb

Please sign in to comment.