-
Notifications
You must be signed in to change notification settings - Fork 32
fix: table layout overflow #142
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
70109e1
feat: terminal-width-aware table rendering with card layout fallback
felipefreitag 434aee9
fix: don't trigger card fallback for naturally narrow columns
felipefreitag 13b8e06
fix: remove truncation entirely, switch directly to cards when table …
felipefreitag 9bddc0d
refactor: remove unused ColumnOption type and columns parameter
felipefreitag 7252cb5
fix: unexport getTerminalWidth, pass termWidth to renderCards, widen …
felipefreitag 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
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
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,118 @@ | ||
| import { describe, expect, test } from 'vitest'; | ||
| import { renderDnsRecordsTable } from '../../../src/commands/domains/utils'; | ||
|
|
||
| describe('renderDnsRecordsTable', () => { | ||
| test('returns empty message when no records', () => { | ||
| expect(renderDnsRecordsTable([], 'example.com')).toBe('(no DNS records)'); | ||
| }); | ||
|
|
||
| test('renders a card per record with type separator', () => { | ||
| const output = renderDnsRecordsTable( | ||
| [ | ||
| { | ||
| record: 'SPF', | ||
| type: 'MX', | ||
| name: 'send', | ||
| ttl: 'Auto', | ||
| status: 'verified', | ||
| value: 'feedback-smtp.us-east-1.amazonses.com', | ||
| priority: 10, | ||
| }, | ||
| ], | ||
| 'example.com', | ||
| ); | ||
|
|
||
| expect(output).toContain('MX'); | ||
| expect(output).toContain('Name send.example.com'); | ||
| expect(output).toContain('TTL Auto'); | ||
| expect(output).toContain('Value feedback-smtp.us-east-1.amazonses.com'); | ||
| }); | ||
|
|
||
| test('expands short name with domain suffix', () => { | ||
| const output = renderDnsRecordsTable( | ||
| [ | ||
| { | ||
| record: 'DKIM', | ||
| type: 'TXT', | ||
| name: 'dkim', | ||
| ttl: 'Auto', | ||
| status: 'pending', | ||
| value: 'p=MIIG...', | ||
| priority: 0, | ||
| }, | ||
| ], | ||
| 'send.example.com', | ||
| ); | ||
|
|
||
| expect(output).toContain('Name dkim.send.example.com'); | ||
| }); | ||
|
|
||
| test('keeps FQDN name as-is', () => { | ||
| const output = renderDnsRecordsTable( | ||
| [ | ||
| { | ||
| record: 'SPF', | ||
| type: 'TXT', | ||
| name: 'send.example.com', | ||
| ttl: 'Auto', | ||
| status: 'verified', | ||
| value: 'v=spf1 include:amazonses.com ~all', | ||
| priority: 0, | ||
| }, | ||
| ], | ||
| 'example.com', | ||
| ); | ||
|
|
||
| expect(output).toContain('Name send.example.com'); | ||
| }); | ||
|
|
||
| test('uses domain name when record name is empty', () => { | ||
| const output = renderDnsRecordsTable( | ||
| [ | ||
| { | ||
| record: 'SPF', | ||
| type: 'TXT', | ||
| name: '', | ||
| ttl: 'Auto', | ||
| status: 'verified', | ||
| value: 'v=spf1', | ||
| priority: 0, | ||
| }, | ||
| ], | ||
| 'example.com', | ||
| ); | ||
|
|
||
| expect(output).toContain('Name example.com'); | ||
| }); | ||
|
|
||
| test('separates multiple records with blank line', () => { | ||
| const output = renderDnsRecordsTable( | ||
| [ | ||
| { | ||
| record: 'SPF', | ||
| type: 'MX', | ||
| name: 'send', | ||
| ttl: 'Auto', | ||
| status: 'verified', | ||
| value: 'mx.example.com', | ||
| priority: 10, | ||
| }, | ||
| { | ||
| record: 'DKIM', | ||
| type: 'TXT', | ||
| name: 'resend._domainkey', | ||
| ttl: 'Auto', | ||
| status: 'pending', | ||
| value: 'p=MIIG...', | ||
| priority: 0, | ||
| }, | ||
| ], | ||
| 'example.com', | ||
| ); | ||
|
|
||
| const cards = output.split('\n\n'); | ||
| expect(cards).toHaveLength(2); | ||
| expect(cards[0]).toContain('MX'); | ||
| expect(cards[1]).toContain('TXT'); | ||
| }); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.