-
Notifications
You must be signed in to change notification settings - Fork 16
Fix: Truncate long issue descriptions to prevent Salesforce overflow #192
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
Open
jag-j
wants to merge
1
commit into
main
Choose a base branch
from
jj/long_description
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Copyright (c) 2019, salesforce.com, inc. | ||
| * All rights reserved. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
| */ | ||
|
|
||
| const { formatToGus } = require('../formatToGus'); | ||
|
|
||
| describe('formatToGus', () => { | ||
| const testUrl = 'https://github.com/test/repo/issues/123'; | ||
|
|
||
| it('should format short markdown content to HTML', () => { | ||
| const body = '# Test Issue\n\nThis is a test issue body.'; | ||
| const result = formatToGus(testUrl, body); | ||
|
|
||
| expect(result).toContain('Github issue link:'); | ||
| expect(result).toContain(testUrl); | ||
| expect(result).toContain('<h1>Test Issue</h1>'); | ||
| expect(result).toContain('<p>This is a test issue body.</p>'); | ||
| }); | ||
|
|
||
| it('should handle empty body', () => { | ||
| const result = formatToGus(testUrl, ''); | ||
|
|
||
| expect(result).toContain('Github issue link:'); | ||
| expect(result).toContain(testUrl); | ||
| }); | ||
|
|
||
| it('should handle null body', () => { | ||
| const result = formatToGus(testUrl, null); | ||
|
|
||
| expect(result).toContain('Github issue link:'); | ||
| expect(result).toContain(testUrl); | ||
| }); | ||
|
|
||
| it('should truncate content exceeding MAX_MARKDOWN_LENGTH', () => { | ||
| // Create a string longer than 10,000 characters | ||
| const longBody = 'A'.repeat(12000); | ||
| const result = formatToGus(testUrl, longBody); | ||
|
|
||
| expect(result).toContain('Content truncated due to length'); | ||
| expect(result).toContain('See full issue on GitHub'); | ||
| // Result should be significantly shorter than the original after truncation | ||
| expect(result.length).toBeLessThan(longBody.length); | ||
| }); | ||
|
|
||
| it('should keep content under 10,000 characters intact', () => { | ||
| const body = 'A'.repeat(9000); | ||
| const result = formatToGus(testUrl, body); | ||
|
|
||
| expect(result).not.toContain('Content truncated'); | ||
| expect(result).toContain('A'.repeat(100)); // Sample check | ||
| }); | ||
|
|
||
| it('should preserve markdown formatting in truncated content', () => { | ||
| const longBody = '# Title\n\n' + 'Content paragraph. '.repeat(1000); | ||
| const result = formatToGus(testUrl, longBody); | ||
|
|
||
| expect(result).toContain('<h1>Title</h1>'); | ||
| expect(result).toContain('Content truncated due to length'); | ||
| }); | ||
|
|
||
| it('should include truncation message at the end when truncated', () => { | ||
| const longBody = 'X'.repeat(15000); | ||
| const result = formatToGus(testUrl, longBody); | ||
|
|
||
| expect(result).toContain('[Content truncated due to length. See full issue on GitHub]'); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there a reason that you're not doing
expect(result).toContain(body)? If it's checking that the result wasn't truncated, then it should check for the untruncated body, right? At the very least, should it check that there are 9000A's in the output?