@opentermsarchive/engine 0.26.1 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/bin/ota-track.js +3 -3
- package/bin/ota-validate.js +2 -2
- package/bin/ota.js +1 -1
- package/config/default.json +1 -1
- package/package.json +3 -4
- package/scripts/dataset/export/index.js +4 -4
- package/scripts/dataset/export/index.test.js +11 -17
- package/scripts/declarations/lint/index.mocha.js +1 -1
- package/scripts/declarations/utils/index.js +12 -12
- package/scripts/declarations/validate/definitions.js +1 -1
- package/scripts/declarations/validate/index.mocha.js +30 -34
- package/scripts/declarations/validate/service.history.schema.js +11 -11
- package/scripts/declarations/validate/service.schema.js +13 -13
- package/scripts/history/migrate-services.js +4 -4
- package/scripts/history/update-to-full-hash.js +2 -2
- package/scripts/import/index.js +14 -14
- package/scripts/rewrite/rewrite-snapshots.js +3 -3
- package/scripts/rewrite/rewrite-versions.js +14 -14
- package/scripts/utils/renamer/README.md +3 -3
- package/scripts/utils/renamer/index.js +13 -13
- package/src/archivist/errors.js +1 -1
- package/src/archivist/extract/exports.js +3 -0
- package/src/archivist/{filter → extract}/index.js +23 -27
- package/src/archivist/extract/index.test.js +516 -0
- package/src/archivist/index.js +101 -140
- package/src/archivist/index.test.js +178 -166
- package/src/archivist/recorder/index.js +11 -55
- package/src/archivist/recorder/index.test.js +310 -356
- package/src/archivist/recorder/record.js +18 -7
- package/src/archivist/recorder/repositories/git/dataMapper.js +41 -31
- package/src/archivist/recorder/repositories/git/index.js +11 -15
- package/src/archivist/recorder/repositories/git/index.test.js +1058 -463
- package/src/archivist/recorder/repositories/interface.js +8 -6
- package/src/archivist/recorder/repositories/mongo/dataMapper.js +21 -14
- package/src/archivist/recorder/repositories/mongo/index.js +8 -8
- package/src/archivist/recorder/repositories/mongo/index.test.js +898 -479
- package/src/archivist/recorder/snapshot.js +5 -0
- package/src/archivist/recorder/snapshot.test.js +65 -0
- package/src/archivist/recorder/version.js +14 -0
- package/src/archivist/recorder/version.test.js +65 -0
- package/src/archivist/services/index.js +60 -51
- package/src/archivist/services/index.test.js +63 -83
- package/src/archivist/services/service.js +26 -22
- package/src/archivist/services/service.test.js +46 -68
- package/src/archivist/services/{pageDeclaration.js → sourceDocument.js} +11 -9
- package/src/archivist/services/{pageDeclaration.test.js → sourceDocument.test.js} +21 -21
- package/src/archivist/services/terms.js +26 -0
- package/src/archivist/services/{documentDeclaration.test.js → terms.test.js} +15 -15
- package/src/exports.js +2 -2
- package/src/index.js +16 -13
- package/src/logger/index.js +35 -36
- package/src/notifier/index.js +8 -8
- package/src/tracker/index.js +6 -6
- package/src/archivist/filter/exports.js +0 -3
- package/src/archivist/filter/index.test.js +0 -564
- package/src/archivist/recorder/record.test.js +0 -91
- package/src/archivist/services/documentDeclaration.js +0 -26
- /package/scripts/utils/renamer/rules/{documentTypes.json → termsTypes.json} +0 -0
- /package/scripts/utils/renamer/rules/{documentTypesByService.json → termsTypesByService.json} +0 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import chai from 'chai';
|
|
2
2
|
import config from 'config';
|
|
3
3
|
|
|
4
|
+
import Snapshot from './snapshot.js';
|
|
5
|
+
import Version from './version.js';
|
|
6
|
+
|
|
4
7
|
import Recorder from './index.js';
|
|
5
8
|
|
|
6
9
|
const { expect } = chai;
|
|
@@ -29,432 +32,383 @@ describe('Recorder', () => {
|
|
|
29
32
|
|
|
30
33
|
after(async () => recorder.finalize());
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} catch (e) {
|
|
66
|
-
expect(e).to.be.an('error');
|
|
67
|
-
expect(e.message).to.contain(paramsNameToExpectedTextInError[testedRequiredParam]);
|
|
68
|
-
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
expect.fail('No error was thrown');
|
|
35
|
+
context('Snapshot', () => {
|
|
36
|
+
describe('#record', () => {
|
|
37
|
+
const CONTENT = '<html><h1>ToS fixture data with UTF-8 çhãràčtęrs</h1></html>';
|
|
38
|
+
|
|
39
|
+
let id;
|
|
40
|
+
let isFirstRecord;
|
|
41
|
+
let record;
|
|
42
|
+
|
|
43
|
+
context('when a required param is missing', () => {
|
|
44
|
+
after(async () => recorder.snapshotsRepository.removeAll());
|
|
45
|
+
|
|
46
|
+
Snapshot.REQUIRED_PARAMS.forEach(testedRequiredParam => {
|
|
47
|
+
context(`when "${testedRequiredParam}" is missing`, () => {
|
|
48
|
+
it('throws an error', async () => {
|
|
49
|
+
try {
|
|
50
|
+
const validParamsExceptTheOneTested = Snapshot.REQUIRED_PARAMS.filter(paramName => paramName != testedRequiredParam).reduce(
|
|
51
|
+
(accumulator, currentValue) => {
|
|
52
|
+
accumulator[currentValue] = 'non null value';
|
|
53
|
+
|
|
54
|
+
return accumulator;
|
|
55
|
+
},
|
|
56
|
+
{},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
await recorder.record(new Snapshot({ ...validParamsExceptTheOneTested }));
|
|
60
|
+
} catch (e) {
|
|
61
|
+
expect(e).to.be.an('error');
|
|
62
|
+
expect(e.message).to.contain(testedRequiredParam);
|
|
63
|
+
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
expect.fail('No error was thrown');
|
|
67
|
+
});
|
|
72
68
|
});
|
|
73
69
|
});
|
|
74
70
|
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
context('when it is the first record', () => {
|
|
78
|
-
before(async () => {
|
|
79
|
-
({ id, isFirstRecord } = await recorder.recordSnapshot({
|
|
80
|
-
serviceId: SERVICE_ID,
|
|
81
|
-
documentType: TYPE,
|
|
82
|
-
content: CONTENT,
|
|
83
|
-
mimeType: MIME_TYPE,
|
|
84
|
-
fetchDate: FETCH_DATE,
|
|
85
|
-
}));
|
|
86
|
-
|
|
87
|
-
record = await recorder.snapshotsRepository.findLatest(SERVICE_ID, TYPE);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
after(async () => recorder.snapshotsRepository.removeAll());
|
|
91
|
-
|
|
92
|
-
it('records the document with the proper content', async () => {
|
|
93
|
-
expect(await record.content).to.equal(CONTENT);
|
|
94
|
-
});
|
|
95
71
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
72
|
+
context('when it is the first record', () => {
|
|
73
|
+
before(async () => {
|
|
74
|
+
({ id, isFirstRecord } = await recorder.record(new Snapshot({
|
|
75
|
+
serviceId: SERVICE_ID,
|
|
76
|
+
termsType: TYPE,
|
|
77
|
+
content: CONTENT,
|
|
78
|
+
mimeType: MIME_TYPE,
|
|
79
|
+
fetchDate: FETCH_DATE,
|
|
80
|
+
})));
|
|
99
81
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
});
|
|
82
|
+
record = await recorder.snapshotsRepository.findLatest(SERVICE_ID, TYPE);
|
|
83
|
+
});
|
|
104
84
|
|
|
105
|
-
|
|
106
|
-
const UPDATED_CONTENT = '<html><h1>ToS fixture data with UTF-8 çhãràčtęrs</h1><h2>Updated!</h2></html>';
|
|
85
|
+
after(async () => recorder.snapshotsRepository.removeAll());
|
|
107
86
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
serviceId: SERVICE_ID,
|
|
111
|
-
documentType: TYPE,
|
|
112
|
-
content: CONTENT,
|
|
113
|
-
mimeType: MIME_TYPE,
|
|
114
|
-
fetchDate: FETCH_DATE,
|
|
87
|
+
it('records the snapshot with the proper content', async () => {
|
|
88
|
+
expect(await record.content).to.equal(CONTENT);
|
|
115
89
|
});
|
|
116
90
|
|
|
117
|
-
(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
content: UPDATED_CONTENT,
|
|
121
|
-
mimeType: MIME_TYPE,
|
|
122
|
-
fetchDate: FETCH_DATE_LATER,
|
|
123
|
-
}));
|
|
91
|
+
it('returns the record id', async () => {
|
|
92
|
+
expect(record.id).to.include(id);
|
|
93
|
+
});
|
|
124
94
|
|
|
125
|
-
|
|
95
|
+
it('states that it is the first record', async () => {
|
|
96
|
+
expect(isFirstRecord).to.be.true;
|
|
97
|
+
});
|
|
126
98
|
});
|
|
127
99
|
|
|
128
|
-
|
|
100
|
+
context('when it is not the first record', () => {
|
|
101
|
+
const UPDATED_CONTENT = '<html><h1>ToS fixture data with UTF-8 çhãràčtęrs</h1><h2>Updated!</h2></html>';
|
|
129
102
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
103
|
+
before(async () => {
|
|
104
|
+
await recorder.record(new Snapshot({
|
|
105
|
+
serviceId: SERVICE_ID,
|
|
106
|
+
termsType: TYPE,
|
|
107
|
+
content: CONTENT,
|
|
108
|
+
mimeType: MIME_TYPE,
|
|
109
|
+
fetchDate: FETCH_DATE,
|
|
110
|
+
}));
|
|
133
111
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
112
|
+
({ id, isFirstRecord } = await recorder.record(new Snapshot({
|
|
113
|
+
serviceId: SERVICE_ID,
|
|
114
|
+
termsType: TYPE,
|
|
115
|
+
content: UPDATED_CONTENT,
|
|
116
|
+
mimeType: MIME_TYPE,
|
|
117
|
+
fetchDate: FETCH_DATE_LATER,
|
|
118
|
+
})));
|
|
137
119
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
141
|
-
});
|
|
120
|
+
record = await recorder.snapshotsRepository.findLatest(SERVICE_ID, TYPE);
|
|
121
|
+
});
|
|
142
122
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
documentType: TYPE,
|
|
148
|
-
content: CONTENT,
|
|
149
|
-
mimeType: MIME_TYPE,
|
|
150
|
-
fetchDate: FETCH_DATE,
|
|
123
|
+
after(async () => recorder.snapshotsRepository.removeAll());
|
|
124
|
+
|
|
125
|
+
it('records the snapshot with the proper content', async () => {
|
|
126
|
+
expect(await record.content).to.equal(UPDATED_CONTENT);
|
|
151
127
|
});
|
|
152
128
|
|
|
153
|
-
(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
content: CONTENT,
|
|
157
|
-
mimeType: MIME_TYPE,
|
|
158
|
-
fetchDate: FETCH_DATE_LATER,
|
|
159
|
-
}));
|
|
129
|
+
it('returns the record id', async () => {
|
|
130
|
+
expect(record.id).to.include(id);
|
|
131
|
+
});
|
|
160
132
|
|
|
161
|
-
|
|
133
|
+
it('states that it is not the first record', async () => {
|
|
134
|
+
expect(isFirstRecord).to.be.false;
|
|
135
|
+
});
|
|
162
136
|
});
|
|
163
137
|
|
|
164
|
-
|
|
138
|
+
context('when the content has not changed', () => {
|
|
139
|
+
before(async () => {
|
|
140
|
+
await recorder.record(new Snapshot({
|
|
141
|
+
serviceId: SERVICE_ID,
|
|
142
|
+
termsType: TYPE,
|
|
143
|
+
content: CONTENT,
|
|
144
|
+
mimeType: MIME_TYPE,
|
|
145
|
+
fetchDate: FETCH_DATE,
|
|
146
|
+
}));
|
|
147
|
+
|
|
148
|
+
({ id, isFirstRecord } = await recorder.record(new Snapshot({
|
|
149
|
+
serviceId: SERVICE_ID,
|
|
150
|
+
termsType: TYPE,
|
|
151
|
+
content: CONTENT,
|
|
152
|
+
mimeType: MIME_TYPE,
|
|
153
|
+
fetchDate: FETCH_DATE_LATER,
|
|
154
|
+
})));
|
|
155
|
+
|
|
156
|
+
record = await recorder.snapshotsRepository.findLatest(SERVICE_ID, TYPE);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
after(async () => recorder.snapshotsRepository.removeAll());
|
|
165
160
|
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
it('does not record the snapshot', async () => {
|
|
162
|
+
expect(id).to.not.be.ok;
|
|
163
|
+
});
|
|
168
164
|
});
|
|
169
165
|
});
|
|
170
166
|
});
|
|
171
167
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
} catch (e) {
|
|
207
|
-
expect(e).to.be.an('error');
|
|
208
|
-
expect(e.message).to.contain(paramsNameToExpectedTextInError[testedRequiredParam]);
|
|
209
|
-
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
expect.fail('No error was thrown');
|
|
168
|
+
context('Version', () => {
|
|
169
|
+
describe('#record', () => {
|
|
170
|
+
const CONTENT = '# ToS fixture data with UTF-8 çhãràčtęrs';
|
|
171
|
+
const SNAPSHOT_ID = '61af86dc5ff5caa74ae926ad';
|
|
172
|
+
|
|
173
|
+
let id;
|
|
174
|
+
let isFirstRecord;
|
|
175
|
+
let record;
|
|
176
|
+
|
|
177
|
+
context('when a required param is missing', () => {
|
|
178
|
+
after(async () => recorder.versionsRepository.removeAll());
|
|
179
|
+
|
|
180
|
+
Version.REQUIRED_PARAMS.forEach(testedRequiredParam => {
|
|
181
|
+
context(`when "${testedRequiredParam}" is missing`, () => {
|
|
182
|
+
it('throws an error', async () => {
|
|
183
|
+
try {
|
|
184
|
+
const validParamsExceptTheOneTested = Version.REQUIRED_PARAMS.filter(paramName => paramName != testedRequiredParam).reduce(
|
|
185
|
+
(accumulator, currentValue) => {
|
|
186
|
+
accumulator[currentValue] = 'no null value';
|
|
187
|
+
|
|
188
|
+
return accumulator;
|
|
189
|
+
},
|
|
190
|
+
{},
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
await recorder.record(new Version({ ...validParamsExceptTheOneTested }));
|
|
194
|
+
} catch (e) {
|
|
195
|
+
expect(e).to.be.an('error');
|
|
196
|
+
expect(e.message).to.contain(testedRequiredParam);
|
|
197
|
+
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
expect.fail('No error was thrown');
|
|
201
|
+
});
|
|
213
202
|
});
|
|
214
203
|
});
|
|
215
204
|
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
context('when it is the first record', () => {
|
|
219
|
-
before(async () => {
|
|
220
|
-
({ id, isFirstRecord } = await recorder.recordVersion({
|
|
221
|
-
serviceId: SERVICE_ID,
|
|
222
|
-
documentType: TYPE,
|
|
223
|
-
content: CONTENT,
|
|
224
|
-
snapshotIds: [SNAPSHOT_ID],
|
|
225
|
-
fetchDate: FETCH_DATE,
|
|
226
|
-
}));
|
|
227
|
-
|
|
228
|
-
record = await recorder.versionsRepository.findLatest(SERVICE_ID, TYPE);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
after(async () => recorder.versionsRepository.removeAll());
|
|
232
|
-
|
|
233
|
-
it('records the document with the proper content', async () => {
|
|
234
|
-
expect(await record.content).to.equal(CONTENT);
|
|
235
|
-
});
|
|
236
205
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
206
|
+
context('when it is the first record', () => {
|
|
207
|
+
before(async () => {
|
|
208
|
+
({ id, isFirstRecord } = await recorder.record(new Version({
|
|
209
|
+
serviceId: SERVICE_ID,
|
|
210
|
+
termsType: TYPE,
|
|
211
|
+
content: CONTENT,
|
|
212
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
213
|
+
fetchDate: FETCH_DATE,
|
|
214
|
+
})));
|
|
240
215
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
244
|
-
});
|
|
216
|
+
record = await recorder.versionsRepository.findLatest(SERVICE_ID, TYPE);
|
|
217
|
+
});
|
|
245
218
|
|
|
246
|
-
|
|
247
|
-
const UPDATED_CONTENT = '<html><h1>ToS fixture data with UTF-8 çhãràčtęrs</h1><h2>Updated!</h2></html>';
|
|
219
|
+
after(async () => recorder.versionsRepository.removeAll());
|
|
248
220
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
serviceId: SERVICE_ID,
|
|
252
|
-
documentType: TYPE,
|
|
253
|
-
content: CONTENT,
|
|
254
|
-
snapshotIds: [SNAPSHOT_ID],
|
|
255
|
-
fetchDate: FETCH_DATE,
|
|
221
|
+
it('records the version with the proper content', async () => {
|
|
222
|
+
expect(await record.content).to.equal(CONTENT);
|
|
256
223
|
});
|
|
257
224
|
|
|
258
|
-
(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
content: UPDATED_CONTENT,
|
|
262
|
-
snapshotIds: [SNAPSHOT_ID],
|
|
263
|
-
fetchDate: FETCH_DATE_LATER,
|
|
264
|
-
}));
|
|
225
|
+
it('returns the record id', async () => {
|
|
226
|
+
expect(record.id).to.include(id);
|
|
227
|
+
});
|
|
265
228
|
|
|
266
|
-
|
|
229
|
+
it('states that it is the first record', async () => {
|
|
230
|
+
expect(isFirstRecord).to.be.true;
|
|
231
|
+
});
|
|
267
232
|
});
|
|
268
233
|
|
|
269
|
-
|
|
234
|
+
context('when it is not the first record', () => {
|
|
235
|
+
const UPDATED_CONTENT = '<html><h1>ToS fixture data with UTF-8 çhãràčtęrs</h1><h2>Updated!</h2></html>';
|
|
270
236
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
237
|
+
before(async () => {
|
|
238
|
+
await recorder.record(new Version({
|
|
239
|
+
serviceId: SERVICE_ID,
|
|
240
|
+
termsType: TYPE,
|
|
241
|
+
content: CONTENT,
|
|
242
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
243
|
+
fetchDate: FETCH_DATE,
|
|
244
|
+
}));
|
|
274
245
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
246
|
+
({ id, isFirstRecord } = await recorder.record(new Version({
|
|
247
|
+
serviceId: SERVICE_ID,
|
|
248
|
+
termsType: TYPE,
|
|
249
|
+
content: UPDATED_CONTENT,
|
|
250
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
251
|
+
fetchDate: FETCH_DATE_LATER,
|
|
252
|
+
})));
|
|
278
253
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
});
|
|
254
|
+
record = await recorder.versionsRepository.findLatest(SERVICE_ID, TYPE);
|
|
255
|
+
});
|
|
282
256
|
|
|
283
|
-
|
|
284
|
-
expect(isFirstRecord).to.be.false;
|
|
285
|
-
});
|
|
286
|
-
});
|
|
257
|
+
after(async () => recorder.versionsRepository.removeAll());
|
|
287
258
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
await recorder.recordVersion({
|
|
291
|
-
serviceId: SERVICE_ID,
|
|
292
|
-
documentType: TYPE,
|
|
293
|
-
content: CONTENT,
|
|
294
|
-
snapshotIds: [SNAPSHOT_ID],
|
|
295
|
-
fetchDate: FETCH_DATE,
|
|
259
|
+
it('records the version with the proper content', async () => {
|
|
260
|
+
expect(await record.content).to.equal(UPDATED_CONTENT);
|
|
296
261
|
});
|
|
297
262
|
|
|
298
|
-
(
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
content: CONTENT,
|
|
302
|
-
snapshotIds: [SNAPSHOT_ID],
|
|
303
|
-
fetchDate: FETCH_DATE_LATER,
|
|
304
|
-
}));
|
|
305
|
-
|
|
306
|
-
record = await recorder.versionsRepository.findLatest(SERVICE_ID, TYPE);
|
|
307
|
-
});
|
|
263
|
+
it('records in the version that it is not an extracted only version', async () => {
|
|
264
|
+
expect(record.isExtractOnly).to.equal(false);
|
|
265
|
+
});
|
|
308
266
|
|
|
309
|
-
|
|
267
|
+
it('returns the record id', async () => {
|
|
268
|
+
expect(record.id).to.include(id);
|
|
269
|
+
});
|
|
310
270
|
|
|
311
|
-
|
|
312
|
-
|
|
271
|
+
it('states that it is not the first record', async () => {
|
|
272
|
+
expect(isFirstRecord).to.be.false;
|
|
273
|
+
});
|
|
313
274
|
});
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
275
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const paramsNameToExpectedTextInError = {
|
|
337
|
-
serviceId: 'service ID',
|
|
338
|
-
documentType: 'terms type',
|
|
339
|
-
snapshotIds: 'snapshot ID',
|
|
340
|
-
fetchDate: 'fetch date',
|
|
341
|
-
content: 'content',
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
Object.entries(validParams).forEach(([testedRequiredParam]) => {
|
|
345
|
-
context(`when "${testedRequiredParam}" is missing`, () => {
|
|
346
|
-
it('throws an error', async () => {
|
|
347
|
-
try {
|
|
348
|
-
const validParamsExceptTheOneTested = Object.fromEntries(Object.entries(validParams).filter(([paramName]) => paramName != testedRequiredParam));
|
|
349
|
-
|
|
350
|
-
await recorder.recordRefilter(validParamsExceptTheOneTested);
|
|
351
|
-
} catch (e) {
|
|
352
|
-
expect(e).to.be.an('error');
|
|
353
|
-
expect(e.message).to.contain(paramsNameToExpectedTextInError[testedRequiredParam]);
|
|
354
|
-
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
expect.fail('No error was thrown');
|
|
358
|
-
});
|
|
276
|
+
context('when the content has not changed', () => {
|
|
277
|
+
before(async () => {
|
|
278
|
+
await recorder.record(new Version({
|
|
279
|
+
serviceId: SERVICE_ID,
|
|
280
|
+
termsType: TYPE,
|
|
281
|
+
content: CONTENT,
|
|
282
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
283
|
+
fetchDate: FETCH_DATE,
|
|
284
|
+
}));
|
|
285
|
+
|
|
286
|
+
({ id, isFirstRecord } = await recorder.record(new Version({
|
|
287
|
+
serviceId: SERVICE_ID,
|
|
288
|
+
termsType: TYPE,
|
|
289
|
+
content: CONTENT,
|
|
290
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
291
|
+
fetchDate: FETCH_DATE_LATER,
|
|
292
|
+
})));
|
|
293
|
+
|
|
294
|
+
record = await recorder.versionsRepository.findLatest(SERVICE_ID, TYPE);
|
|
359
295
|
});
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
296
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
content: CONTENT,
|
|
369
|
-
snapshotIds: [SNAPSHOT_ID],
|
|
370
|
-
fetchDate: FETCH_DATE,
|
|
371
|
-
}));
|
|
372
|
-
|
|
373
|
-
record = await recorder.versionsRepository.findLatest(SERVICE_ID, TYPE);
|
|
297
|
+
after(async () => recorder.versionsRepository.removeAll());
|
|
298
|
+
|
|
299
|
+
it('does not record any version', async () => {
|
|
300
|
+
expect(id).to.not.be.ok;
|
|
301
|
+
});
|
|
374
302
|
});
|
|
375
303
|
|
|
376
|
-
|
|
304
|
+
context('when it is an extraction only', () => {
|
|
305
|
+
const CONTENT = '# ToS fixture data with UTF-8 çhãràčtęrs';
|
|
306
|
+
const SNAPSHOT_ID = '61af86dc5ff5caa74ae926ad';
|
|
377
307
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
308
|
+
let id;
|
|
309
|
+
let isFirstRecord;
|
|
310
|
+
let record;
|
|
381
311
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
312
|
+
context('when it is the first record', () => {
|
|
313
|
+
before(async () => {
|
|
314
|
+
({ id, isFirstRecord } = await recorder.record(new Version({
|
|
315
|
+
serviceId: SERVICE_ID,
|
|
316
|
+
termsType: TYPE,
|
|
317
|
+
content: CONTENT,
|
|
318
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
319
|
+
fetchDate: FETCH_DATE,
|
|
320
|
+
isExtractOnly: true,
|
|
321
|
+
})));
|
|
385
322
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
});
|
|
389
|
-
});
|
|
323
|
+
record = await recorder.versionsRepository.findLatest(SERVICE_ID, TYPE);
|
|
324
|
+
});
|
|
390
325
|
|
|
391
|
-
|
|
392
|
-
const UPDATED_CONTENT = '<html><h1>ToS fixture data with UTF-8 çhãràčtęrs</h1><h2>Updated!</h2></html>';
|
|
326
|
+
after(async () => recorder.versionsRepository.removeAll()); after(async () => recorder.versionsRepository.removeAll());
|
|
393
327
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
documentType: TYPE,
|
|
398
|
-
content: CONTENT,
|
|
399
|
-
snapshotIds: [SNAPSHOT_ID],
|
|
400
|
-
fetchDate: FETCH_DATE,
|
|
401
|
-
});
|
|
328
|
+
it('records the version with the proper content', async () => {
|
|
329
|
+
expect(await record.content).to.equal(CONTENT);
|
|
330
|
+
});
|
|
402
331
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
content: UPDATED_CONTENT,
|
|
407
|
-
snapshotIds: [SNAPSHOT_ID],
|
|
408
|
-
fetchDate: FETCH_DATE_LATER,
|
|
409
|
-
}));
|
|
332
|
+
it('returns the record id', async () => {
|
|
333
|
+
expect(record.id).to.include(id);
|
|
334
|
+
});
|
|
410
335
|
|
|
411
|
-
|
|
412
|
-
|
|
336
|
+
it('states that it is the first record', async () => {
|
|
337
|
+
expect(isFirstRecord).to.be.true;
|
|
338
|
+
});
|
|
339
|
+
});
|
|
413
340
|
|
|
414
|
-
|
|
341
|
+
context('when it is not the first record', () => {
|
|
342
|
+
const UPDATED_CONTENT = '<html><h1>ToS fixture data with UTF-8 çhãràčtęrs</h1><h2>Updated!</h2></html>';
|
|
343
|
+
|
|
344
|
+
before(async () => {
|
|
345
|
+
await recorder.record(new Version({
|
|
346
|
+
serviceId: SERVICE_ID,
|
|
347
|
+
termsType: TYPE,
|
|
348
|
+
content: CONTENT,
|
|
349
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
350
|
+
fetchDate: FETCH_DATE,
|
|
351
|
+
}));
|
|
352
|
+
|
|
353
|
+
({ id, isFirstRecord } = await recorder.record(new Version({
|
|
354
|
+
serviceId: SERVICE_ID,
|
|
355
|
+
termsType: TYPE,
|
|
356
|
+
content: UPDATED_CONTENT,
|
|
357
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
358
|
+
fetchDate: FETCH_DATE_LATER,
|
|
359
|
+
isExtractOnly: true,
|
|
360
|
+
})));
|
|
361
|
+
|
|
362
|
+
record = await recorder.versionsRepository.findLatest(SERVICE_ID, TYPE);
|
|
363
|
+
});
|
|
415
364
|
|
|
416
|
-
|
|
417
|
-
expect(await record.content).to.equal(UPDATED_CONTENT);
|
|
418
|
-
});
|
|
365
|
+
after(async () => recorder.versionsRepository.removeAll());
|
|
419
366
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
367
|
+
it('records the version with the proper content', async () => {
|
|
368
|
+
expect(await record.content).to.equal(UPDATED_CONTENT);
|
|
369
|
+
});
|
|
423
370
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
371
|
+
it('records in the version that it is an extracted only version', async () => {
|
|
372
|
+
expect(record.isExtractOnly).to.equal(true);
|
|
373
|
+
});
|
|
427
374
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
});
|
|
375
|
+
it('returns the record id', async () => {
|
|
376
|
+
expect(record.id).to.include(id);
|
|
377
|
+
});
|
|
432
378
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
serviceId: SERVICE_ID,
|
|
437
|
-
documentType: TYPE,
|
|
438
|
-
content: CONTENT,
|
|
439
|
-
snapshotIds: [SNAPSHOT_ID],
|
|
440
|
-
fetchDate: FETCH_DATE,
|
|
379
|
+
it('states that it is not the first record', async () => {
|
|
380
|
+
expect(isFirstRecord).to.be.false;
|
|
381
|
+
});
|
|
441
382
|
});
|
|
442
383
|
|
|
443
|
-
(
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
384
|
+
context('when the content has not changed', () => {
|
|
385
|
+
before(async () => {
|
|
386
|
+
await recorder.record(new Version({
|
|
387
|
+
serviceId: SERVICE_ID,
|
|
388
|
+
termsType: TYPE,
|
|
389
|
+
content: CONTENT,
|
|
390
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
391
|
+
fetchDate: FETCH_DATE,
|
|
392
|
+
}));
|
|
393
|
+
|
|
394
|
+
({ id, isFirstRecord } = await recorder.record(new Version({
|
|
395
|
+
serviceId: SERVICE_ID,
|
|
396
|
+
termsType: TYPE,
|
|
397
|
+
content: CONTENT,
|
|
398
|
+
snapshotIds: [SNAPSHOT_ID],
|
|
399
|
+
fetchDate: FETCH_DATE_LATER,
|
|
400
|
+
isExtractOnly: true,
|
|
401
|
+
})));
|
|
402
|
+
|
|
403
|
+
record = await recorder.versionsRepository.findLatest(SERVICE_ID, TYPE);
|
|
404
|
+
});
|
|
453
405
|
|
|
454
|
-
|
|
406
|
+
after(async () => recorder.versionsRepository.removeAll());
|
|
455
407
|
|
|
456
|
-
|
|
457
|
-
|
|
408
|
+
it('does not record any version', async () => {
|
|
409
|
+
expect(id).to.not.be.ok;
|
|
410
|
+
});
|
|
411
|
+
});
|
|
458
412
|
});
|
|
459
413
|
});
|
|
460
414
|
});
|