Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
DistroKid draft accepts a single-artist account's fixed artist instead of failing
[._.]/ Adam Eivy93c427dfd639
diff --git a/client/src/lib/distrokidForm.test.js b/client/src/lib/distrokidForm.test.jsindex b229312986..8e20394fe1 100644--- a/client/src/lib/distrokidForm.test.js+++ b/client/src/lib/distrokidForm.test.js@@ -2,7 +2,7 @@// browser through page.evaluate, so they are tested here, against a fixture of// the upload form's fields (#10337), in the client's DOM environment.import { describe, it, expect, beforeEach } from 'vitest';-import { discloseDistrokidAi, fillDistrokidFields, untickDistrokidExtras } from '../../../server/lib/distrokidForm.js';+import { discloseDistrokidAi, fillDistrokidFields, setDistrokidArtist, untickDistrokidExtras } from '../../../server/lib/distrokidForm.js';const radios = (name, values) => values.map((v) => `<label><input type="radio" name="${name}" value="${v}">${v}</label>`).join('');const options = (values) => values.map((v) => `<option value="${v}">${v}</option>`).join('');@@ -115,3 +115,32 @@ describe('DistroKid form recipe', () => {expect(document.querySelector('input[name=spotifyArtistID]:checked')).toBeNull();});});++describe('DistroKid artist', () => {+ it('types the artist into the field a multi-artist plan shows', () => {+ document.body.innerHTML = '<input id="artistName" name="bandname">';+ expect(setDistrokidArtist('Example Artist')).toEqual({ ok: true, fixed: null });+ expect(document.querySelector('#artistName').value).toBe('Example Artist');+ });++ it('picks the artist from a picker by its shown name', () => {+ document.body.innerHTML = '<select name="bandname"><option value="">Pick</option><option value="a1">Example Artist</option></select>';+ expect(setDistrokidArtist('example artist')).toEqual({ ok: true, fixed: null });+ expect(document.querySelector('select').value).toBe('a1');+ });++ it("accepts a single-artist account's hidden artist when it matches", () => {+ document.body.innerHTML = '<input type="hidden" id="artistName" name="bandname" value="exampleartist">';+ expect(setDistrokidArtist('ExampleArtist')).toEqual({ ok: true, fixed: 'exampleartist' });+ });++ it("names the account's own artist when it differs", () => {+ document.body.innerHTML = '<input type="hidden" id="artistName" name="bandname" value="exampleartist">';+ expect(setDistrokidArtist('Someone Else')).toEqual({ ok: false, fixed: 'exampleartist' });+ });++ it('fails when the form has no artist field', () => {+ document.body.innerHTML = '';+ expect(setDistrokidArtist('Example Artist')).toEqual({ ok: false, fixed: null });+ });+});diff --git a/server/lib/distrokidForm.js b/server/lib/distrokidForm.jsindex 42a3eacd47..a7072682f2 100644--- a/server/lib/distrokidForm.js+++ b/server/lib/distrokidForm.js@@ -179,3 +179,32 @@ export function untickDistrokidExtras() {stillTicked: ticked.filter((b) => b.checked).map(labelOf),};}++/**+ * Set the release's artist. A plan with several artists shows a field (or a+ * picker); an account with one artist renders it as a hidden input that+ * already holds that artist, so there it is only checked. Resolves+ * `{ ok, fixed }`: `fixed` is the account's own artist when the form does not+ * let it change, so a mismatch can name both.+ */+export function setDistrokidArtist(artist) {+ const fields = [...document.querySelectorAll('#artistName, [name=bandname]')];+ const field = fields.find((e) => e.type !== 'hidden');+ if (field) {+ if (field.tagName === 'SELECT') {+ const want = artist.toLowerCase();+ const opt = [...field.options].find((o) => o.value === artist || o.textContent.trim().toLowerCase() === want);+ if (!opt) return { ok: false, fixed: null };+ field.value = opt.value;+ } else {+ field.focus();+ field.value = artist;+ }+ field.dispatchEvent(new Event('input', { bubbles: true }));+ field.dispatchEvent(new Event('change', { bubbles: true }));+ field.blur?.();+ return { ok: true, fixed: null };+ }+ const fixed = fields.find((e) => e.value)?.value || null;+ return { ok: !!fixed && fixed.toLowerCase() === artist.toLowerCase(), fixed };+}diff --git a/server/services/musicVideo/publish/distrokid.js b/server/services/musicVideo/publish/distrokid.jsindex 9396f41506..f85aa81638 100644--- a/server/services/musicVideo/publish/distrokid.js+++ b/server/services/musicVideo/publish/distrokid.js@@ -16,7 +16,7 @@* than failing the whole draft.*/import { PUBLISH_STEP_TIMEOUT_MS as T, loginRequired, step } from './browser.js';-import { discloseDistrokidAi, fillDistrokidFields, untickDistrokidExtras } from '../../../lib/distrokidForm.js';+import { discloseDistrokidAi, fillDistrokidFields, setDistrokidArtist, untickDistrokidExtras } from '../../../lib/distrokidForm.js';const label = 'DistroKid';const UPLOAD_URL = 'https://distrokid.com/new/';@@ -59,7 +59,12 @@ export const distrokidAdapter = {await soft('number of songs (1)', () => setValue(page, '#howManySongsOnThisAlbum, select[name=howmanysongs]', '1'));await page.waitForTimeout(1500);await step(label, 'set the artist', async () => {- if (!(await setValue(page, '#artistName, [name=bandname]', payload.artist))) throw new Error(`no artist field accepted "${payload.artist}"`);+ // An account with one artist fixes it in a hidden field, so it is checked, not typed.+ const { ok, fixed } = await page.evaluate(setDistrokidArtist, payload.artist);+ if (ok) return;+ throw new Error(fixed+ ? `this DistroKid account releases as "${fixed}", not "${payload.artist}"`+ : `no artist field accepted "${payload.artist}"`);});await step(label, 'upload the cover', () => page.locator('#artwork, input[type=file][name=artwork]').first().setInputFiles(payload.cover.path, { timeout: T }));await step(label, 'upload the audio', () => page.locator('#js-track-upload-1').first().setInputFiles(payload.audio.path, { timeout: T }));