Release 2.16.1
This commit is contained in:
1 parent
3514d514a3
commit
8ce8228091
25 files changed
+1307
-613
No files matched your search
@@ -54,9 +54,39 @@ test('api source duplicate form model keeps info toast variant', () => {
|
||||
assert.equal(model.showSaveSecondaryActions, true);
|
||||
});
|
||||
|
||||
test('API source form normalization is shared by add, edit, and duplication', () => {
|
||||
const source = { id: 9, name: 'Tiltify', auth_method: 'token_login', token_url: 'https://example.com/token', token_response_path: 'data.token', token_header_prefix: '', update_interval_value: 30, update_interval_unit: 'seconds', enabled: 0 };
|
||||
const add = buildApiSourceFormViewModel(source, '', null, {}, false).apiSource;
|
||||
const edit = buildApiSourceFormViewModel(source, '', null, {}, true).apiSource;
|
||||
const duplicate = buildDuplicateApiSource(source, 'Copy of Tiltify');
|
||||
for (const values of [add, edit, duplicate]) {
|
||||
assert.equal(values.authMethod, 'token_login');
|
||||
assert.equal(values.tokenUrl, source.token_url);
|
||||
assert.equal(values.tokenResponsePath, 'data.token');
|
||||
assert.equal(values.tokenHeaderPrefix, '');
|
||||
assert.equal(values.updateIntervalValue, 30);
|
||||
assert.equal(values.updateIntervalUnit, 'seconds');
|
||||
assert.equal(values.enabled, 0);
|
||||
}
|
||||
});
|
||||
|
||||
test('API group duplication copies request settings without IDs or response state', () => {
|
||||
const request = { id: 10, name: 'Donors', api_url: 'https://example.com/donors', request_method: 'GET', items_path: 'data', enabled: 1, update_interval_value: 30, update_interval_unit: 'seconds', last_response_json: '{"private":"old snapshot"}', last_pull_error: 'Old error' };
|
||||
const duplicate = buildDuplicateApiSource({ id: 9, name: 'Tiltify', requests: [request] }, 'Copy of Tiltify');
|
||||
assert.equal(duplicate.id, null);
|
||||
assert.equal(duplicate.requests.length, 1);
|
||||
assert.equal(duplicate.requests[0].api_url, request.api_url);
|
||||
assert.equal(duplicate.requests[0].update_interval_value, 30);
|
||||
assert.equal(duplicate.requests[0].id, undefined);
|
||||
assert.equal(duplicate.requests[0].last_response_json, undefined);
|
||||
assert.equal(duplicate.requests[0].last_pull_error, undefined);
|
||||
assert.equal(request.id, 10);
|
||||
});
|
||||
|
||||
test('api source list template includes duplicate action', () => {
|
||||
const template = fs.readFileSync(path.join(__dirname, '..', 'src', 'web', 'views', 'data-sources', 'api-sources', 'list.hbs'), 'utf8');
|
||||
|
||||
assert.match(template, /\/data-sources\/api-sources\/{\{id\}\}\/duplicate/);
|
||||
assert.match(template, />Dupe<\/a>/);
|
||||
assert.match(template, /<h2>API sources<\/h2>\s*<p>Manage API sources, shared authentication, and request refresh schedules\.<\/p>/);
|
||||
});
|
||||
Reference in new issue
Block a user