Skip to content

Conversation

@Rishi2600
Copy link

@Rishi2600 Rishi2600 commented Dec 12, 2025

What kind of change does this PR introduce?

  • Adds Cypress component tests for the hiddenElements utility function from lib/markdownUtils.ts.

Issue Number:

Changes

Created cypress/components/lib/markdownUtils.cy.ts with 3 test cases:

  1. Multiple elements: hiddenElements('Header', 'Footer', 'Sidebar')
  2. Empty input: hiddenElements()
  3. Single element: hiddenElements('Navbar')

Document on how you can check the code without testing (Just for documentation and clarity)

const hiddenElements = (...elements) => {
  return elements.reduce((acc, element) => {
    return {
      ...acc,
      [element]: { component: () => null },
    };
  }, {});
};

console.log('Test 1:', hiddenElements('A', 'B', 'C'));
console.log('Test 2:', hiddenElements());
console.log('Test 3:', hiddenElements('Single'));

This is going to show an output like

'Test 1:' {
  A: { component: [Function: component] },
  B: { component: [Function: component] },
  C: { component: [Function: component] }
}
'Test 2:' {}
'Test 3:' { Single: { component: [Function: component] } }

Test Results

image

Testing

# Run the specific test file
yarn cypress run --component --spec "cypress/components/lib/markdownUtils.cy.ts"

# Or run all component tests
yarn cypress run --component

Also, note on pre-commit hook failure -
The pre-commit hook failed due to existing build issues unrelated to this PR:

  • JSON parsing error in /ambassadors page
  • Missing file: _includes/community/programs/contractors/contractors.json
    I thought not to touch the main branch without permission, so I left that.

Verification steps (I've tested them all manually before commit)
Verification Steps

  1. TypeScript compiles: yarn typecheck
  2. Linting passes: yarn lint
  3. Tests pass: yarn cypress run --component --spec "cypress/components/lib/markdownUtils.cy.ts"
  4. No production code changes: Only test file added.

Future Work

This PR establishes a testing pattern for markdownUtils.ts. Future PRs can add tests for:

  • transformMarkdownLinks
  • checkHasContent
  • parseTabsFromMarkdown

Adds test coverage without modifying production code, using the project's existing testing infrastructure.

@Rishi2600 Rishi2600 requested a review from a team as a code owner December 12, 2025 09:57
@github-project-automation github-project-automation bot moved this to Ready to review in PR - Triage Group Dec 12, 2025
@github-actions
Copy link

Hi @Rishi2600! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: issue reference, kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Dec 12, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview 99a07e8

@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a822963) to head (99a07e8).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1994   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines          633       633           
  Branches       196       196           
=========================================
  Hits           633       633           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

Hi @Rishi2600! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: issue reference, kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@Rishi2600
Copy link
Author

Rishi2600 commented Dec 12, 2025

Hello @Utkarsh-123github @Relequestual @DhairyaMajmudar @benjagm, hope you are doing well.
Can you have a glance at this? I'd appreciate your reviews if you have a moment. Thanks!

@vtushar06
Copy link
Contributor

Hii @jagpreetrahi, can you guide here us for next step.

@Rishi2600
Copy link
Author

Hey @vtushar06, just checking out if there are any updates you can help me with

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready to review

Development

Successfully merging this pull request may close these issues.

Add unit tests for markdownUtils hiddenElements

2 participants