Add independent roast plan cloning from the plans table
Test and deploy / test-and-deploy (push) Successful in 1m52s
Test and deploy / test-and-deploy (push) Successful in 1m52s
This commit is contained in:
1 parent
393978195c
commit
a9358048ef
5 files changed
+46
-1
No files matched your search
@@ -89,3 +89,12 @@ test("summary search, filters and pagination exclude full telemetry and other ac
|
||||
0,
|
||||
);
|
||||
});
|
||||
|
||||
test('clone creates an independent owned plan without copying roast outcomes or consumption', async () => {
|
||||
const {app,agent}=await setup();const {csrf}=await signup(agent,'[email protected]');const other=request.agent(app);const {csrf:otherCsrf}=await signup(other,'[email protected]');
|
||||
const plan=blankPlan();plan.fields['0.1']='Burundi';plan.fields['4.1']='light';plan.temps.fc.tempC='190';plan.inventory={lotId:'lot',lotLabel:'Burundi lot',consumed:{weightG:500}};plan.afterRoast.cupNotes='Original cup';plan.planActual.fc.actualTime='8:20';
|
||||
const original=(await agent.post('/api/plans').set('x-csrf-token',csrf).send({plan,name:'Fruity'})).body.plan;
|
||||
const route='/api/plans/'+original.id+'/clone';assert.equal((await request(app).post(route)).status,401);assert.equal((await agent.post(route)).status,403);assert.equal((await other.post(route).set('x-csrf-token',otherCsrf)).status,404);assert.equal((await agent.post('/api/plans/not-a-uuid/clone').set('x-csrf-token',csrf)).status,404);
|
||||
const response=await agent.post(route).set('x-csrf-token',csrf);assert.equal(response.status,201);const copy=response.body.plan;assert.notEqual(copy.id,original.id);assert.equal(copy.name,'Fruity (copy)');assert.deepEqual(copy.plan.fields,plan.fields);assert.deepEqual(copy.plan.temps,plan.temps);assert.equal(copy.plan.inventory.lotId,'lot');assert.equal(copy.plan.inventory.consumed,null);assert.deepEqual(copy.plan.afterRoast,blankPlan().afterRoast);assert.deepEqual(copy.plan.planActual,blankPlan().planActual);
|
||||
copy.plan.fields['4.1']='medium';assert.equal((await agent.put('/api/plans/'+copy.id).set('x-csrf-token',csrf).send({plan:copy.plan})).status,200);assert.deepEqual((await agent.get('/api/plans/'+original.id)).body.plan.plan,plan);assert.equal((await other.get('/api/plans/'+copy.id)).status,404);
|
||||
});
|
||||
Reference in new issue
Block a user