Add media server selection to Nostr settings
Also, hide the fallback option when there's no server to fall back to
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
mergeRequiredRelays,
|
||||
uniqNormalizedRelays,
|
||||
} from 'marco/utils/nostr';
|
||||
import { DEFAULT_BLOSSOM_SERVER } from 'marco/services/blossom';
|
||||
|
||||
class MockNostrDataService extends Service {
|
||||
@service settings;
|
||||
@@ -18,6 +19,8 @@ class MockNostrDataService extends Service {
|
||||
mailboxReadRelays = ['wss://mailbox.example.com'];
|
||||
mailboxWriteRelays = ['wss://mailbox-write.example.com'];
|
||||
|
||||
blossomServers = [];
|
||||
|
||||
get configuredReadRelays() {
|
||||
const configured = uniqNormalizedRelays([
|
||||
...this.mailboxReadRelays,
|
||||
@@ -185,4 +188,33 @@ module('Integration | Component | app-menu/settings/nostr', function (hooks) {
|
||||
'wss://mailbox-write.example.com',
|
||||
]);
|
||||
});
|
||||
|
||||
test('media server dropdown shows only the default server when no blossom servers discovered', async function (assert) {
|
||||
const element = await renderAndOpenDetails(this);
|
||||
const select = element.querySelector('#nostr-media-server');
|
||||
|
||||
assert.dom(select).exists();
|
||||
assert.strictEqual(select.options.length, 1);
|
||||
assert.dom(select.options[0]).hasValue(DEFAULT_BLOSSOM_SERVER);
|
||||
assert.dom(select.options[0]).hasText(DEFAULT_BLOSSOM_SERVER);
|
||||
assert.strictEqual(select.value, DEFAULT_BLOSSOM_SERVER);
|
||||
assert
|
||||
.dom('#nostr-photo-fallback-uploads')
|
||||
.doesNotExist('fallback toggle hidden with single media server');
|
||||
});
|
||||
|
||||
test('media server dropdown lists discovered blossom servers', async function (assert) {
|
||||
const servers = ['https://cdn.example.com', 'https://cdn.satellite.earth'];
|
||||
this.owner.lookup('service:nostrData').blossomServers = servers;
|
||||
|
||||
const element = await renderAndOpenDetails(this);
|
||||
const select = element.querySelector('#nostr-media-server');
|
||||
|
||||
assert.strictEqual(select.options.length, servers.length);
|
||||
assert.dom(select.options[0]).hasValue(servers[0]);
|
||||
assert.dom(select.options[1]).hasValue(servers[1]);
|
||||
assert
|
||||
.dom('#nostr-photo-fallback-uploads')
|
||||
.exists('fallback toggle visible with multiple media servers');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user