Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

'use strict';

const checkForReproducer = require('../checkForReproducer');

const ISSUE_AUTHOR = 'issue-author';

function buildGithub(body) {
return {
rest: {
issues: {
get: jest.fn().mockResolvedValue({
data: {
user: {login: ISSUE_AUTHOR},
created_at: '2026-10-01T00:00:00Z',
body,
},
}),
listComments: jest.fn().mockResolvedValue({data: []}),
listEventsForTimeline: jest.fn().mockResolvedValue({data: []}),
removeLabel: jest.fn().mockResolvedValue({}),
addLabels: jest.fn().mockResolvedValue({}),
},
},
};
}

const context = {
repo: {owner: 'react', repo: 'react-native'},
payload: {issue: {number: 1}},
};

describe('checkForReproducer reproducer links', () => {
test.each([
'https://github.com/react/react-native/pull/58972',
'https://github.com/facebook/react-native/pull/58972',
])('accepts a pull request link as a reproducer: %s', async link => {
const github = buildGithub(`Reproducer: ${link}`);

await checkForReproducer(github, context);

expect(github.rest.issues.removeLabel).toHaveBeenCalledWith(
expect.objectContaining({name: 'Needs: Repro'}),
);
expect(github.rest.issues.addLabels).not.toHaveBeenCalled();
});

test.each([
'Reproducer: https://github.com/someone-else/some-repo/pull/12',
'It crashes when I scroll.',
])('asks for a reproducer when there is none: %s', async body => {
const github = buildGithub(body);

await checkForReproducer(github, context);

expect(github.rest.issues.addLabels).toHaveBeenCalledWith(
expect.objectContaining({
labels: ['Needs: Repro', 'Needs: Author Feedback'],
}),
);
expect(github.rest.issues.removeLabel).not.toHaveBeenCalled();
});
});
2 changes: 1 addition & 1 deletion .github/workflow-scripts/checkForReproducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = async (github, context) => {
const hasValidReproducer = entities.some(entity => {
const hasPullRequestRepoLink = containsPattern(
entity.body,
`https?:\/\/github\.com\/facebook\/react-native\/pull\/\d+\/?`,
`https?:\\/\\/github\\.com\\/(?:facebook|react)\\/react-native\\/pull\\/\\d+\\/?`,
);

const hasExpoSnackLink = containsPattern(
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/close-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
// Looking at the commit message, checks which PR number, if any, was closed by this commit
const getClosedPrIfExists = (commit) => {
if(!commit || !commit.message) return;
const prClosingRegex = /Closes https:\/\/github.com\/facebook\/react-native\/pull\/([0-9]+)|Pull Request resolved: https:\/\/github.com\/facebook\/react-native\/pull\/([0-9]+)/;
const prClosingRegex = /Closes https:\/\/github.com\/(?:facebook|react)\/react-native\/pull\/([0-9]+)|Pull Request resolved: https:\/\/github.com\/(?:facebook|react)\/react-native\/pull\/([0-9]+)/;
const prClosingMatch = commit.message.match(prClosingRegex);
if(!prClosingMatch || (!prClosingMatch[1] && ! prClosingMatch[2])) return;
return prClosingMatch[1] ?? prClosingMatch[2];
Expand Down
Loading