CI and images / lint (push) Successful in 2s
CI and images / extension-version (push) Successful in 2s
CI and images / extension-test (push) Successful in 20s
CI and images / frontend-build (push) Successful in 24s
CI and images / backend-lint-and-test (push) Successful in 32s
CI and images / integration (push) Successful in 2m22s
CI and images / build-agent (push) Successful in 5s
CI and images / sign-extension (push) Successful in 3m13s
CI and images / build-web (push) Successful in 1m42s
CI and images / smoke-web (push) Successful in 54s
CI and images / promote (push) Successful in 1s
Server (#4420) - extension_service gains a Discord pattern (server or channel, jump links, ptb/canary; not DMs or threads), mirrored in platforms.js and pinned by the shared artist-url-samples.json. - probe on a Discord URL matches the source by ids under any artist, reports a whole-server source as covering the channel, suggests the artist who owns another source on the same server, and names server/channel via the stored token (best-effort, bounded, no rate-limit waits). - quick-add takes artist_id / artist_name; Discord URLs are stored canonical. Extension (#4421, #4422) - Content script on discord.com; SPA navigation by URL polling (the old pushState patch ran in the isolated world and never fired); stale probes are dropped. - Discord chip opens an Add panel: this channel or the whole server, and the suggested artist / a search / a new name. - Popup: sources show artist, platform and state; a Discord token export is verified by FC and the result shown. Token capture covers ptb/canary. - Pure logic in lib/chip.js and lib/popup-format.js, with specs. CI (#4423) - extension.yml's lane (web-ext lint, vitest, XPI contents) moves into build.yml as extension-test and joins the needs of sign-extension, build-web and build-agent. As a separate workflow it gated nothing: a red extension suite still signed and shipped the XPI (rule 177). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjrnpQjRgHdvq95rASoiR
109 lines
4.0 KiB
JavaScript
109 lines
4.0 KiB
JavaScript
import { describe, it, expect } from 'vitest'
|
|
import { loadLib } from './helpers/loadLib.js'
|
|
|
|
const { chipState, chipLabel, discordPanelDefaults, discordAddRequest } = loadLib('chip.js', [
|
|
'chipState',
|
|
'chipLabel',
|
|
'discordPanelDefaults',
|
|
'discordAddRequest'
|
|
])
|
|
|
|
const discord = (extra = {}) => ({
|
|
platform: 'discord',
|
|
slug: '111/222',
|
|
discord: {
|
|
server_id: '111',
|
|
channel_id: '222',
|
|
server_name: 'Studio',
|
|
channel_name: 'drops',
|
|
server_url: 'https://discord.com/channels/111',
|
|
channel_url: 'https://discord.com/channels/111/222'
|
|
},
|
|
...extra
|
|
})
|
|
|
|
describe('chip state and label', () => {
|
|
it('keeps the one-click wording on creator platforms', () => {
|
|
expect(chipLabel({ state: 'new', platform: 'patreon' }, 'Patreon')).toBe('+ Add to FabledCurator')
|
|
expect(
|
|
chipLabel({ state: 'artist_match', platform: 'patreon', artist: { name: 'Atole' } }, 'Patreon')
|
|
).toBe('+ Add Patreon source to Atole')
|
|
expect(chipLabel({ state: 'source_match', platform: 'patreon' }, 'Patreon')).toBe(
|
|
'✓ In FabledCurator · Patreon'
|
|
)
|
|
})
|
|
|
|
it('offers the channel by name on Discord, whatever the suggestion', () => {
|
|
expect(chipLabel(discord({ state: 'new' }), 'Discord')).toBe('+ Add #drops to FabledCurator')
|
|
expect(chipLabel(discord({ state: 'artist_match', artist: { name: 'A' } }), 'Discord')).toBe(
|
|
'+ Add #drops to FabledCurator'
|
|
)
|
|
})
|
|
|
|
it('says "this channel" when the token could not read the name', () => {
|
|
const p = discord({ state: 'new' })
|
|
p.discord.channel_name = null
|
|
expect(chipLabel(p, 'Discord')).toBe('+ Add this channel to FabledCurator')
|
|
})
|
|
|
|
it('says whose source a Discord channel already is, and when the server covers it', () => {
|
|
const artist = { name: 'Tamada', slug: 'tamada' }
|
|
expect(chipLabel(discord({ state: 'source_match', artist, covered_by_server: false }), 'Discord')).toBe(
|
|
'✓ In FabledCurator · Tamada'
|
|
)
|
|
expect(chipLabel(discord({ state: 'source_match', artist, covered_by_server: true }), 'Discord')).toBe(
|
|
'✓ Whole server in FabledCurator · Tamada'
|
|
)
|
|
})
|
|
|
|
it('falls back to the generic add when the probe failed', () => {
|
|
expect(chipState({ error: 'x' })).toBe('new')
|
|
expect(chipLabel({ error: 'x' }, '')).toBe('+ Add to FabledCurator')
|
|
expect(chipState({ state: 'source_match' })).toBe('source-match')
|
|
})
|
|
})
|
|
|
|
describe('Discord Add panel', () => {
|
|
it('opens on the channel with the suggested artist preselected', () => {
|
|
const d = discordPanelDefaults(discord({ state: 'artist_match', artist: { id: 7, name: 'Tamada' } }))
|
|
expect(d.scope).toBe('channel')
|
|
expect(d.artist).toEqual({ id: 7, name: 'Tamada' })
|
|
expect(d.artistName).toBe('Tamada')
|
|
})
|
|
|
|
it('proposes a new artist named after the server when nothing is suggested', () => {
|
|
const d = discordPanelDefaults(discord({ state: 'new' }))
|
|
expect(d.artist).toBe(null)
|
|
expect(d.artistName).toBe('Studio')
|
|
})
|
|
|
|
it('sends a picked artist by id', () => {
|
|
const choice = discordPanelDefaults(discord({ state: 'artist_match', artist: { id: 7, name: 'Tamada' } }))
|
|
expect(discordAddRequest(choice)).toEqual({
|
|
url: 'https://discord.com/channels/111/222',
|
|
artistId: 7
|
|
})
|
|
})
|
|
|
|
it('sends a typed name once the picked artist has been edited away', () => {
|
|
const choice = discordPanelDefaults(discord({ state: 'artist_match', artist: { id: 7, name: 'Tamada' } }))
|
|
choice.artistName = 'Tamada Alt'
|
|
expect(discordAddRequest(choice)).toEqual({
|
|
url: 'https://discord.com/channels/111/222',
|
|
artistName: 'Tamada Alt'
|
|
})
|
|
})
|
|
|
|
it('adds the whole server when the operator picks it', () => {
|
|
const choice = discordPanelDefaults(discord({ state: 'new' }))
|
|
choice.scope = 'server'
|
|
expect(discordAddRequest(choice).url).toBe('https://discord.com/channels/111')
|
|
})
|
|
|
|
it('has nothing to send without an artist', () => {
|
|
const choice = discordPanelDefaults(discord({ state: 'new' }))
|
|
choice.artistName = ' '
|
|
expect(discordAddRequest(choice)).toBe(null)
|
|
})
|
|
})
|