Files
raucao 3a9ddea010
CI / Lint (pull_request) Successful in 57s
CI / Test (pull_request) Successful in 1m32s
Release Drafter / Update release notes draft (pull_request) Successful in 16s
Default to BTC Map Overpass provider
Switch the default Overpass API provider to overpass.btcmap.org and
migrate users still on the previous overpass-api.de default over once.
2026-11-29 17:27:11 +04:00

66 lines
2.2 KiB
JavaScript

import { module, test } from 'qunit';
import { setupTest } from 'marco/tests/helpers';
const BTCMAP_OVERPASS_API = 'https://overpass.btcmap.org/api/interpreter';
const LEGACY_OVERPASS_API = 'https://overpass-api.de/api/interpreter';
const PRIVATE_COFFEE_OVERPASS_API =
'https://overpass.private.coffee/api/interpreter';
const MIGRATION_KEY = 'marco:migration:overpass-btcmap';
function storeSettings(settings) {
localStorage.setItem('marco:settings', JSON.stringify(settings));
}
module('Unit | Service | settings', function (hooks) {
setupTest(hooks);
hooks.beforeEach(function () {
localStorage.clear();
});
hooks.afterEach(function () {
localStorage.clear();
});
test('it exists', function (assert) {
let service = this.owner.lookup('service:settings');
assert.ok(service);
});
test('new users get the BTC Map Overpass provider by default', function (assert) {
let service = this.owner.lookup('service:settings');
assert.strictEqual(service.overpassApi, BTCMAP_OVERPASS_API);
assert.strictEqual(localStorage.getItem(MIGRATION_KEY), 'true');
});
test('users still on the legacy default are migrated to BTC Map once', function (assert) {
storeSettings({ overpassApi: LEGACY_OVERPASS_API });
let service = this.owner.lookup('service:settings');
assert.strictEqual(service.overpassApi, BTCMAP_OVERPASS_API);
assert.strictEqual(localStorage.getItem(MIGRATION_KEY), 'true');
});
test('users on a non-legacy provider are left untouched', function (assert) {
storeSettings({ overpassApi: PRIVATE_COFFEE_OVERPASS_API });
let service = this.owner.lookup('service:settings');
assert.strictEqual(service.overpassApi, PRIVATE_COFFEE_OVERPASS_API);
assert.strictEqual(localStorage.getItem(MIGRATION_KEY), 'true');
});
test('migration does not run again once it has been applied', function (assert) {
// Simulate a user who already went through the migration and then
// deliberately switched back to the legacy provider.
localStorage.setItem(MIGRATION_KEY, 'true');
storeSettings({ overpassApi: LEGACY_OVERPASS_API });
let service = this.owner.lookup('service:settings');
assert.strictEqual(service.overpassApi, LEGACY_OVERPASS_API);
});
});