Archived
2

implemented changelog

This commit is contained in:
VLE2FE
2020-06-05 08:50:06 +02:00
parent 74080d0902
commit ca29cef48c
33 changed files with 905 additions and 112 deletions

View File

@ -13,7 +13,6 @@ import mongoose from 'mongoose';
// TODO: write script for data import
// TODO: allow adding sample numbers for existing samples
describe('/sample', () => {
let server;
before(done => TestHelper.before(done));
@ -374,6 +373,22 @@ describe('/sample', () => {
});
});
});
it('creates a changelog', done => {
TestHelper.request(server, done, {
method: 'put',
url: '/sample/400000000000000000000001',
auth: {basic: 'janedoe'},
httpStatus: 200,
req: {type: 'part', color: 'signalviolet', batch: '114531', condition: {condition_template: '200000000000000000000003'}, material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
log: {
collection: 'samples',
dataAdd: {
status: 0
},
dataIgn: ['notes', 'note_id']
}
});
});
it('adjusts the note_fields correctly', done => {
TestHelper.request(server, done, {
method: 'put',
@ -707,6 +722,19 @@ describe('/sample', () => {
});
});
});
it('creates a changelog', done => {
TestHelper.request(server, done, {
method: 'delete',
url: '/sample/400000000000000000000001',
auth: {basic: 'janedoe'},
httpStatus: 200,
log: {
collection: 'samples',
skip: 1,
dataAdd: {status: -1}
}
});
});
it('keeps the notes of the sample', done => {
TestHelper.request(server, done, {
method: 'delete',
@ -867,6 +895,24 @@ describe('/sample', () => {
});
});
});
it('creates a changelog', done => {
TestHelper.request(server, done, {
method: 'put',
url: '/sample/restore/400000000000000000000005',
auth: {basic: 'admin'},
httpStatus: 200,
req: {},
log: {
collection: 'samples',
dataAdd: {
group_id: '900000000000000000000002',
supplier_id: '110000000000000000000002',
status: 0
},
dataIgn: ['group_id', 'supplier_id']
}
});
});
it('rejects an API key', done => {
TestHelper.request(server, done, {
method: 'put',
@ -922,6 +968,24 @@ describe('/sample', () => {
});
});
});
it('creates a changelog', done => {
TestHelper.request(server, done, {
method: 'put',
url: '/sample/validate/400000000000000000000003',
auth: {basic: 'admin'},
httpStatus: 200,
req: {},
log: {
collection: 'samples',
dataAdd: {
group_id: '900000000000000000000002',
supplier_id: '110000000000000000000002',
status: 10
},
dataIgn: ['group_id', 'supplier_id']
}
});
});
it('rejects validating a sample without condition', done => {
TestHelper.request(server, done, {
method: 'put',
@ -1038,6 +1102,24 @@ describe('/sample', () => {
})
});
});
it('creates a changelog', done => {
TestHelper.request(server, done, {
method: 'post',
url: '/sample/new',
auth: {basic: 'janedoe'},
httpStatus: 200,
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
log: {
collection: 'samples',
dataAdd: {
number: 'Rng37',
user_id: '000000000000000000000002',
status: 0
},
dataIgn: ['notes', 'note_id']
}
});
});
it('stores the custom fields', done => {
TestHelper.request(server, done, {
method: 'post',