Skip to content

feat: hide QA-only templates from /templates when customizableMedia flag is off#8797

Open
jaco-brink wants to merge 13 commits intomainfrom
jacobusbrink/nes-1370-prod-testable-template
Open

feat: hide QA-only templates from /templates when customizableMedia flag is off#8797
jaco-brink wants to merge 13 commits intomainfrom
jacobusbrink/nes-1370-prod-testable-template

Conversation

@jaco-brink
Copy link
Contributor

@jaco-brink jaco-brink commented Mar 3, 2026

Summary

  • Adds QA_ONLY_TEMPLATE_SLUGS constant in TemplateSections to track slugs of QA-only test templates
  • Filters out those journeys from all carousels on /templates when the customizableMedia LaunchDarkly flag is false/undefined
  • Fixes /templates getStaticProps to pass flags through to FlagsProvider (was missing, causing all flags to evaluate as undefined)

Test plan

  • Confirm journey with slug qa-customizable-media-test does not appear on /templates when customizableMedia flag is off
  • Confirm it does appear when customizableMedia flag is on
  • All existing TemplateSections tests pass

Summary by CodeRabbit

  • New Features

    • Template listings now respect a configurable feature flag so QA-only templates are shown or hidden per configuration.
    • The templates admin page now uses server-side authentication with redirect handling and exposes feature flags to the rendered page.
  • Tests

    • Added tests verifying QA-only template visibility under different feature-flag states.

…lag is off

Adds a client-side slug filter to TemplateSections that hides journeys
whose slug is in QA_ONLY_TEMPLATE_SLUGS when the customizableMedia
LaunchDarkly flag evaluates to false. Also fixes /templates getStaticProps
to pass flags through to the FlagsProvider so flag evaluation works.

Made-with: Cursor
@linear
Copy link

linear bot commented Mar 3, 2026

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Replaces static props with server-side auth on the admin templates page to return feature flags and optional redirects; adds a customizableMedia feature flag to TemplateSections to hide/show QA-only template slugs and adds tests for both flag states.

Changes

Cohort / File(s) Summary
Admin page — server-side auth & flags
apps/journeys-admin/pages/templates/index.tsx
Replaced getStaticProps with getServerSideProps wrapped by withUserTokenSSR and AuthAction.RENDER; calls initAndAuthApp, returns flags, initialApolloState, translations, and handles optional redirect. Default export updated to withUser({ whenUnauthedAfterInit: AuthAction.RENDER }).
Template UI — feature gating
libs/journeys/ui/src/components/TemplateSections/TemplateSections.tsx
Added QA_ONLY_TEMPLATE_SLUGS, used useFlags to read customizableMedia, introduced visibleJourneys filtering when flag is false, replaced usages of data.journeys with visibleJourneys, updated useMemo deps and added a debug log.
Tests — flag behavior
libs/journeys/ui/src/components/TemplateSections/TemplateSections.spec.tsx
Added FlagsProvider in tests, introduced qaOnlyJourney mock and combined journeys list, and added tests asserting QA-only templates are hidden when customizableMedia is false and shown when true.

Sequence Diagram(s)

sequenceDiagram
    participant Browser as Browser
    participant NextSSR as Next.js SSR (getServerSideProps)
    participant InitAuth as initAndAuthApp
    participant Page as Templates Page
    participant TemplateComp as TemplateSections

    Browser->>NextSSR: Request /templates
    NextSSR->>InitAuth: initAndAuthApp({ locale, resolvedUrl, user? })
    InitAuth-->>NextSSR: { initialApolloState, flags, redirect? }
    alt redirect present
        NextSSR-->>Browser: 3xx redirect
    else no redirect
        NextSSR-->>Page: props { initialApolloState, flags, ... }
        Page->>TemplateComp: render with flags
        TemplateComp->>TemplateComp: read flags.customizableMedia
        alt customizableMedia = false
            TemplateComp->>TemplateComp: filter out QA-only templates
        else customizableMedia = true
            TemplateComp->>TemplateComp: include QA-only templates
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mikeallisonJS
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: hiding QA-only templates when a specific flag is off, which is the primary objective of the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jacobusbrink/nes-1370-prod-testable-template

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Fails
🚫 Please assign someone to merge this PR.

Generated by 🚫 dangerJS against 8015c8a

@nx-cloud
Copy link

nx-cloud bot commented Mar 3, 2026

View your CI Pipeline Execution ↗ for commit 8015c8a

Command Status Duration Result
nx run journeys-admin-e2e:e2e ✅ Succeeded 32s View ↗
nx run watch-e2e:e2e ✅ Succeeded 33s View ↗
nx run resources-e2e:e2e ✅ Succeeded 29s View ↗
nx run journeys-e2e:e2e ✅ Succeeded 20s View ↗
nx run videos-admin-e2e:e2e ✅ Succeeded 4s View ↗
nx run-many --target=vercel-alias --projects=watch ✅ Succeeded 2s View ↗
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 4s View ↗
nx run-many --target=deploy --projects=watch ✅ Succeeded 54s View ↗
Additional runs (12) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2026-03-05 20:34:57 UTC

@github-actions github-actions bot temporarily deployed to Preview - resources March 3, 2026 00:43 Inactive
@github-actions github-actions bot requested a deployment to Preview - journeys-admin March 3, 2026 00:43 Pending
@github-actions github-actions bot temporarily deployed to Preview - journeys March 3, 2026 00:43 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 3, 2026 00:43 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
libs/journeys/ui/src/components/TemplateSections/TemplateSections.spec.tsx (1)

407-423: Consider adding a test case for when customizableMedia is undefined.

The PR objectives state QA templates should be hidden when the flag is "off or undefined." The current tests cover false and true, but the undefined case (no FlagsProvider or flag not set) is also a valid scenario worth testing to ensure the default behavior is correct.

💡 Suggested test case for undefined flag
it('hides QA-only slug template when customizableMedia is undefined', async () => {
  const { queryByRole } = render(
    <FlagsProvider flags={{}}>
      <MockedProvider mocks={[getJourneysWithQaOnlyMock]}>
        <TemplateSections languageIds={['529']} />
      </MockedProvider>
    </FlagsProvider>
  )
  await waitFor(() =>
    expect(
      queryByRole('heading', { name: 'Featured & New' })
    ).toBeInTheDocument()
  )
  expect(
    queryByRole('heading', { name: 'QA Customizable Media Test' })
  ).not.toBeInTheDocument()
})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/journeys/ui/src/components/TemplateSections/TemplateSections.spec.tsx`
around lines 407 - 423, Add a test to assert the QA-only slug is hidden when the
customizableMedia flag is undefined by rendering TemplateSections inside a
FlagsProvider without the customizableMedia key (empty flags object) and using
the same MockedProvider/getJourneysWithQaOnlyMock setup; in the new test
(similar to the existing 'hides QA-only slug template when customizableMedia is
false'), call render with <FlagsProvider flags={{}}>, wait for the "Featured &
New" heading, and assert that the "QA Customizable Media Test" heading is not in
the document so TemplateSections' behavior for undefined customizableMedia is
covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@libs/journeys/ui/src/components/TemplateSections/TemplateSections.spec.tsx`:
- Around line 407-423: Add a test to assert the QA-only slug is hidden when the
customizableMedia flag is undefined by rendering TemplateSections inside a
FlagsProvider without the customizableMedia key (empty flags object) and using
the same MockedProvider/getJourneysWithQaOnlyMock setup; in the new test
(similar to the existing 'hides QA-only slug template when customizableMedia is
false'), call render with <FlagsProvider flags={{}}>, wait for the "Featured &
New" heading, and assert that the "QA Customizable Media Test" heading is not in
the document so TemplateSections' behavior for undefined customizableMedia is
covered.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ba34453 and b30dbd8.

📒 Files selected for processing (3)
  • apps/journeys-admin/pages/templates/index.tsx
  • libs/journeys/ui/src/components/TemplateSections/TemplateSections.spec.tsx
  • libs/journeys/ui/src/components/TemplateSections/TemplateSections.tsx

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Fri Mar 6 09:29:18 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
resources ✅ Ready resources preview Fri Mar 6 09:29:38 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
videos-admin ✅ Ready videos-admin preview Fri Mar 6 09:29:24 NZDT 2026

@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 3, 2026 00:49 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 3, 2026 00:49 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 3, 2026 00:49 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 3, 2026 00:49 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 3, 2026 00:49 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Fri Mar 6 09:30:06 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch ✅ Ready watch preview Fri Mar 6 09:30:24 NZDT 2026

@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 4, 2026 03:10 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 4, 2026 03:10 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 4, 2026 03:10 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 4, 2026 03:10 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 4, 2026 03:10 Inactive
@blacksmith-sh

This comment has been minimized.

@github-actions github-actions bot requested a deployment to Preview - videos-admin March 5, 2026 02:49 Pending
@github-actions github-actions bot requested a deployment to Preview - resources March 5, 2026 02:49 Pending
@github-actions github-actions bot requested a deployment to Preview - resources March 5, 2026 02:54 Pending
@github-actions github-actions bot requested a deployment to Preview - journeys-admin March 5, 2026 02:54 Pending
@github-actions github-actions bot requested a deployment to Preview - journeys March 5, 2026 02:54 Pending
@github-actions github-actions bot requested a deployment to Preview - videos-admin March 5, 2026 02:54 Pending
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/journeys-admin/pages/templates/index.tsx (1)

20-43: ⚠️ Potential issue | 🟠 Major

Do not log user identifiers and full flag payloads in the browser.

Line 43 exposes user.id and all feature flags in client logs. This is sensitive telemetry and should be removed from production code.

Suggested fix
-import { useFlags } from '@core/shared/ui/FlagsProvider'
@@
-  const flags = useFlags()
-  console.log('[/templates] userId:', user?.id ?? 'anonymous', '| flags:', JSON.stringify(flags))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/journeys-admin/pages/templates/index.tsx` around lines 20 - 43, The
console.log in TemplateIndexPage leaks sensitive info (user?.id and flags) to
the browser; remove the client-side log or replace it with a
sanitized/server-side telemetry call. Locate the console.log call inside the
TemplateIndexPage function where useUser() and useFlags() are used and either
delete the line or change it to only emit non-identifying state (e.g. presence
booleans) or send details to a secure server-side logger instead of logging
user.id or the full flags object in the browser.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@libs/journeys/ui/src/components/TemplateSections/TemplateSections.tsx`:
- Line 38: Remove the noisy debug console.log in the TemplateSections component:
delete the line that prints "[TemplateSections] customizableMedia flag:" and the
customizableMedia variable (the console.log call located in TemplateSections.tsx
inside the TemplateSections component) so feature-flag state is not emitted on
every render; if you need runtime visibility keep a non-production guard (e.g.,
use a debug logger or check NODE_ENV) instead of unconditional console.log.

---

Outside diff comments:
In `@apps/journeys-admin/pages/templates/index.tsx`:
- Around line 20-43: The console.log in TemplateIndexPage leaks sensitive info
(user?.id and flags) to the browser; remove the client-side log or replace it
with a sanitized/server-side telemetry call. Locate the console.log call inside
the TemplateIndexPage function where useUser() and useFlags() are used and
either delete the line or change it to only emit non-identifying state (e.g.
presence booleans) or send details to a secure server-side logger instead of
logging user.id or the full flags object in the browser.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 365f976a-3fe0-4e42-8035-a426b882559a

📥 Commits

Reviewing files that changed from the base of the PR and between 518a79e and aaa9c32.

📒 Files selected for processing (2)
  • apps/journeys-admin/pages/templates/index.tsx
  • libs/journeys/ui/src/components/TemplateSections/TemplateSections.tsx

@github-actions github-actions bot temporarily deployed to Preview - journeys March 5, 2026 02:57 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 5, 2026 02:57 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 5, 2026 02:57 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 5, 2026 02:57 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 5, 2026 02:57 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/journeys-admin/pages/templates/index.tsx`:
- Around line 43-48: Remove the debug console.log call that prints user?.id and
flags in the templates page (the console.log statement referencing '[/templates]
userId:' and JSON.stringify(flags)); if the flags variable is only used for that
log and not used elsewhere in the component or exported (search for its
identifier 'flags'), delete the flags declaration/usage as well to avoid leaving
unused variables and potential leaking of user info.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 77cad60c-1778-4373-afd7-22dbf345e1a9

📥 Commits

Reviewing files that changed from the base of the PR and between aaa9c32 and 07e1cce.

📒 Files selected for processing (1)
  • apps/journeys-admin/pages/templates/index.tsx

@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 5, 2026 03:35 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 5, 2026 03:35 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 5, 2026 03:35 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 5, 2026 03:35 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 5, 2026 03:35 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 5, 2026 20:27 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 5, 2026 20:27 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 5, 2026 20:27 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 5, 2026 20:27 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 5, 2026 20:27 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant