CI / lint (push) Successful in 4s
CI / extension-version (push) Successful in 5s
CI / frontend-build (push) Successful in 20s
CI / backend-lint-and-test (push) Successful in 32s
extension / lint (push) Successful in 28s
CI / integration (push) Successful in 3m52s
Build images / sign-extension (push) Successful in 4s
Build images / build-ml (push) Failing after 5s
Build images / build-agent (push) Successful in 13s
Build images / build-web (push) Successful in 2m4s
Closes the half of the ask the signing work didn't: a way to tell a dev
build from a main one. FC_CHANNEL is baked into the web image at build
time and /api/extension/manifest reports it as its own key, next to
version — the popup banner, the toolbar tooltip and the Settings card all
name it.
Beside the version, never inside it. A `1.0.3499884-dev` suffix is the
obvious shortcut and it is the exact failure this design comes from:
versionIsNewer parses each dotted segment with parseInt, so a suffixed
segment reads as 0, every dev build compares equal to every other, and
"no update available" stops being distinguishable from "I cannot read this
version". The comparator already degrades rather than discarding (rule
150), which is a reason not to NEED the suffix, not a licence to add one.
Two tests hold the line — one backend, asserting version and channel are
separate keys; one frontend, asserting the rendered version text stays the
bare derived number.
Optional on the read side, and absent rather than defaulted. An image
built before this field says nothing by not having the key; an image built
without a channel now says nothing the same way, so there is one absence
to handle instead of a second spelling of "unknown". Every reader drops
the label entirely when it is missing and reads exactly as it did before.
Reported verbatim rather than validated against {dev, main}: if an image
declares something else, showing what it claims helps whoever is debugging
more than dropping it would.
FC_CHANNEL is declared LAST in the Dockerfile. An ARG invalidates every
layer below it, and this is the one value that differs between the dev and
main builds of identical source — earlier, and the two channels could
never share a cached pip install. A tag push counts as main: a vYY.MM.DD
tag is cut from main, so that image is a main-channel artifact wearing an
immutable name.
No channel switcher, deliberately. background.js:34 already records that
Firefox's static update_url cannot apply, because every FC instance is a
different host — so the extension asks its configured backend, and the
channel IS the instance it points at. Switching is repointing apiUrl and
reinstalling from that host. A separate setting would contradict each
server build shipping its own extension.
This commit touches packaged extension files, so it moves the derived
version and will sign a new one via AMO — the first push to exercise the
extension-changed path from dev end to end.
73 lines
2.9 KiB
JavaScript
73 lines
2.9 KiB
JavaScript
// @vitest-environment happy-dom
|
|
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
import { nextTick } from 'vue'
|
|
|
|
import BrowserExtensionCard from '../../src/components/settings/BrowserExtensionCard.vue'
|
|
import { freshPinia, mountComponent } from '../support/mountComponent.js'
|
|
|
|
// useApi is a thin fetch wrapper, so the seam is fetch itself (same shape as
|
|
// showcase.spec.js) rather than a module mock.
|
|
function stubApi(manifest) {
|
|
globalThis.fetch = vi.fn(async (url) => {
|
|
const payload = String(url).includes('/api/extension/manifest')
|
|
? manifest
|
|
: { key: 'test-key' }
|
|
return {
|
|
ok: true, status: 200, statusText: '200',
|
|
text: async () => JSON.stringify(payload),
|
|
}
|
|
})
|
|
}
|
|
|
|
async function mountCard(manifest) {
|
|
stubApi(manifest)
|
|
const w = mountComponent(BrowserExtensionCard, { pinia: freshPinia() })
|
|
// onMounted fires two fetches (manifest + key) and each resolves through a
|
|
// chain of microtasks. Yielding to a macrotask drains the whole queue, which
|
|
// a fixed number of nextTicks would only do by luck.
|
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
await nextTick()
|
|
return w
|
|
}
|
|
|
|
const INSTALLED = {
|
|
installed: true,
|
|
version: '1.0.3499884',
|
|
xpi_url: '/extension/fabledcurator-1.0.3499884.xpi',
|
|
latest_url: '/extension/fabledcurator-latest.xpi',
|
|
sha256: 'abc',
|
|
}
|
|
|
|
describe('BrowserExtensionCard — channel', () => {
|
|
beforeEach(() => { vi.restoreAllMocks() })
|
|
afterEach(() => { delete globalThis.fetch })
|
|
|
|
it('names the channel the instance reports', async () => {
|
|
// The point of the whole channel scheme: an operator can tell a dev
|
|
// instance from a main one without installing anything.
|
|
const w = await mountCard({ ...INSTALLED, channel: 'dev' })
|
|
expect(w.text()).toContain('dev')
|
|
})
|
|
|
|
it('shows the version and the channel as SEPARATE text, never merged', async () => {
|
|
// Regression guard with teeth: the tempting shortcut is a `-dev` version
|
|
// suffix, and that is precisely what breaks the extension's comparator —
|
|
// it parses each dotted segment with parseInt, so a suffixed segment reads
|
|
// as 0 and every dev build compares equal to every other. If someone ever
|
|
// "simplifies" by folding the channel into the version, the version text
|
|
// stops being the bare derived number and this fails.
|
|
const w = await mountCard({ ...INSTALLED, channel: 'dev' })
|
|
expect(w.text()).toContain('v1.0.3499884')
|
|
expect(w.text()).not.toContain('1.0.3499884-dev')
|
|
})
|
|
|
|
it('renders no channel when the instance declares none', async () => {
|
|
// A locally-built image, or one predating the field. The card must read
|
|
// exactly as it did before the channel existed rather than inventing an
|
|
// "unknown" badge — absence is a normal answer here, not a fault.
|
|
const w = await mountCard(INSTALLED)
|
|
expect(w.text()).toContain('v1.0.3499884')
|
|
expect(w.findAll('v-chip')).toHaveLength(0)
|
|
})
|
|
})
|