Skip to content

Commit

Permalink
Merge branch 'WordPress:trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
miminari authored Dec 6, 2023
2 parents 614bd74 + efa4b01 commit eb4c754
Show file tree
Hide file tree
Showing 590 changed files with 27,017 additions and 14,203 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ jobs:
npm run wp-env start
- name: Run the tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e:playwright -- --shard=${{ matrix.part }}/${{ matrix.totalParts }}
Expand Down
41 changes: 33 additions & 8 deletions bin/plugin/commands/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,17 @@ const LABEL_FEATURE_MAPPING = {
'[Feature] Raw Handling': 'Block Editor',
'[Package] Edit Post': 'Post Editor',
'[Package] Icons': 'Icons',
'[Package] Block Editor': 'Block Editor',
'[Package] Block editor': 'Block Editor',
'[Package] Block library': 'Block Library',
'[Package] Editor': 'Post Editor',
'[Package] Edit Site': 'Site Editor',
'[Package] Edit Widgets': 'Widgets Editor',
'[Package] Widgets Customizer': 'Widgets Editor',
'[Package] Components': 'Components',
'[Package] Block Library': 'Block Library',
'[Package] Rich text': 'Block Editor',
'[Package] Data': 'Data Layer',
'[Package] Commands': 'Commands',
'[Block] Legacy Widget': 'Widgets Editor',
'REST API Interaction': 'REST API',
'New Block': 'Block Library',
Expand Down Expand Up @@ -220,9 +222,18 @@ function getTypesByLabels( labels ) {
...new Set(
labels
.filter( ( label ) =>
Object.keys( LABEL_TYPE_MAPPING ).includes( label )
Object.keys( LABEL_TYPE_MAPPING )
.map( ( currentLabel ) => currentLabel.toLowerCase() )
.includes( label.toLowerCase() )
)
.map( ( label ) => LABEL_TYPE_MAPPING[ label ] )
.map( ( label ) => {
const lowerCaseLabel =
Object.keys( LABEL_TYPE_MAPPING ).find(
( key ) => key.toLowerCase() === label.toLowerCase()
) || label;

return LABEL_TYPE_MAPPING[ lowerCaseLabel ];
} )
),
];
}
Expand All @@ -236,11 +247,24 @@ function getTypesByLabels( labels ) {
* @return {string[]} Feature candidates.
*/
function mapLabelsToFeatures( labels ) {
return labels
.filter( ( label ) =>
Object.keys( LABEL_FEATURE_MAPPING ).includes( label )
)
.map( ( label ) => LABEL_FEATURE_MAPPING[ label ] );
return [
...new Set(
labels
.filter( ( label ) =>
Object.keys( LABEL_FEATURE_MAPPING )
.map( ( currentLabel ) => currentLabel.toLowerCase() )
.includes( label.toLowerCase() )
)
.map( ( label ) => {
const lowerCaseLabel =
Object.keys( LABEL_FEATURE_MAPPING ).find(
( key ) => key.toLowerCase() === label.toLowerCase()
) || label;

return LABEL_FEATURE_MAPPING[ lowerCaseLabel ];
} )
),
];
}

/**
Expand Down Expand Up @@ -1070,4 +1094,5 @@ async function getReleaseChangelog( options ) {
getChangelog,
getUniqueByUsername,
skipCreatedByBots,
mapLabelsToFeatures,
};
1 change: 1 addition & 0 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async function runTestSuite( testSuite, testRunnerDir, runKey ) {
testRunnerDir,
{
...process.env,
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1',
WP_ARTIFACTS_PATH: ARTIFACTS_PATH,
RESULTS_ID: runKey,
}
Expand Down
324 changes: 191 additions & 133 deletions bin/plugin/commands/test/__snapshots__/changelog.js.snap

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions bin/plugin/commands/test/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getChangelog,
getContributorProps,
getContributorsList,
mapLabelsToFeatures,
} from '../changelog';
import _pullRequests from './fixtures/pull-requests.json';
import botPullRequestFixture from './fixtures/bot-pull-requests.json';
Expand Down Expand Up @@ -312,18 +313,35 @@ describe( 'sortGroup', () => {
} );

describe( 'getTypesByLabels', () => {
it( 'returns all normalized type candidates by type prefix', () => {
it( 'returns all normalized type candidates by type prefix. it is case insensitive', () => {
const result = getTypesByLabels( [
'[Type] Regression',
'[Type] Bug',
'[Package] Blocks',
'[Type] Performance',
'[Type] performance',
] );

expect( result ).toEqual( [ 'Bug Fixes', 'Performance' ] );
} );
} );

describe( 'mapLabelsToFeatures', () => {
it( 'returns all normalized feature candidates by feature prefix. it is case insensitive', () => {
const result = mapLabelsToFeatures( [
'[Package] Commands',
'[Package] Block Library',
'[Feature] Link Editing',
'[Feature] block Multi Selection',
] );

expect( result ).toEqual( [
'Commands',
'Block Library',
'Block Editor',
] );
} );
} );

describe( 'getTypesByTitle', () => {
it.each( [
[ 'Fix Typography panel rendering from style hooks' ],
Expand Down Expand Up @@ -473,7 +491,7 @@ describe( 'getFormattedItemDescription', () => {
describe( 'getChangelog', () => {
test( 'verify that the changelog is properly formatted', () => {
// The fixture with the list of pull requests was generated by running the following command:
// npm run other:changelog -- --milestone="Gutenberg 11.3"
// npm run other:changelog -- --milestone="Gutenberg 16.8"
// The response from the `fetchAllPullRequests` call in the `getChangelog` method was stored in the JSON file.
expect( getChangelog( pullRequests ) ).toMatchSnapshot();
} );
Expand Down
Loading

0 comments on commit eb4c754

Please sign in to comment.