chore: remove Tencent Hy3 promo special-casing from promotions bar

This commit is contained in:
Peter Steinberger
2026-07-17 12:33:32 -07:00
parent 8142b3562a
commit 77459acc0a
4 changed files with 3 additions and 61 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

+1 -21
View File
@@ -60,7 +60,7 @@ describe("PromotionsBar", () => {
promotionsResponse([{ ...promotion, startsAt: 120_000, endsAt: 200_000 }]),
);
const { container } = render(<PromotionsBar />);
render(<PromotionsBar />);
await flushPromises();
expect(screen.queryByText(promotion.title)).toBeNull();
expect(fetchMock.mock.calls[0]?.[0]).toBe("https://clawhub.test/api/v1/promotions");
@@ -74,7 +74,6 @@ describe("PromotionsBar", () => {
expect(screen.getByText(promotion.title)).toBeTruthy();
expect(screen.getByText(promotion.blurb)).toBeTruthy();
expect(screen.queryByText("1 day left")).toBeNull();
expect(container.querySelector('img[src="/tencent-hy-favicon.png"]')).toBeNull();
});
it("removes a promotion at its expiry boundary and refreshes the query", async () => {
@@ -95,25 +94,6 @@ describe("PromotionsBar", () => {
expect(screen.queryByText(promotion.title)).toBeNull();
});
it("uses the campaign date instead of a changing countdown for Tencent Hy3", async () => {
fetchMock.mockResolvedValueOnce(
promotionsResponse([
{
...promotion,
title: "Tencent Hy3 is free on OpenRouter",
endsAt: Date.UTC(2026, 6, 21),
},
]),
);
const { container } = render(<PromotionsBar />);
await flushPromises();
expect(screen.getByText("Tencent's latest model, free until July 21")).toBeTruthy();
expect(screen.queryByText(/days left/)).toBeNull();
expect(container.querySelector('img[src="/tencent-hy-favicon.png"]')).toBeTruthy();
});
it("keeps a dismissed promotion hidden for the same campaign window", async () => {
const activePromotion = { ...promotion, endsAt: 200_000 };
fetchMock.mockResolvedValue(promotionsResponse([activePromotion]));
+2 -36
View File
@@ -39,30 +39,10 @@ function nextPromotionsRefreshDelay(promotions: PublicPromotion[], now: number)
);
}
function formatPromotionDate(endsAt: number) {
return new Intl.DateTimeFormat("en-US", {
month: "long",
day: "numeric",
timeZone: "UTC",
}).format(new Date(endsAt));
}
function isTencentHyPromotion(title: string) {
return /tencent hy3/i.test(title);
}
function promotionCtaUrl(promotion: PublicPromotion) {
return promotion.launchPageUrl ?? promotion.signupUrl ?? promotion.docsUrl ?? null;
}
function promotionMetaCopy(promotion: PublicPromotion) {
if (isTencentHyPromotion(promotion.title)) {
return `Tencent's latest model, free until ${formatPromotionDate(promotion.endsAt)}`;
}
return promotion.blurb;
}
function PromotionBarItem({
promotion,
onDismiss,
@@ -71,31 +51,17 @@ function PromotionBarItem({
onDismiss: (promotion: PublicPromotion) => void;
}) {
const ctaUrl = promotionCtaUrl(promotion);
const isTencentPromotion = isTencentHyPromotion(promotion.title);
return (
<article className="promotion-bar-item">
<div className="promotion-bar-content">
<div className="promotion-bar-copy">
<h3 className="promotion-bar-title">
{isTencentPromotion ? (
<img
src="/tencent-hy-favicon.png"
alt=""
aria-hidden="true"
className="promotion-bar-icon"
/>
) : (
<Gift
size={14}
aria-hidden="true"
className="promotion-bar-icon promotion-bar-icon-fallback"
/>
)}
<Gift size={14} aria-hidden="true" className="promotion-bar-icon" />
<span className="promotion-bar-title-copy">{promotion.title}</span>
</h3>
<span className="promotion-bar-separator" aria-hidden="true" />
<span className="promotion-bar-meta">{promotionMetaCopy(promotion)}</span>
<span className="promotion-bar-meta">{promotion.blurb}</span>
</div>
{ctaUrl ? (
<a className="promotion-bar-link" href={ctaUrl} target="_blank" rel="noopener noreferrer">
-4
View File
@@ -25694,10 +25694,6 @@ a.search-empty-action {
width: 14px;
height: 14px;
flex: 0 0 auto;
border-radius: var(--oc-radius-inset);
}
.promotion-bar-icon-fallback {
color: var(--accent);
}