// Channel-profile cards showed BLANK view counts because the channel grid never // subscribed its cards to the shared view counter (the main feed does). This wires // each card's [data-view-count] element the same way. The count VALUES come from the // same shared transport as the feed — the channel just wasn't displaying them. // // test_integrity_note: // change_type: ["new_tests"] // scenarios: // - id: SCN-channel-card-view-count // given: "a channel card element with a [data-view-count] span + a pointer" // when: "subscribeChannelCardViewCount runs (and clearChannelCardViewCounts tears down)" // then: "the element gets a non-blank view label; missing pointer/element/card are safe no-ops" // observable_outcomes: // - "a card with a pointer gets a non-blank view label (no longer blank)" // - "no pointer / no [data-view-count] / no card -> no throw, no label forced" // - "clearChannelCardViewCounts is idempotent and never throws" // determinism_controls: // - "JSDOM element; real module against the (uninitialised) shared view counter" // anti_cheat_rationale: // prevents: ["asserting the blank (broken) state", "hard-coded return value"] // relaxation: // did_relax_any_assertion: false import "./test-helpers/setup-localstorage.mjs"; import test from "node:test"; import { strict as assert } from "node:assert"; import { JSDOM } from "jsdom"; import { subscribeChannelCardViewCount, clearChannelCardViewCounts, } from "../js/channelViewCounts.js"; function makeCard(html) { const dom = new JSDOM(`
${html}`); return dom.window.document.body.firstElementChild; } test("a card with a pointer gets a non-blank view-count label (fixes the blank)", () => { const card = makeCard('