- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 6.4k
 
test: create remark table plugin tests #8295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 
           The latest updates on your projects. Learn more about Vercel for GitHub. 
  | 
    
          Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@            Coverage Diff             @@
##             main    #8295      +/-   ##
==========================================
+ Coverage   76.53%   76.66%   +0.13%     
==========================================
  Files         117      118       +1     
  Lines        9733     9793      +60     
  Branches      329      335       +6     
==========================================
+ Hits         7449     7508      +59     
- Misses       2282     2283       +1     
  Partials        2        2              ☔ View full report in Codecov by Sentry.  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the table cell boundary check and moves the cell.data initialization to occur after the boundary check instead of before. The changes ensure that cells with indices beyond the header columns are properly handled without unnecessary data initialization.
- Fixed the boundary condition from 
idx > headerLabels.lengthtoidx > headerLabels.length - 1to correctly identify cells beyond header bounds - Moved 
cell.data ??= {}initialization to occur after the boundary check to avoid initializing data for out-of-bounds cells - Added comprehensive test suite covering various edge cases including extra columns, complex headers, and empty cells
 
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description | 
|---|---|
| apps/site/util/table.ts | Fixed boundary check logic and reordered cell.data initialization to happen after validation | 
| apps/site/util/tests/table.test.mjs | Added comprehensive test suite with 8 test cases covering normal operation and edge cases | 
Comments suppressed due to low confidence (1)
apps/site/util/table.ts:42
- Direct assignment to 
cell.data.hPropertieswill overwrite any existing properties. The test case 'should preserve existing cell data and merge with new hProperties' expects existinghProperties(likeclassName: 'existing-class') to be preserved, but this assignment will replace them. Use object spread to merge:cell.data.hProperties = { ...cell.data.hProperties, 'data-label': headerLabels[idx] }; 
          cell.data.hProperties = {
            'data-label': headerLabels[idx],
          };
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean
Description
Create some tests for remark table plguin
Validation
pnpm testCheck List
pnpm formatto ensure the code follows the style guide.pnpm testto check if all tests are passing.pnpm buildto check if the website builds without errors.