-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat:Added collection name and minor UI changes to the generate doc modal #8391
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
sachin-bruno
wants to merge
3
commits into
usebruno:main
Choose a base branch
from
sachin-bruno:sachin-bruno/feature-environment-selection
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.
+110
−50
Open
Changes from 1 commit
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
Some comments aren't visible on the classic Files Changed page.
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
97 changes: 97 additions & 0 deletions
97
.../Sidebar/Collections/Collection/GenerateDocumentation/CollectionVersionInfo/index.spec.js
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,97 @@ | ||
| import '@testing-library/jest-dom'; | ||
| import React from 'react'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import CollectionVersionInfo from './index'; | ||
|
|
||
| describe('CollectionVersionInfo', () => { | ||
| describe('collection name', () => { | ||
| it('renders the collection name in the collection-name slot', () => { | ||
| render(<CollectionVersionInfo name="Hotel Booking API" version="1.2.0" />); | ||
| expect(screen.getByTestId('collection-name')).toHaveTextContent('Hotel Booking API'); | ||
| }); | ||
|
|
||
| it('keeps the name and the version in separate slots', () => { | ||
| render(<CollectionVersionInfo name="Hotel Booking API" version="1.2.0" />); | ||
|
|
||
| const nameSlot = screen.getByTestId('collection-name'); | ||
| const versionSlot = screen.getByTestId('version-value'); | ||
|
|
||
| // Name lives only in the name slot, version only in the version slot. | ||
| expect(nameSlot).toHaveTextContent('Hotel Booking API'); | ||
| expect(nameSlot).not.toHaveTextContent('v1.2.0'); | ||
| expect(versionSlot).toHaveTextContent('v1.2.0'); | ||
| expect(versionSlot).not.toHaveTextContent('Hotel Booking API'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('version formatting', () => { | ||
| it('renders a full semver with a v prefix', () => { | ||
| render(<CollectionVersionInfo name="API" version="1.2.0" />); | ||
| expect(screen.getByTestId('version-value')).toHaveTextContent('v1.2.0'); | ||
| }); | ||
|
|
||
| it('coerces a bare major version to major.minor.patch', () => { | ||
| render(<CollectionVersionInfo name="API" version="1" />); | ||
| expect(screen.getByTestId('version-value')).toHaveTextContent('v1.0.0'); | ||
| }); | ||
|
|
||
| it('coerces a partial major.minor version to major.minor.patch', () => { | ||
| render(<CollectionVersionInfo name="API" version="2.1" />); | ||
| expect(screen.getByTestId('version-value')).toHaveTextContent('v2.1.0'); | ||
| }); | ||
|
|
||
| it('does not double-prefix an already v-prefixed version', () => { | ||
| render(<CollectionVersionInfo name="API" version="v1.2.0" />); | ||
| const versionSlot = screen.getByTestId('version-value'); | ||
| expect(versionSlot).toHaveTextContent('v1.2.0'); | ||
| expect(versionSlot).not.toHaveTextContent('vv'); | ||
| }); | ||
|
|
||
| it('preserves a pre-release suffix', () => { | ||
| render(<CollectionVersionInfo name="API" version="1.0.0-beta" />); | ||
| expect(screen.getByTestId('version-value')).toHaveTextContent('v1.0.0-beta'); | ||
| }); | ||
|
|
||
| it('falls back to the default version when unset', () => { | ||
| render(<CollectionVersionInfo name="API" />); | ||
| expect(screen.getByTestId('version-value')).toHaveTextContent('v1.0.0'); | ||
| }); | ||
|
|
||
| it('falls back to the default version when unparseable', () => { | ||
| render(<CollectionVersionInfo name="API" version="not-a-version" />); | ||
| expect(screen.getByTestId('version-value')).toHaveTextContent('v1.0.0'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('content summary', () => { | ||
| it('pluralises folder and request counts', () => { | ||
| render(<CollectionVersionInfo name="API" version="1.0.0" folderCount={2} requestCount={5} />); | ||
| // Exact-match each count span so a singular/plural regression is caught. | ||
| expect(screen.getByText('2 Folders')).toBeInTheDocument(); | ||
| expect(screen.getByText('5 requests')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('uses singular labels for a single folder and request', () => { | ||
| render(<CollectionVersionInfo name="API" version="1.0.0" folderCount={1} requestCount={1} />); | ||
| expect(screen.getByText('1 Folder')).toBeInTheDocument(); | ||
| expect(screen.getByText('1 request')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('defaults the counts to zero', () => { | ||
| render(<CollectionVersionInfo name="API" version="1.0.0" />); | ||
| expect(screen.getByText('0 Folders')).toBeInTheDocument(); | ||
| expect(screen.getByText('0 requests')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the separator as an aria-hidden decorative dot', () => { | ||
| const { container } = render( | ||
| <CollectionVersionInfo name="API" version="1.0.0" folderCount={2} requestCount={5} /> | ||
| ); | ||
| const dot = container.querySelector('.version-dot'); | ||
| expect(dot).toBeInTheDocument(); | ||
| expect(dot).toHaveAttribute('aria-hidden', 'true'); | ||
| // Decorative only — carries no text. | ||
| expect(dot).toHaveTextContent(''); | ||
| }); | ||
| }); | ||
| }); | ||
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
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
Oops, something went wrong.
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.