Skip to content
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

Refactored src/screens/UserPortal/Volunteer/Invitations from jest to vitest #2691

Closed

Conversation

syedali237
Copy link
Contributor

@syedali237 syedali237 commented Dec 20, 2024

What kind of change does this PR introduce?

Refactoring & Bugfix

Issue Number:

Fixes #2583

Did you add tests for your changes?

Yes

Snapshots/Videos:

Screenshot 2024-12-20 at 7 11 22 PM Screenshot 2024-12-20 at 7 11 10 PM

If relevant, did you update the documentation?
No

Summary

Refactored the test case to be run using vitest.

Does this PR introduce a breaking change?

No

Other information
Changed the tagTemplate.ts file, it was giving error while commiting updated the schema to the latest documentation.

Screenshot 2024-12-20 at 7 17 41 PM

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • New Features

    • Enhanced structure of the tagTemplate for improved schema definition.
  • Bug Fixes

    • Updated testing framework from Jest to Vitest, improving test management and mock handling.
  • Chores

    • Adjusted string formatting in the basePdf property to comply with JSON standards.

Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

Walkthrough

This pull request involves two primary changes: a structural modification in the tagTemplate.ts file and a migration of the Invitations.spec.tsx test file from Jest to Vitest. In the tagTemplate.ts, the schemas property has been restructured to use a nested array format, potentially affecting how templates are processed. The Invitations.spec.tsx file has been updated to use Vitest-specific mocking and testing functions, replacing Jest-specific implementations.

Changes

File Change Summary
src/components/CheckIn/tagTemplate.ts Restructured schemas to a nested array and updated basePdf quote style; added ExtendedSchema type and modified tagTemplate type definition.
src/screens/UserPortal/Volunteer/Invitations/Invitations.spec.tsx Migrated from Jest to Vitest, updated mocking and testing functions, and removed Jest-specific setup.

Assessment against linked issues

