Skip to content

apps/* tests hardcode template branding and product ids; fail after rename #381

@ZappoMan

Description

@ZappoMan

Summary

After npm run rename to a new product name (e.g. NewApp), tests under apps/mobile/__tests__ and apps/web/**/__tests__ fail because they assert hardcoded template values (Beaker Stack, beakerstack, template GitHub URLs) while production code reads from @adopter/config/* (updated by rename in adopter/ only).

Related: #379 (rename scope), #380 (billing meter constant imports).

Steps to reproduce

  1. Rename the template:

    npm run rename -- --from "Beaker Stack" --to "NewApp" --preserve-upstream
  2. Run unit tests:

    npm run test:unit:mobile
    npm run test:unit:web

Actual behavior

Mobile — display name in billing UI copy

apps/mobile/__tests__/screens/billing/BillingScreens.test.tsx fails:

Unable to find an element with text: /Beaker Stack web app/i

Rendered UI correctly shows:

Update your payment method in the NewApp web app.

Because BillingOverviewScreen uses:

`… Update your payment method in the ${getAdopterConfig().branding.displayName} web app.`

while the test asserts:

expect(getByText(/Beaker Stack web app/i)).toBeTruthy();

Web — product id from adopter billing / app identity

Several web tests hardcode beakerstack as productId / p_product_id while hooks and pages use billingConfig.productId or appIdentity.productId (e.g. newapp after rename):

apps/web/src/admin/__tests__/adminUsageColumns.test.ts

expected 'newapp' to be 'beakerstack'

(adminProductId is billingConfig.productId.)

apps/web/src/billing/__tests__/useDemoCollections.test.tsx (multiple tests)

expected spy to be called with … p_product_id: "beakerstack"
received … p_product_id: "newapp"

(useDemoCollections in @adopter/web/billing uses appIdentity.productId.)

apps/web/src/pages/__tests__/SignupInvitePage.test.tsx

expected … productId: "beakerstack"
received … productId: "newapp"

(finalizeInviteSignup sends billingConfig.productId.)

Web — GitHub repo URL in dashboard demo banner

apps/web/src/pages/__tests__/DashboardPage.test.tsx

Expected href="https://github.com/Artificer-Innovations/BeakerStack"
Received href="https://github.com/Artificer-Innovations/NewApp"

(adopter/web/components/dashboard/DemoBanner.tsx and adopter/config/landing.ts are updated by rename; the test still expects the upstream template URL.)

Expected behavior

Template tests in apps/* should not hardcode template display names, product ids, or repo URLs when the code under test derives those values from adopter config.

Suggested patterns:

import { branding } from '@adopter/config/branding';
expect(getByText(new RegExp(`${branding.displayName} web app`, 'i'))).toBeTruthy();

import { billingConfig } from '@adopter/config/billing';
expect(adminProductId).toBe(billingConfig.productId);

import { appIdentity } from '@adopter/config/app-identity';
expect(rpc).toHaveBeenCalledWith('billing_demo_add_collection', {
  p_product_id: appIdentity.productId,
});

import { landingConfig } from '@adopter/config/landing';
expect(link).toHaveAttribute('href', landingConfig.finalCta.secondaryCta.href);

Affected files (confirmed in fork testing)

File Hardcoded Should use
apps/mobile/__tests__/screens/billing/BillingScreens.test.tsx Beaker Stack web app @adopter/config/branding
apps/web/src/admin/__tests__/adminUsageColumns.test.ts 'beakerstack' product id billingConfig.productId
apps/web/src/billing/__tests__/useDemoCollections.test.tsx p_product_id: 'beakerstack' appIdentity.productId
apps/web/src/pages/__tests__/DashboardPage.test.tsx BeakerStack GitHub URL landingConfig or adopter banner URL
apps/web/src/pages/__tests__/SignupInvitePage.test.tsx productId: 'beakerstack' billingConfig.productId

Additional grep targets: apps/web/src/pages/__tests__/HomePage.test.tsx, BillingUsagePage.test.tsx, and other mocks with displayName: 'Beaker Stack' or product_id: 'beakerstack'.

Suggested fix

  1. Update the affected tests to import values from @adopter/config/branding, billing, app-identity, or landing instead of hardcoding template literals.
  2. Document in docs/renaming.md that adopters should grep apps/**/__tests__ for Beaker Stack, beakerstack, and template GitHub URLs after rename.
  3. Optionally extend rename strict mode or add npm run rename:check to flag hardcoded product ids / display names in apps/ (same class of drift as setup:full Supabase slug uses stale app.config.js; rename does not update apps/mobile branding #379).

Workaround (adopters)

Replace hardcoded template strings in apps/**/__tests__ with imports from @adopter/config/* as shown above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions