Skip to content

fix(page-status): correctly classify BYOM pages when sourceLastModified is null/absent#369

Open
somarc wants to merge 2 commits into
mainfrom
fix/page-status-byom-no-source
Open

fix(page-status): correctly classify BYOM pages when sourceLastModified is null/absent#369
somarc wants to merge 2 commits into
mainfrom
fix/page-status-byom-no-source

Conversation

@somarc

@somarc somarc commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes page-status: BYOM content always shows 'No source' #340 — BYOM pages with no sourceLastModified were always shown as No source (negative/red), even when fully previewed and published
  • Extracts classification logic from buildSequenceStatus() into a new pure module tools/page-status/status.jsclassifySequenceStatus(), making it independently testable
  • When edit is null/absent (null ?? NaN guard ensures both are treated as Invalid Date), classification falls through to preview/publish state instead of immediately returning negative
  • Adds tests/tools/page-status/status.test.js — 10 tests parametrized over [undefined, null] covering the full no-source matrix plus 5 with-source regression paths (100% branch coverage)

Classification matrix (no source date)

preview publish Before After
absent absent No source ❌ No source ❌ (unchanged)
valid absent No source ❌ Not published ✅
absent valid No source ❌ Current ✅
valid valid, preview ≤ publish No source ❌ Current ✅
valid valid, preview > publish No source ❌ Pending changes ✅

Preview

Branch preview of the page-status tool:
https://fix-page-status-byom-no-source--helix-tools-website--adobe.aem.page

Test plan

  • npm run lint — passes
  • npm test — 430 tests pass, status.js at 100% branch coverage
  • Open the page-status tool, run a status check against a site with BYOM pages — verify they show Current / Pending changes / Not published instead of No source
  • Verify non-BYOM pages (regular authored content) are unaffected

🤖 Generated with Claude Code

@aem-code-sync

aem-code-sync Bot commented May 13, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run all PSI checks
  • Re-run failed PSI checks
  • Re-sync branch
Commits

@aem-code-sync

aem-code-sync Bot commented May 13, 2026

Copy link
Copy Markdown
Page Scores Audits Google
📱 / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@claude

claude Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Code Review

Files Reviewed

  • tools/page-status/status.js — new pure classification module
  • tools/page-status/scripts.js — refactored to use new module
  • tests/tools/page-status/status.test.js — new test file
  • tools/page-status/flows.html — new interactive flow explorer

Issues Found

CONSIDER:

tools/page-status/flows.html — Intended as a permanent developer tool or a temporary review aid?

  • The file is publicly accessible (no .hlxignore entry) and does not load scripts/aem.js or scripts/scripts.js, unlike every other tool in tools/. This is fine for a pure debug page but inconsistent with the project pattern.
  • It loads Google Fonts from an external CDN (fonts.googleapis.com) — a performance dependency that isn't gated through lazy-styles.css / delayed.js.
  • It contains hardcoded references to the feature branch (fix/page-status-byom-no-source) which will become stale after merge.

Recommendation: If the file is kept, add it to .hlxignore so it isn't publicly crawlable, and strip the branch-specific nav links. If it was only added so reviewers could trace the classification paths interactively, consider removing it before merging.


What's Good

  • Fix is correct. new Date(null) returns the Unix epoch (a valid date), silently misclassifying BYOM pages. The null ?? NaN guard is the right approach — it converts both null and undefined to NaN before new Date(), producing Invalid Date and falling through to the preview/publish state logic.
  • Refactoring is clean. Extracting classifySequenceStatus() into a pure module makes the function independently testable and reduces buildSequenceStatus() to two lines. No behavior change for source-present paths.
  • Test coverage is thorough. Parametrizing over [undefined, null] pins the ?? NaN guard contract and ensures both call sites are regression-tested. The five with-source regression paths confirm the existing logic is untouched.
  • All branches covered. The classification matrix in the PR description matches the code, and 100% branch coverage is reported.
  • No linting issues — no eslint-disable, no debug console.log, selectors are not applicable here (JS-only modules).

Verdict

APPROVE — the bug fix is correct, well-tested, and cleanly refactored. One optional cleanup item on flows.html noted above.

@somarc somarc force-pushed the fix/page-status-byom-no-source branch from 0e3266a to 4004cb2 Compare May 13, 2026 18:34
@aem-code-sync aem-code-sync Bot temporarily deployed to fix/page-status-byom-no-source May 13, 2026 18:34 Inactive
const previewDate = new Date(preview ?? NaN);
const publishDate = new Date(publish ?? NaN);

if (!valid(editDate)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the edit date may not be valid for non-byom (sharepoint/gdrive authoring) in those cases, non valid edit date indicates the file was deleted from source, and I think we should try to preserve that warning.

somarc and others added 2 commits June 10, 2026 11:25
…ed is null/absent

Fixes #340. Pages without a source date (e.g. BYOM) were always shown as
"No source" (negative) regardless of their preview/publish state. The fix
extracts the classification logic into a pure helper (status.js) that falls
through to preview/publish sequencing when no edit date is present — null
and undefined are both treated as absent via the `?? NaN` guard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@somarc somarc force-pushed the fix/page-status-byom-no-source branch from e09c4c1 to 38e48d5 Compare June 10, 2026 15:26
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.

page-status: BYOM content always shows 'No source'

2 participants