Skip to content

Commit

Permalink
Test: Add snapshot test for changelog formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Aug 13, 2021
1 parent ea88432 commit b193771
Show file tree
Hide file tree
Showing 4 changed files with 15,512 additions and 1 deletion.
14 changes: 13 additions & 1 deletion bin/plugin/commands/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,23 @@ async function getChangelog( settings ) {
}
}

let changelog = '';
return formatChangelog( pullRequests );
}

/**
* Formats the changelog string for a given list of pull requests.
*
* @param {IssuesListForRepoResponseItem[]} pullRequests List of pull requests.
*
* @return {string} The formatted changelog string.
*/
function formatChangelog( pullRequests ) {
const groupedPullRequests = groupBy( pullRequests, getIssueType );

const sortedGroups = Object.keys( groupedPullRequests ).sort( sortGroup );

let changelog = '';

for ( const group of sortedGroups ) {
const groupPullRequests = groupedPullRequests[ group ];
const groupEntries = groupPullRequests
Expand Down Expand Up @@ -796,4 +807,5 @@ async function getReleaseChangelog( options ) {
sortGroup,
getTypesByLabels,
getTypesByTitle,
formatChangelog,
};
222 changes: 222 additions & 0 deletions bin/plugin/commands/test/__snapshots__/changelog.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`formatChangelog verify that the changelog is properly formatted 1`] = `
"### Enhancements
#### Components
- components: Use updated range styles. ([33824](https://github.com/WordPress/gutenberg/pull/33824))
- Components: Update snackbar to use framer motion instead of react spring. ([33717](https://github.com/WordPress/gutenberg/pull/33717))
- components: Add new ColorPicker. ([33714](https://github.com/WordPress/gutenberg/pull/33714))
- Components: Promote \`ItemGroup\`. ([33701](https://github.com/WordPress/gutenberg/pull/33701))
#### Block Library
- [Post Featured Image]: Add basic dimension controls. ([31634](https://github.com/WordPress/gutenberg/pull/31634))
#### Site Editor
- Site Editor: Add error boundary. ([33921](https://github.com/WordPress/gutenberg/pull/33921))
#### Widgets Editor
- Add error boundaries to widget screens. ([33771](https://github.com/WordPress/gutenberg/pull/33771))
#### Patterns
- Block patterns: Add translation context on titles. ([33734](https://github.com/WordPress/gutenberg/pull/33734))
#### Document Settings
- Disable spellcheck and autocomplete in permalink slug field. ([33708](https://github.com/WordPress/gutenberg/pull/33708))
#### Template Editor
- Template Mode: Add busy state to template creation modal. ([33076](https://github.com/WordPress/gutenberg/pull/33076))
#### Global Styles
- Dimensions Panel: Add new ToolsPanel component and update spacing supports. ([32392](https://github.com/WordPress/gutenberg/pull/32392))
#### Uncategorized
- Scripts: Use cssnano to minimize CSS files with build. ([33750](https://github.com/WordPress/gutenberg/pull/33750))
- Scripts: Webpack configuration update to minimize CSS. ([33676](https://github.com/WordPress/gutenberg/pull/33676))
### Bug Fixes
#### Block Library
- Fix navigation block appender invalid html. ([33964](https://github.com/WordPress/gutenberg/pull/33964))
- Image Block: Fix issue with canInsertCover not being set to false for empty arrays. ([33863](https://github.com/WordPress/gutenberg/pull/33863))
- Fix justification for button block when selected. ([33739](https://github.com/WordPress/gutenberg/pull/33739))
- [Query Pagination Numbers]: Fix first page's link. ([33629](https://github.com/WordPress/gutenberg/pull/33629))
#### Components
- \`useBreakpointIndex\`: Attach \`resize\` event listener to \`window\` instead of \`document\`. ([33902](https://github.com/WordPress/gutenberg/pull/33902))
- Components: Fix RTL on custom gradient picker. ([33831](https://github.com/WordPress/gutenberg/pull/33831))
- FontSizePicker: Use number values when the initial value is a number. ([33679](https://github.com/WordPress/gutenberg/pull/33679))
- FormTokenField: Avoid error when maxLength value is hit. ([33623](https://github.com/WordPress/gutenberg/pull/33623))
#### Block Editor
- URL Details: Avoid PHP notice when parsing protocol-relative icon URLs. ([33779](https://github.com/WordPress/gutenberg/pull/33779))
- Force link text to wrap in the Link UI when encountering extra long link text. ([33753](https://github.com/WordPress/gutenberg/pull/33753))
- Only show rich preview for image and description if data is available. ([33660](https://github.com/WordPress/gutenberg/pull/33660))
- Improve display of LinkURL menu and fix spacing. ([33652](https://github.com/WordPress/gutenberg/pull/33652))
#### Global Styles
- Site editor: Fix presets for blocks with multiple selectors. ([33951](https://github.com/WordPress/gutenberg/pull/33951))
- Global Styles: Fix Global Styles transient key clash. ([33844](https://github.com/WordPress/gutenberg/pull/33844))
- Global Styles: Avoid rendering duplicate elements stylesheet. ([33680](https://github.com/WordPress/gutenberg/pull/33680))
#### CSS & Styling
- Fix navigation block placeholder preview markup. ([33963](https://github.com/WordPress/gutenberg/pull/33963))
#### Navigation Screen
- Navigation Editor: Avoid React warning when creating a new menu. ([33843](https://github.com/WordPress/gutenberg/pull/33843))
- Fix regressed menu selection dropdown placeholder value for Nav Editor menu locations UI. ([33748](https://github.com/WordPress/gutenberg/pull/33748))
#### Site Editor
- Fix the site editor breaking in firefox. ([33896](https://github.com/WordPress/gutenberg/pull/33896))
#### Editor
- Editor: Safer isPreviewingPost check. ([33840](https://github.com/WordPress/gutenberg/pull/33840))
#### Meta Boxes
- Fix Safari 13 metaboxes from overlapping the content. ([33817](https://github.com/WordPress/gutenberg/pull/33817))
#### Build Tooling
- Readable JS assets Plugin: Fix webpack 5 support. ([33785](https://github.com/WordPress/gutenberg/pull/33785))
#### Documentation
- fix: Broken link in documentation to block support mechanism. ([33780](https://github.com/WordPress/gutenberg/pull/33780))
#### Accessibility
- Fix some JAWS bugs. ([33627](https://github.com/WordPress/gutenberg/pull/33627))
#### Template Editor
- Template: Only show post template actions to users with correct capabilities. ([33392](https://github.com/WordPress/gutenberg/pull/33392))
#### Uncategorized
- Fix block appender position in classic themes. ([33895](https://github.com/WordPress/gutenberg/pull/33895))
- Fix positioning discrepancy with draggable chip. ([33893](https://github.com/WordPress/gutenberg/pull/33893))
- Fix misspelling of \\"queries\\" in filter documentation. ([33799](https://github.com/WordPress/gutenberg/pull/33799))
- ESLint Plugin: Include .jsx extenstion when linting import statements. ([33746](https://github.com/WordPress/gutenberg/pull/33746))
- Correct \`function_exists()\` check typo introduced in #33331. ([33513](https://github.com/WordPress/gutenberg/pull/33513))
### Performance
#### Block Library
- Improve the rendering/update performance of the image block. ([33974](https://github.com/WordPress/gutenberg/pull/33974))
- Do not add to the block-library CSS bundle the colors that come from \`theme.json\`. ([33924](https://github.com/WordPress/gutenberg/pull/33924))
#### Block Editor
- Lazy render the inserter search results. ([33868](https://github.com/WordPress/gutenberg/pull/33868))
- Lazy render block types in the inserter. ([33749](https://github.com/WordPress/gutenberg/pull/33749))
#### Parsing
- Improve the performance of the parser by removing the automatic custom classnames handling. ([33903](https://github.com/WordPress/gutenberg/pull/33903))
#### Template Editor
- Template Mode: Remove 'per_page' argument from the template data selector. ([33742](https://github.com/WordPress/gutenberg/pull/33742))
#### Editor
- Refactor the HierarchicalTermSelector so that it does not cause unnecessary loading of terms. ([33418](https://github.com/WordPress/gutenberg/pull/33418))
#### Uncategorized
- Avoid double parsing the content when loading the editor. ([33727](https://github.com/WordPress/gutenberg/pull/33727))
### Experiments
#### Full Site Editing
- Site Editor: Implement a settings object filter. ([33737](https://github.com/WordPress/gutenberg/pull/33737))
- Template part selection popover - minor style updates for visiblity. ([33733](https://github.com/WordPress/gutenberg/pull/33733))
- Template Part placeholder - Add title step to creation flow. ([33703](https://github.com/WordPress/gutenberg/pull/33703))
#### Block Library
- Enable ability to remove a link from the Nav Link block in the Nav Block. ([33777](https://github.com/WordPress/gutenberg/pull/33777))
- Fix navigation margin collapsing. ([33021](https://github.com/WordPress/gutenberg/pull/33021))
### Documentation
- Add documentation to disable remote calls for block patterns. ([33930](https://github.com/WordPress/gutenberg/pull/33930))
- Docs: Add more details about block attributes. ([33880](https://github.com/WordPress/gutenberg/pull/33880))
- Correct spelling and grammar in documentation. ([33860](https://github.com/WordPress/gutenberg/pull/33860))
- Fix gutenberg_resolve_template() return documentation. ([33800](https://github.com/WordPress/gutenberg/pull/33800))
- Add spaces in add_theme_support documentation code. ([33796](https://github.com/WordPress/gutenberg/pull/33796))
- [docs] fix: \`supports.color.gradients\` is plural. ([33781](https://github.com/WordPress/gutenberg/pull/33781))
- Add missing comma. ([33764](https://github.com/WordPress/gutenberg/pull/33764))
- Example for rest_endpoints filter in PHP. ([33738](https://github.com/WordPress/gutenberg/pull/33738))
- Update documentation to reflect new automated process for feature grouping. ([33573](https://github.com/WordPress/gutenberg/pull/33573))
- link fix: Block editor Sidebar Tutorial. ([33308](https://github.com/WordPress/gutenberg/pull/33308))
### Code Quality
#### Components
- Components: Use the \`__unsafe_useEmotionCache\` in the \`useCx\` hook. ([33982](https://github.com/WordPress/gutenberg/pull/33982))
- Components utils: \`rtl()\` return type, \`rtl.watch()\` utility. ([33882](https://github.com/WordPress/gutenberg/pull/33882))
- components: InputControl to TypeScript. ([33696](https://github.com/WordPress/gutenberg/pull/33696))
#### Block Library
- Site Logo: Use getMedia shorthand. ([33992](https://github.com/WordPress/gutenberg/pull/33992))
- Featured Image: Use getMedia shorthand. ([33943](https://github.com/WordPress/gutenberg/pull/33943))
#### Global Styles
- Remove the experimental prefix and rename \`theme.json\` files. ([33925](https://github.com/WordPress/gutenberg/pull/33925))
- No longer read from \`experimental-theme.json\`. ([33904](https://github.com/WordPress/gutenberg/pull/33904))
#### Plugin
- Plugin: Fix \`jsdoc/check-line-alignment\` ESLint warnings. ([33901](https://github.com/WordPress/gutenberg/pull/33901))
#### Post Editor
- Refactor MetaBoxesArea to to functional components using hooks. ([30542](https://github.com/WordPress/gutenberg/pull/30542))
#### Uncategorized
- Scripts: Fix typo in format change message. ([33945](https://github.com/WordPress/gutenberg/pull/33945))
### Tools
#### Testing
- Add search performance measure and make other measures more stable. ([33848](https://github.com/WordPress/gutenberg/pull/33848))
- E2E: Block Hierarchy Navigation wait for the column to be highlighted. ([33721](https://github.com/WordPress/gutenberg/pull/33721))
#### Build Tooling
- Scripts: Update webpack to v5 (try 2). ([33818](https://github.com/WordPress/gutenberg/pull/33818))
#### Uncategorized
- GitHub Templates: Format bug report template. ([33786](https://github.com/WordPress/gutenberg/pull/33786))
- GitHub Templates: Fix spacing in bug report template. ([33761](https://github.com/WordPress/gutenberg/pull/33761))
- Update bug issue template to use forms. ([33713](https://github.com/WordPress/gutenberg/pull/33713))
### Various
#### Block Library
- Search Block: Removed components class from icon button and polished css. ([33961](https://github.com/WordPress/gutenberg/pull/33961))
- [Button Block]: Add padding block support. ([31774](https://github.com/WordPress/gutenberg/pull/31774))
#### Widgets Editor
- Try to fix flaky customizer inspector test 2nd try. ([33965](https://github.com/WordPress/gutenberg/pull/33965))
- Try to fix flaky customizer inspector test. ([33890](https://github.com/WordPress/gutenberg/pull/33890))
#### Block Editor
- Closing the block inserter decrements block type impressions. ([33906](https://github.com/WordPress/gutenberg/pull/33906))
- Enable rich previews for internal links. ([33086](https://github.com/WordPress/gutenberg/pull/33086))
#### Icons
- Try new icons for reusable blocks and template parts. ([34002](https://github.com/WordPress/gutenberg/pull/34002))
#### Components
- Polish the focus style for the segmented control. ([33842](https://github.com/WordPress/gutenberg/pull/33842))
#### REST API
- Improve likelihood of getting rich link previews by modifying UA string for URL Details REST API endpoint. ([33747](https://github.com/WordPress/gutenberg/pull/33747))
#### CSS & Styling
- Try: Reduce specificity of reset & classic styles. ([32659](https://github.com/WordPress/gutenberg/pull/32659))
#### Uncategorized
- Tune appender margin. ([33866](https://github.com/WordPress/gutenberg/pull/33866))
- RNMobile: Add integration test guide. ([33833](https://github.com/WordPress/gutenberg/pull/33833))
- Core Data: Deprecate \`getAuthors\` in favor of \`getUsers\`. ([33725](https://github.com/WordPress/gutenberg/pull/33725))
- RNMobile: Try unifying the unit test command on mobile. ([33657](https://github.com/WordPress/gutenberg/pull/33657))
"
`;
8 changes: 8 additions & 0 deletions bin/plugin/commands/test/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
getTypesByLabels,
getTypesByTitle,
getIssueFeature,
formatChangelog,
} from '../changelog';
import pullRequests from './fixtures/pull-requests.json';

describe( 'getNormalizedTitle', () => {
const DEFAULT_ISSUE = {
Expand Down Expand Up @@ -312,3 +314,9 @@ describe( 'getTypesByTitle', () => {
expect( result ).toEqual( [ 'Bug Fixes' ] );
} );
} );

describe( 'formatChangelog', () => {
test( 'verify that the changelog is properly formatted', () => {
expect( formatChangelog( pullRequests ) ).toMatchSnapshot();
} );
} );
Loading

0 comments on commit b193771

Please sign in to comment.