Skip to content

chore: maintenance batch — Notion migration, DocCard re-swizzle, regression tests - #182

Closed
luandro wants to merge 9 commits into
mainfrom
chore/notion-data-source-migration
Closed

luandro wants to merge 9 commits into
mainfrom
chore/notion-data-source-migration

Conversation

@luandro

@luandro luandro commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Batch of maintenance tasks identified during the Docusaurus 3.10.1 update review. Each task was implemented, tested, and reviewed individually via Codex before committing.

Changes

1. Notion DATA_SOURCE_ID migration completed (a77f338)

  • Removed deprecated databasesQuery() method from EnhancedNotionClient
  • dataSourcesQuery() is now the sole query method for the Notion v5 API
  • Removed runtime warning when DATA_SOURCE_ID is missing (silent fallback to DATABASE_ID)
  • Updated all tests: databasesQuerydataSourcesQuery, database_iddata_source_id
  • Updated migration docs (context/workflows/translation-process.md) — marked complete
  • Updated testing docs (context/testing/vitest-mocking-best-practices.md) — databases.querydataSources.query
  • DATABASE_ID retained as silent backward-compat fallback (removing it would break 50+ CI/Docker/test files)

2. DocCard re-swizzle for Docusaurus 3.10 (3e7cc47)

  • Merged upstream 3.10 improvements into swizzled src/theme/DocCard/index.tsx
  • Added useDocById from @docusaurus/plugin-content-docs/client for automatic doc descriptions
  • CardLink now falls back to doc.description from frontmatter when item.description is absent
  • Preserved customizations: .cardTitle CSS keeps word-break/overflow-wrap for long titles; heading omits text--truncate (titles wrap, not truncate)

3. Vitest Date mock cleanup (89679a5)

  • Replaced 40-line manual Date constructor override with clean vi.setSystemTime(fixedDate) / vi.useRealTimers()
  • The comment claimed vi.setSystemTime was unavailable in Vitest 4.x — verified it works fine in 4.0.18
  • All 44 generateBlocks tests pass

4. Docusaurus regression tests (58e4201)

Added 29 tests across two new suites that catch breaking changes on future Docusaurus upgrades:

scripts/docusaurus-swizzle-contracts.test.ts (20 tests):

  • Verifies all upstream APIs our swizzled components depend on still exist
  • Checks @theme-original/* source files (TOC, DocSidebar, DocSidebarItem)
  • Validates plugin-content-docs/client exports (useDocById, findFirstSidebarItemLink, useActiveDocContext)
  • Validates theme-common exports (usePluralForm, useHistorySelector)
  • Checks @docusaurus/types type exports (WrapperProps, I18nLocaleConfig, Config)
  • Verifies theme-classic type declarations (@theme/DocCard Props, LocaleDropdownNavbarItem)
  • Checks virtual module declarations in module-type-aliases
  • Uses filesystem checks for type-only/virtual packages (runtime imports fail outside Docusaurus build context)

scripts/docusaurus-config.test.ts (9 tests):

  • Validates config loads without runtime errors
  • Checks required fields (title, url, baseUrl)
  • Validates i18n config (locales: en, pt, es; localeConfigs with labels)
  • Checks presets and plugins arrays
  • Validates customFields (defaultDocsPage, localizedDocKeysByLocale)
  • Verifies markdown.hooks.onBrokenMarkdownLinks config (3.10+ pattern)

5. CHANGELOG update (457d305)

  • Updated stale CHANGELOG.md with 54 commits worth of changes since Jan 2026

6. Minor fix (6e2545b)

  • Fixed hardcoded error message in expectTypeExport helper

Verification

Check Result
tsc --noEmit Clean
ESLint (all changed files) Clean
vitest run (3324 tests) 3292 passed, 32 skipped, 0 failed
docusaurus build (en, pt, es) Success — all 3 locales
Codex review (per-task + full branch) No actionable regressions found

Notes

  • databases.retrieve (not databases.query) is still used in notion-translate, notion-version, and migration/discoverDataSource — this is a different Notion API endpoint, still valid in v5 for retrieving database metadata
  • Broken anchor warnings during build are pre-existing content issues from Notion-generated docs, unrelated to these changes

Greptile Summary

Batch of five maintenance tasks: Notion v5 API migration completion, DocCard re-swizzle for Docusaurus 3.10.1, Vitest Date mock cleanup, new Docusaurus regression test suites, and a CHANGELOG update.

  • Notion migration: databasesQuery() and its DATABASE_ID → data_source_id remapping removed; dataSourcesQuery() is now the only query method. No remaining callers of the old method found anywhere in the codebase.
  • DocCard: useDocById added so doc frontmatter description is surfaced as a card description fallback when item.description is absent; existing word-wrap CSS customizations preserved.
  • Regression tests: Two new suites (docusaurus-swizzle-contracts.test.ts, docusaurus-config.test.ts) verify that swizzled-component upstream APIs and config shape survive future Docusaurus upgrades.

Confidence Score: 5/5

Changes are safe to merge; all modifications are additive tests, a clean API removal with no remaining callers, and a minor DocCard enhancement.

The Notion migration removes a deprecated shim with no remaining callers; the DocCard change is a one-liner description fallback; the new regression suites add coverage without touching production paths. The one non-trivial question — whether vi.setSystemTime without vi.useFakeTimers() fully mocks new Date() in Vitest 4.x — is noted as a suggestion, but the PR author verified all 44 Date-related tests pass.

scripts/notion-fetch/generateBlocks.test.ts — verify vi.useFakeTimers() is not required before vi.setSystemTime() in the project's Vitest version to guard against future breakage.

Important Files Changed

Filename Overview
scripts/notionClient.ts Removed deprecated databasesQuery() method and the DATA_SOURCE_ID missing warning; dataSourcesQuery() is now the sole query path. No remaining callers of databasesQuery found across the codebase.
src/theme/DocCard/index.tsx Added useDocById to pull doc description from frontmatter when item.description is absent; existing CSS customizations preserved.
scripts/notion-fetch/generateBlocks.test.ts Replaced 40-line manual Date constructor override with vi.setSystemTime/vi.useRealTimers(); vi.useFakeTimers() is missing before vi.setSystemTime(), which the Vitest docs require to mock the new Date() constructor.
scripts/docusaurus-swizzle-contracts.test.ts New regression suite verifying upstream Docusaurus APIs still exist; filesystem checks used for virtual/type-only packages. Substring-match assertions (e.g. content.includes("Config")) may produce false-positives.
scripts/docusaurus-config.test.ts New config validation suite covering required fields, i18n, presets, plugins, customFields, and 3.10+ markdown hooks.
package.json Docusaurus bumped from 3.9.2 → 3.10.1, Node requirement raised to >=20.0; eslint and @eslint/js pinned to exact version 9.39.4 without semver range, unlike the rest of devDependencies.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[fetchNotionData / notion-translate] -->|dataSourcesQuery| B[EnhancedNotionClient]
    B --> C[dataSources.query via Notion v5 API]
    B -->|pagesRetrieve / blocksChildrenList| D[pages.retrieve / blocks.children.list]

    subgraph DocCard rendering
        E[DocCard item=link] --> F[useDocById item.docId]
        F -->|doc found| G[doc.description fallback]
        E -->|item.description present| H[item.description used directly]
        G --> I[CardLayout description prop]
        H --> I
    end

    subgraph Regression tests
        J[docusaurus-swizzle-contracts.test.ts] -->|fs checks| K[node_modules source files]
        L[docusaurus-config.test.ts] -->|dynamic import| M[docusaurus.config.ts]
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[fetchNotionData / notion-translate] -->|dataSourcesQuery| B[EnhancedNotionClient]
    B --> C[dataSources.query via Notion v5 API]
    B -->|pagesRetrieve / blocksChildrenList| D[pages.retrieve / blocks.children.list]

    subgraph DocCard rendering
        E[DocCard item=link] --> F[useDocById item.docId]
        F -->|doc found| G[doc.description fallback]
        E -->|item.description present| H[item.description used directly]
        G --> I[CardLayout description prop]
        H --> I
    end

    subgraph Regression tests
        J[docusaurus-swizzle-contracts.test.ts] -->|fs checks| K[node_modules source files]
        L[docusaurus-config.test.ts] -->|dynamic import| M[docusaurus.config.ts]
    end
Loading

Reviews (2): Last reviewed commit: "chore(deps): update Docusaurus from 3.9...." | Re-trigger Greptile

luandro and others added 8 commits June 10, 2026 08:10
Prevents build failures from broken image URLs in Notion content.
…RCE_ID migration

- Remove deprecated databasesQuery() method from EnhancedNotionClient
- dataSourcesQuery() is now the sole query method for v5 API
- Remove runtime warning when DATA_SOURCE_ID is missing (silent fallback)
- Update tests: databasesQuery tests → dataSourcesQuery tests
- Update migration docs: mark migration complete (2026-06)
- Update testing docs: databases.query → dataSources.query examples

DATABASE_ID retained as silent backward-compat fallback.
All 3263 tests pass, typecheck clean.
Merge upstream improvements while preserving custom title wrapping:
- Add useDocById for automatic doc descriptions on CardLink
- Import useDocById from @docusaurus/plugin-content-docs/client
- CardLink now falls back to doc.description from frontmatter

Preserved customizations:
- .cardTitle CSS keeps word-break/overflow-wrap for long titles
- Heading omits text--truncate (titles wrap, not truncate)

Verified: typecheck clean, build succeeds (3 locales).
The comment claimed vi.setSystemTime was unavailable in Vitest 4.x,
but it works fine in 4.0.18. Replace 40-line manual Date constructor
override with clean vi.setSystemTime(fixedDate) / vi.useRealTimers().

All 44 generateBlocks tests pass.
Add two test suites that catch breaking changes when upgrading
Docusaurus:

1. docusaurus-swizzle-contracts.test.ts (20 tests):
   - Verifies all upstream APIs our swizzled components depend on
   - Checks theme-original re-exports (TOC, DocSidebar, DocSidebarItem)
   - Validates plugin-content-docs/client exports (useDocById, etc.)
   - Validates theme-common exports (usePluralForm, useHistorySelector)
   - Checks @docusaurus/types type exports (WrapperProps, I18nLocaleConfig)
   - Verifies theme-classic type declarations (@theme/DocCard Props)
   - Checks virtual module declarations in module-type-aliases
   - Validates DropdownNavbarItem and Icon/Language sources

2. docusaurus-config.test.ts (9 tests):
   - Validates config loads without runtime errors
   - Checks required fields (title, url, baseUrl)
   - Validates i18n config (locales: en, pt, es)
   - Validates localeConfigs for all locales
   - Checks presets and plugins arrays
   - Validates customFields (defaultDocsPage, localizedDocKeysByLocale)
   - Verifies markdown hooks config (3.10+ pattern)

Uses filesystem checks for type-only and virtual packages since
runtime imports fail outside the Docusaurus build context.
Add entries for 54 commits since Jan 2026:
- Docusaurus 3.10.1 upgrade, Node 20 bump, DocCard re-swizzle
- Notion DATA_SOURCE_ID migration completion
- Vitest Date mock cleanup, ESLint fix, lockfile cleanup
- Regression tests for Docusaurus updates
- Fetch-one API, translation strategies, DeepSeek support
- i18n locale detection and dropdown fixes
The error message hardcoded '@docusaurus/types' even though the
function is generic. Use pkgDir parameter instead.
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@socket-security

socket-security Bot commented Jun 19, 2026

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm js-yaml is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ?npm/eslint@9.39.4npm/js-yaml@4.2.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/js-yaml@4.2.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e2545b978

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

import Link from "@docusaurus/Link";
import { findFirstSidebarItemLink } from "@docusaurus/plugin-content-docs/client";
import {
useDocById,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bump Docusaurus before importing useDocById

This imports useDocById, but the committed install still locks @docusaurus/plugin-content-docs to 3.9.2 (bun.lock keeps the 3.9.2 entries and package.json still declares ^3.9.2), while the new contract test itself labels useDocById as added in Docusaurus 3.10. In any install that honors the committed lockfile, including the Docker build with bun install --frozen-lockfile, this DocCard module will fail to resolve that export before the site can build; update the Docusaurus package ranges/lockfile to 3.10.x or avoid the new API.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

🚀 Preview Deployment

Your documentation preview is ready!

Preview URL: https://pr-182.comapeo-docs.pages.dev

🔄 Content: Regenerated 5 pages from Notion (script changes detected)

💡 Tip: Add label fetch-all-pages to test with full content, or fetch-10-pages for broader coverage.

This preview will update automatically when you push new commits to this PR.


Built with commit b92ac35

Comment on lines 279 to 282
it("* matches files in current directory only", () => {
expect(matchesPathFilter("bun.lockb", ["bun.lockb*"])).toBe(true);
expect(matchesPathFilter("bun.lock", ["bun.lockb*"])).toBe(false);
expect(matchesPathFilter("bun.lock", ["bun.lock"])).toBe(true);
expect(matchesPathFilter("bun.lockb", ["bun.lock"])).toBe(false);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Misleading test name and missing wildcard coverage

The test was renamed from verifying bun.lockb* glob behaviour to testing an exact-match pattern ["bun.lock"], but its title still says "* matches files in current directory only". More critically, the production pattern in RECOMMENDED_PATH_FILTERS and DOCKERFILE_COPY_PATTERNS is "bun.lock*" (with wildcard), yet neither assertion here exercises that wildcard — so a regression in glob evaluation against bun.lock* would go undetected by this test case.

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/test-docker/path-filter.test.ts
Line: 279-282

Comment:
**Misleading test name and missing wildcard coverage**

The test was renamed from verifying `bun.lockb*` glob behaviour to testing an exact-match pattern `["bun.lock"]`, but its title still says "* matches files in current directory only". More critically, the production pattern in `RECOMMENDED_PATH_FILTERS` and `DOCKERFILE_COPY_PATTERNS` is `"bun.lock*"` (with wildcard), yet neither assertion here exercises that wildcard — so a regression in glob evaluation against `bun.lock*` would go undetected by this test case.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +117 to +119
it("exports Config type", () => {
expectTypeExport(typesDir, "Config");
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 content.includes("Config") matches any occurrence of the substring, including SiteConfig, DocusaurusConfig, GlobalPluginConfig, etc. If the Config type itself were removed or renamed, the test would still pass as long as any other identifier containing "Config" remains in the file. A word-boundary check (or testing for the export declaration form) would make the assertion meaningful.

Suggested change
it("exports Config type", () => {
expectTypeExport(typesDir, "Config");
});
it("exports Config type", () => {
expectTypeExport(typesDir, "export type Config");
});
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/docusaurus-swizzle-contracts.test.ts
Line: 117-119

Comment:
`content.includes("Config")` matches any occurrence of the substring, including `SiteConfig`, `DocusaurusConfig`, `GlobalPluginConfig`, etc. If the `Config` type itself were removed or renamed, the test would still pass as long as any other identifier containing "Config" remains in the file. A word-boundary check (or testing for the export declaration form) would make the assertion meaningful.

```suggestion
    it("exports Config type", () => {
      expectTypeExport(typesDir, "export type Config");
    });
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

🐳 Docker Image Published

Your Docker image has been built and pushed for this PR.

Image Reference: docker.io/communityfirst/comapeo-docs-api:pr-182

Platforms: linux/amd64, linux/arm64

Testing

To test this image:

docker pull docker.io/communityfirst/comapeo-docs-api:pr-182
docker run -p 3001:3001 docker.io/communityfirst/comapeo-docs-api:pr-182

Built with commit b92ac35

Updates all 11 @docusaurus/* packages:
- @docusaurus/core
- @docusaurus/preset-classic
- @docusaurus/plugin-client-redirects
- @docusaurus/plugin-google-gtag
- @docusaurus/plugin-ideal-image
- @docusaurus/plugin-pwa
- @docusaurus/plugin-sitemap
- @docusaurus/eslint-plugin
- @docusaurus/module-type-aliases
- @docusaurus/tsconfig
- @docusaurus/types

Verified: typecheck clean, build succeeds (3 locales), 3264 tests pass.

Notable upstream changes (3.10.0):
- Docusaurus Faster (Rspack) now stable via future.v4 flag
- DocCard refactored: split into Layout sub-component, emoji extraction,
  useDocById for descriptions (our swizzle uses stable APIs, unaffected)
- React upgraded to v19 internally
- Node 18 dropped (EOL)
@luandro

luandro commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Closing: Notion client migration is obsolete due to content pipeline migration; Docusaurus DocCard and contract test improvements can be cherry-picked to a clean branch.

@luandro luandro closed this Sep 11, 2026
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