| 
						
					 | 
					 | 
					@@ -10,9 +10,9 @@ import globals from '../globals';
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// TODO: write script for data import
 | 
					 | 
					 | 
					 | 
					// TODO: write script for data import
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// TODO: delete everything (measurements, condition) with sample
 | 
					 | 
					 | 
					 | 
					// TODO: delete everything (measurements, condition) with sample
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// TODO: allow adding sample numbers for existing samples
 | 
					 | 
					 | 
					 | 
					// TODO: allow adding sample numbers for existing samples
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// TODO: Do not allow validation or measurement entry without condition
 | 
					 | 
					 | 
					 | 
					// TODO: Do not allow validation or measurement entry without condition
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					// TODO: restore sample
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					describe('/sample', () => {
 | 
					 | 
					 | 
					 | 
					describe('/sample', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  let server;
 | 
					 | 
					 | 
					 | 
					  let server;
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -187,7 +187,6 @@ describe('/sample', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        res: {_id: '400000000000000000000003', number: '33', type: 'part', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', mineral: 0, glass_fiber: 33, carbon_fiber: 0, numbers: [{color: 'black', number: '5514262406'}]}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'granulate to sample'}], custom_fields: {'not allowed for new applications': true}}, user: 'admin'}
 | 
					 | 
					 | 
					 | 
					        res: {_id: '400000000000000000000003', number: '33', type: 'part', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', mineral: 0, glass_fiber: 33, carbon_fiber: 0, numbers: [{color: 'black', number: '5514262406'}]}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'granulate to sample'}], custom_fields: {'not allowed for new applications': true}}, user: 'admin'}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    });
 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    it('works with an API key', done => {
 | 
					 | 
					 | 
					 | 
					    it('works with an API key', done => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        method: 'get',
 | 
					 | 
					 | 
					 | 
					        method: 'get',
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -197,7 +196,6 @@ describe('/sample', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        res: {_id: '400000000000000000000003', number: '33', type: 'part', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', mineral: 0, glass_fiber: 33, carbon_fiber: 0, numbers: [{color: 'black', number: '5514262406'}]}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'granulate to sample'}], custom_fields: {'not allowed for new applications': true}}, user: 'admin'}
 | 
					 | 
					 | 
					 | 
					        res: {_id: '400000000000000000000003', number: '33', type: 'part', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', mineral: 0, glass_fiber: 33, carbon_fiber: 0, numbers: [{color: 'black', number: '5514262406'}]}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'granulate to sample'}], custom_fields: {'not allowed for new applications': true}}, user: 'admin'}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    });
 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    it('returns a deleted sample for a maintain/admin user', done => {
 | 
					 | 
					 | 
					 | 
					    it('returns a deleted sample for a maintain/admin user', done => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        method: 'get',
 | 
					 | 
					 | 
					 | 
					        method: 'get',
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -207,7 +205,6 @@ describe('/sample', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        res: {_id: '400000000000000000000005', number: 'Rng33', type: 'granulate', color: 'black', batch: '1653000308', condition: {condition_template: '200000000000000000000003'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', mineral: 0, glass_fiber: 33, carbon_fiber: 0, numbers: [{color: 'black', number: '5514262406'}]}, notes: {}, user: 'admin'}
 | 
					 | 
					 | 
					 | 
					        res: {_id: '400000000000000000000005', number: 'Rng33', type: 'granulate', color: 'black', batch: '1653000308', condition: {condition_template: '200000000000000000000003'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', mineral: 0, glass_fiber: 33, carbon_fiber: 0, numbers: [{color: 'black', number: '5514262406'}]}, notes: {}, user: 'admin'}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    });
 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    it('returns 403 for a write user when requesting a deleted sample', done => {
 | 
					 | 
					 | 
					 | 
					    it('returns 403 for a write user when requesting a deleted sample', done => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        method: 'get',
 | 
					 | 
					 | 
					 | 
					        method: 'get',
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -216,7 +213,6 @@ describe('/sample', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        httpStatus: 403
 | 
					 | 
					 | 
					 | 
					        httpStatus: 403
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    });
 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    it('returns 404 for an unknown sample', done => {
 | 
					 | 
					 | 
					 | 
					    it('returns 404 for an unknown sample', done => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        method: 'get',
 | 
					 | 
					 | 
					 | 
					        method: 'get',
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -225,7 +221,6 @@ describe('/sample', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        httpStatus: 404
 | 
					 | 
					 | 
					 | 
					        httpStatus: 404
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    });
 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    it('rejects an invalid id', done => {
 | 
					 | 
					 | 
					 | 
					    it('rejects an invalid id', done => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        method: 'get',
 | 
					 | 
					 | 
					 | 
					        method: 'get',
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -234,7 +229,6 @@ describe('/sample', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        httpStatus: 404
 | 
					 | 
					 | 
					 | 
					        httpStatus: 404
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    });
 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    it('rejects unauthorized requests', done => {
 | 
					 | 
					 | 
					 | 
					    it('rejects unauthorized requests', done => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        method: 'get',
 | 
					 | 
					 | 
					 | 
					        method: 'get',
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -589,6 +583,15 @@ describe('/sample', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        res: {status: 'Condition template not available'}
 | 
					 | 
					 | 
					 | 
					        res: {status: 'Condition template not available'}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    });
 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    it('rejects editing a deleted sample', done => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        method: 'put',
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        url: '/sample/400000000000000000000005',
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        auth: {basic: 'admin'},
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        httpStatus: 403,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        req: {}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    it('rejects an API key', done => {
 | 
					 | 
					 | 
					 | 
					    it('rejects an API key', done => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
					 | 
					 | 
					 | 
					      TestHelper.request(server, done, {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        method: 'put',
 | 
					 | 
					 | 
					 | 
					        method: 'put',
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					 
 |