Objective Addressed Explanation
Replace Jest-specific functions with Vitest equivalents [#2583]
Ensure tests pass using npm run test:vitest [#2583] Requires full test suite verification.
Maintain 100% test coverage [#2583] Requires coverage report confirmation.

Possibly related issues

Possibly related PRs

Suggested reviewers

  • palisadoes

Poem

🐰 Hopping through code with glee,
Jest transforms to Vitest, can't you see?
Nested schemas dance and play,
Refactoring leads the testing way!
A rabbit's leap of pure delight, 🌟
Making our test suite shine so bright! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Our Pull Request Approval Process

Thanks for contributing!

Testing Your Code

Remember, your PRs won't be reviewed until these criteria are met:

  1. We don't merge PRs with poor code quality.
    1. Follow coding best practices such that CodeRabbit.ai approves your PR.
  2. We don't merge PRs with failed tests.
    1. When tests fail, click on the Details link to learn more.
    2. Write sufficient tests for your changes (CodeCov Patch Test). Your testing level must be better than the target threshold of the repository
    3. Tests may fail if you edit sensitive files. Ask to add the ignore-sensitive-files-pr label if the edits are necessary.
  3. We cannot merge PRs with conflicting files. These must be fixed.

Our policies make our code better.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 371327e and 0acbfac.

📒 Files selected for processing (2)
  • src/components/CheckIn/tagTemplate.ts (1 hunks)
  • src/screens/UserPortal/Volunteer/Invitations/Invitations.spec.tsx (2 hunks)
🧰 Additional context used
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
src/components/CheckIn/tagTemplate.ts

[failure] 7-7:
Object literal may only specify known properties, and '"name"' does not exist in type '{ type: "text"; height: number; width: number; position: { x: number; y: number; }; rotate?: number | undefined; alignment?: "center" | "left" | "right" | undefined; fontSize?: number | undefined; ... 5 more ...; dynamicFontSize?: { ...; } | undefined; }'.

🔇 Additional comments (2)
src/screens/UserPortal/Volunteer/Invitations/Invitations.spec.tsx (2)

97-97: LGTM! Test cleanup properly migrated to Vitest.

The test cleanup is correctly updated to use vi.clearAllMocks() instead of jest.clearAllMocks().


24-40: LGTM! Mock implementations properly migrated to Vitest.

The migration from Jest to Vitest looks good. The mock implementations are correctly updated and the new mock for react-router-dom provides appropriate custom implementations for hooks.

✅ Verification successful

Based on the search results, I can see that there are still many test files using Jest mocks (jest.mock and jest.fn), while some files have been migrated to use Vitest mocks (vi.mock and vi.fn). The file under review (src/screens/UserPortal/Volunteer/Invitations/Invitations.spec.tsx) has been properly migrated to use Vitest mocks.

Migration to Vitest mocks looks good, but other test files need similar updates

The changes in this file correctly replace Jest mocks with Vitest equivalents:

  • jest.mock -> vi.mock
  • jest.fn -> vi.fn

However, there are many other test files that still need to be migrated from Jest to Vitest mocks. This is not a blocker for this PR since we want to keep changes focused and manageable.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all Jest mocks have been migrated to Vitest

# Test: Search for any remaining Jest mocks
rg "jest\.mock" 
rg "jest\.fn"

# Test: Verify Vitest mocks are used instead
rg "vi\.mock"
rg "vi\.fn"

Length of output: 64949

src/components/CheckIn/tagTemplate.ts Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

🧹 Nitpick comments (1)
src/components/CheckIn/tagTemplate.ts (1)

22-22: Use consistent quote style

For consistency with JSON format, use double quotes for the basePdf property value.

Apply this diff to fix the quote style:

-  "basePdf":
-    'data:application/pdf;base64,JVBERi0xLjQKJfbk/N8KMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovVmVyc2lvbiAvMS40Ci9QYWdlcyAyIDAgUgovU3RydWN0VHJlZVJvb3QgMyAwIFIKL01hcmtJbmZvIDQgMCBSCi9MYW5nIChlbikKL1ZpZXdlclByZWZlcmVuY2VzIDUgMCBSCj4+CmVuZG9iago2IDAgb2JqCjw8Ci9DcmVhdG9yIChDYW52YSkKL1Byb2R1Y2VyIChDYW52YSkKL0NyZWF0aW9uRGF0ZSAoRDoyMDIzMDYyMDA3MjgxMyswMCcwMCcpCi9Nb2REYXRlIChEOjIwMjMwNjIwMDcyODEzKzAwJzAwJykKL0tleXdvcmRzIChEQUZjMjhYSXViTSxCQUUycS01WEdhaykKL0F1dGhvciAoRXNoYWFuIEFnZ2Fyd2FsKQovVGl0bGUgKEJsYW5rIE5hbWUgVGFnIGluIEVtZXJhbGQgTWludCBHcmVlbiBBc3BpcmF0aW9uYWwgRWxlZ2FuY2UgU3R5bGUpCj4+CmVuZG9iagoyIDAgb2JqCjw8Ci9UeXBlIC9QYWdlcwovS2lkcyBbNyAwIFJdCi9Db3VudCAxCj4+CmVuZG9iagozIDAgb2JqCjw8Ci9UeXBlIC9TdHJ1Y3RUcmVlUm9vdAovUGFyZW50VHJlZSA4IDAgUgovUGFyZW50VHJlZU5leHRLZXkgMQovSyBbOSAwIFJdCi9JRFRyZWUgMTAgMCBSCj4+CmVuZG9iago0IDAgb2JqCjw8Ci9NYXJrZWQgdHJ1ZQovU3VzcGVjdHMgZmFsc2UKPj4KZW5kb2JqCjUgMC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Cj4+CnN0cmVhbQ0KeJzsfQl4FNeVbgupN6GuajDYY1tIIpPJm8dbJhkyb5LJTIaZJCaYRRvCwTEOjmNi42DAZjGLpNbGamOMgVgJGGMMxo3QvqKltQsBXuKQxFlmPEPGkziLd0BSd6vfuefcul29SOqWhBa7zldff6VWdS337vnv2Y8k6aSTTjrppJNOOumkk0466aSTTjrppJNOOumkk0466aSTTjrppJNOOumkk0466aSTTjrppJNOOumkk0466aSTTp9Y8sI2T/KulrzFkrdL8l6SvM2St0ryOvCzGb+B79+UvG9JXu94365OOul0Ywi42/uO5H0RMcEueZ3I+7Q51E1848Tjf4ew8I6ODDrp9Ikixt20XWbM7noqpq/U5GoyulqNrgajq9roLjW6qozueqO7xeRymnpeiWEHX8Lj6VeO8X4G

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch</summary>

[failure] 22-22: 
';' expected.

</details>

</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yaml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 0acbfac30276e685fdc64e3997606c4ad3401d21 and 7b9274fafadca2de4ba97aef33bbc44f3f8956a2.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `src/components/CheckIn/tagTemplate.ts` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🪛 Biome (1.9.4)</summary>

<details>
<summary>src/components/CheckIn/tagTemplate.ts</summary>

[error] 21-21: Expected a property, a shorthand property, a getter, a setter, or a method but instead found ']'.

Expected a property, a shorthand property, a getter, a setter, or a method here.


(parse)

</details>

</details>
<details>
<summary>🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch</summary>

<details>
<summary>src/components/CheckIn/tagTemplate.ts</summary>

[failure] 21-21: 
Property assignment expected.

---

[failure] 21-21: 
Declaration or statement expected.

---

[failure] 22-22: 
';' expected.

</details>

</details>

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

src/components/CheckIn/tagTemplate.ts Outdated Show resolved Hide resolved
@palisadoes
Copy link
Contributor

Please fix:

  1. Any failing tests (Click on the details link for more information)
  2. Any conflicting files

Make sure CodeRabbit.ai approves your changes

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b9274f and e17d70d.

📒 Files selected for processing (1)
  • src/components/CheckIn/tagTemplate.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
src/components/CheckIn/tagTemplate.ts

[failure] 7-7:
Object literal may only specify known properties, and '"name"' does not exist in type '{ type: "text"; height: number; width: number; position: { x: number; y: number; }; rotate?: number | undefined; alignment?: "center" | "left" | "right" | undefined; fontSize?: number | undefined; ... 5 more ...; dynamicFontSize?: { ...; } | undefined; }'.

🔇 Additional comments (1)
src/components/CheckIn/tagTemplate.ts (1)

21-21: LGTM: Base PDF data is properly encoded

The base64 encoded PDF data is correctly formatted.

src/components/CheckIn/tagTemplate.ts Outdated Show resolved Hide resolved
@syedali237
Copy link
Contributor Author

@palisadoes I have updated the template schema to align with the documentation provided by pdfme.
After making the necessary adjustments to the schema, the typecheck now passes successfully when run locally (npm run typecheck shows no errors).

Screenshot 2024-12-21 at 4 52 07 PM

However, the GitHub action is still failing with the same type error, as shown below:

Screenshot 2024-12-21 at 4 46 52 PM

It’s unclear why this discrepancy is happening, as the error is no longer reproducible locally. Could this be related to differences in the CI environment, such as cached dependencies or an outdated @pdfme/common package?

Any insights or suggestions to resolve this issue?

From the documentation below its clear that 'name' property does exist.

Screenshot 2024-12-21 at 4 39 25 PM

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 21, 2024
@palisadoes
Copy link
Contributor

Please fix the failing tests. Our test code coverage system will fail if any of these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. The code does not comply with our linting check or other related formatting requirements

Here are some steps to take:

  1. Click on the Details link for the tests to get an explanation of the cause(s)
  2. You may have to fix a test that is not related to this PR as in some rare cases we merge faulty test code. If this is the case, fix the test in this PR. Do not open another issue.

We do this to ensure the overall reliability of the code base is maintained. This is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Additional notes:

  1. Ensure that CodeRabbit.ai approves your work
  2. Please fix any conflicting files

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e17d70d and 6816eff.

📒 Files selected for processing (1)
  • src/components/CheckIn/tagTemplate.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
src/components/CheckIn/tagTemplate.ts

[failure] 7-7:
Object literal may only specify known properties, and '"name"' does not exist in type '{ type: "text"; height: number; width: number; position: { x: number; y: number; }; rotate?: number | undefined; alignment?: "center" | "left" | "right" | undefined; fontSize?: number | undefined; ... 5 more ...; dynamicFontSize?: { ...; } | undefined; }'.

🔇 Additional comments (1)
src/components/CheckIn/tagTemplate.ts (1)

4-19: Verify the nested array schema structure.

The schema has been restructured as a nested array [[{...}]]. While this matches the @pdfme/common documentation, we should verify that all consumers of this template are updated to handle the new structure.

✅ Verification successful

Let me verify the usage of the @pdfme/common library and its expected schema structure.


Let me check the actual usage in the code to verify if the nested array structure is being handled correctly.


The nested array schema structure is valid and compatible with existing usage.

The verification shows that:

  1. The template is only used in TableRow.tsx with the @pdfme/generator's generate function
  2. The code correctly handles the template by passing it directly to the generate function along with properly formatted inputs
  3. The nested array structure [[{...}]] is compatible with the Template type from @pdfme/common

The schema restructuring doesn't impact the consumers as they interact with the template through the @pdfme/generator API which expects this exact format.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of tagTemplate to verify compatibility with new schema structure
rg -A 5 "tagTemplate" --type ts

Length of output: 1353


Script:

#!/bin/bash
# Check imports of @pdfme/common to understand the expected Template type
rg "@pdfme/common" --type ts -A 2

# Find any other template definitions in the codebase for comparison
ast-grep --pattern 'Template = {
  $$$
}'

Length of output: 698


Script:

#!/bin/bash
# Check how the template is being used in TableRow.tsx
cat src/components/CheckIn/TableRow.tsx

Length of output: 3671

🧰 Tools
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch

[failure] 7-7:
Object literal may only specify known properties, and '"name"' does not exist in type '{ type: "text"; height: number; width: number; position: { x: number; y: number; }; rotate?: number | undefined; alignment?: "center" | "left" | "right" | undefined; fontSize?: number | undefined; ... 5 more ...; dynamicFontSize?: { ...; } | undefined; }'.

src/components/CheckIn/tagTemplate.ts Outdated Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 21, 2024
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

🧹 Nitpick comments (1)
src/components/CheckIn/tagTemplate.ts (1)

25-25: Consider using template literals for base64 data.

The long base64 string could be better formatted using template literals for improved readability.

-  "basePdf": 'data:application/pdf;base64,JVBERi0...',
+  "basePdf": `data:application/pdf;base64,
+    JVBERi0...
+  `,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6816eff and 8648cf0.

📒 Files selected for processing (1)
  • src/components/CheckIn/tagTemplate.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
src/components/CheckIn/tagTemplate.ts

[failure] 11-11:
Object literal may only specify known properties, and '"name"' does not exist in type '{ type: "text"; height: number; width: number; position: { x: number; y: number; }; rotate?: number | undefined; alignment?: "center" | "left" | "right" | undefined; fontSize?: number | undefined; ... 5 more ...; dynamicFontSize?: { ...; } | undefined; }'.

🔇 Additional comments (2)
src/components/CheckIn/tagTemplate.ts (2)

3-6: 🛠️ Refactor suggestion

Consider using interface extension instead of type alias for better type safety.

The current type definition might not properly extend the base schema type. Consider using an interface that extends the base schema type from @pdfme/common:

-type ExtendedSchema = {
-  name? : string;
-}
+interface ExtendedSchema extends TextSchema {
+  name?: string;
+}

This approach ensures proper type extension and better type checking.

Likely invalid or redundant comment.


1-25: Verify PDF template compatibility.

The template structure has been modified. Please ensure that:

  1. The PDF template is compatible with the current version of @pdfme/common
  2. All required fields are properly mapped
  3. The base64 PDF data is valid

Run this script to verify template compatibility:

✅ Verification successful

Based on the gathered information, I can now provide the final response:

Template structure and dependencies are correctly configured

The verification shows that:

  • @pdfme dependencies are properly installed (@pdfme/generator: ^5.2.3)
  • Template structure follows @pdfme/common type definition
  • Template is correctly used with the generate function in TableRow.tsx
  • Input validation is implemented before PDF generation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify template structure and PDF compatibility

# Check @pdfme/common version and types
npm ls @pdfme/common

# Find all usages of the template
rg -A 5 "tagTemplate" 

# Verify PDF data is valid base64
echo "${basePdf#*,}" | base64 -d > /dev/null 2>&1

Length of output: 3818


Script:

#!/bin/bash
# Let's verify the template structure and its usage more thoroughly

# Check if @pdfme/common is in package.json dependencies
rg "@pdfme/common" package.json

# Find imports of @pdfme/common across the codebase
rg "from '@pdfme/common'"

# Look for Template type usage and structure
rg -A 10 "Template.*from.*@pdfme/common"

# Check how the template is being used with generate function
ast-grep --pattern 'generate({ template: $_, inputs: $_ })'

Length of output: 3467


Script:

#!/bin/bash
# Let's check the package dependencies and generator usage

# Check package.json for all @pdfme related dependencies
rg -A 1 -B 1 "\"@pdfme/" package.json

# Look for the generate import and its usage
rg -A 2 "import.*generate.*from.*@pdfme"

# Check TableRow.tsx more thoroughly for template usage
cat src/components/CheckIn/TableRow.tsx

Length of output: 4137

🧰 Tools
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch

[failure] 11-11:
Object literal may only specify known properties, and '"name"' does not exist in type '{ type: "text"; height: number; width: number; position: { x: number; y: number; }; rotate?: number | undefined; alignment?: "center" | "left" | "right" | undefined; fontSize?: number | undefined; ... 5 more ...; dynamicFontSize?: { ...; } | undefined; }'.

src/components/CheckIn/tagTemplate.ts Outdated Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 21, 2024
@syedali237
Copy link
Contributor Author

Here, the linting check gives an error that the "name" property does not exist on the type Template, even though it's clearly defined as z.ZodString on the type Template. Running npm run typecheck locally doesn't show any issues, but it's failing on GitHub Actions.
Has anyone have suggestions regarding this?

Screenshot 2024-12-22 at 12 39 09 AM Screenshot 2024-12-22 at 12 38 57 AM

@IITI-tushar
Copy link
Contributor

In tagTemplate.ts try changing "name" to name as given in here https://pdfme.com/docs/getting-started#template
image

@IITI-tushar
Copy link
Contributor

@syedali237 try removing double quotes from name , schema , type....
From hereScreenshot_20241222-180130.png

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

🧹 Nitpick comments (1)
src/components/CheckIn/tagTemplate.ts (1)

25-25: Consider externalizing the base64 PDF data.

The large base64 encoded PDF string embedded in the code makes the file harder to maintain. Consider moving it to a separate asset file.

  1. Create a separate file like nameTagTemplate.pdf.ts
  2. Export the base64 string from there
  3. Import and use it in this file
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8648cf0 and c0a54d3.

📒 Files selected for processing (1)
  • src/components/CheckIn/tagTemplate.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
src/components/CheckIn/tagTemplate.ts

[failure] 11-11:
Object literal may only specify known properties, and 'name' does not exist in type '{ type: "text"; height: number; width: number; position: { x: number; y: number; }; rotate?: number | undefined; alignment?: "center" | "left" | "right" | undefined; fontSize?: number | undefined; ... 5 more ...; dynamicFontSize?: { ...; } | undefined; }'.

🔇 Additional comments (1)
src/components/CheckIn/tagTemplate.ts (1)

7-24: ⚠️ Potential issue

Fix type error in schema definition.

The 'name' property is causing a type error because it's not part of the base TextSchema type. This needs to be fixed to ensure type safety.

Apply one of these solutions:

  1. Use the field property as per pdfme documentation:
-        name: "name",
+        field: "name",
  1. Or use the ExtendedSchema interface as suggested above:
-export const tagTemplate: Template & ExtendedSchema = {
+export const tagTemplate: Template<ExtendedSchema> = {

Likely invalid or redundant comment.

🧰 Tools
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch

[failure] 11-11:
Object literal may only specify known properties, and 'name' does not exist in type '{ type: "text"; height: number; width: number; position: { x: number; y: number; }; rotate?: number | undefined; alignment?: "center" | "left" | "right" | undefined; fontSize?: number | undefined; ... 5 more ...; dynamicFontSize?: { ...; } | undefined; }'.

src/components/CheckIn/tagTemplate.ts Show resolved Hide resolved
@syedali237
Copy link
Contributor Author

@IITI-tushar this didn't work..

@IITI-tushar
Copy link
Contributor

@syedali237 why have you make changes in tag templates?
Try to update the file as given in develop-postgres branch.

@syedali237
Copy link
Contributor Author

syedali237 commented Dec 22, 2024

@syedali237 why have you make changes in tag templates? Try to update the file as given in develop-postgres branch.

@IITI-tushar it was giving an error while committing, I did mention that earlier. I tried committing the original file from the develop-postgres branch but still the same error arises. so had to fix it

Although it pass npm run typecheck on my system locally but here it is failing.

@IITI-tushar
Copy link
Contributor

@syedali237 I have recently made 2 prs and there was no error with tagtemplates
Try to run lint:fix and format:fix .

@syedali237
Copy link
Contributor Author

@syedali237 I have recently made 2 prs and there was no error with tagtemplates Try to run lint:fix and format:fix .

the file tagTemplate is already in .eslintignore, lint:fix doesn't cover it, but when typecheck is performed with the original tagTemplate.ts file from develop-postgres then it shows this error, otherwise with my changes it does not throw this error locally but here it fails on Github Actions.

Screenshot 2024-12-22 at 6 49 41 PM

@syedali237
Copy link
Contributor Author

Closing this PR, had issues with my repository.

@syedali237 syedali237 closed this Dec 22, 2024
@syedali237 syedali237 deleted the issue-2583 branch December 22, 2024 16:16
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.

3 participants