Преглед изворни кода

SONAR-16118 Sort PRs numerically instead of alphabetically

tags/9.5.0.56709
Wouter Admiraal пре 2 година
родитељ
комит
e97b716f28

+ 1
- 1
server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/Menu-test.tsx Прегледај датотеку

const { onKeyDown } = wrapper.find(SearchBox).props(); const { onKeyDown } = wrapper.find(SearchBox).props();


onKeyDown!(mockEvent({ nativeEvent: { code: KeyboardCodes.UpArrow } })); onKeyDown!(mockEvent({ nativeEvent: { code: KeyboardCodes.UpArrow } }));
expect(wrapper.state().selectedBranchLike).toBe(branchLikes[5]);
expect(wrapper.state().selectedBranchLike).toBe(branchLikes[3]);


onKeyDown!(mockEvent({ nativeEvent: { code: KeyboardCodes.DownArrow } })); onKeyDown!(mockEvent({ nativeEvent: { code: KeyboardCodes.DownArrow } }));
onKeyDown!(mockEvent({ nativeEvent: { code: KeyboardCodes.DownArrow } })); onKeyDown!(mockEvent({ nativeEvent: { code: KeyboardCodes.DownArrow } }));

+ 8
- 8
server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/Menu-test.tsx.snap Прегледај датотеку

"analysisDate": "2018-01-01", "analysisDate": "2018-01-01",
"base": "master", "base": "master",
"branch": "feature/foo/bar", "branch": "feature/foo/bar",
"key": "1",
"key": "2",
"target": "master", "target": "master",
"title": "PR-1",
"title": "PR-2",
}, },
Object { Object {
"analysisDate": "2018-01-01", "analysisDate": "2018-01-01",
"base": "master", "base": "master",
"branch": "feature/foo/bar", "branch": "feature/foo/bar",
"key": "2",
"key": "1",
"target": "master", "target": "master",
"title": "PR-2",
"title": "PR-1",
}, },
], ],
}, },
"analysisDate": "2018-01-01", "analysisDate": "2018-01-01",
"base": "master", "base": "master",
"branch": "feature/foo/bar", "branch": "feature/foo/bar",
"key": "1",
"key": "2",
"target": "master", "target": "master",
"title": "PR-1",
"title": "PR-2",
}, },
Object { Object {
"analysisDate": "2018-01-01", "analysisDate": "2018-01-01",
"base": "master", "base": "master",
"branch": "feature/foo/bar", "branch": "feature/foo/bar",
"key": "2",
"key": "1",
"target": "master", "target": "master",
"title": "PR-2",
"title": "PR-1",
}, },
], ],
}, },

+ 6
- 6
server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItemList-test.tsx.snap Прегледај датотеку

"analysisDate": "2018-01-01", "analysisDate": "2018-01-01",
"base": "master", "base": "master",
"branch": "feature/foo/bar", "branch": "feature/foo/bar",
"key": "1",
"key": "2",
"target": "master", "target": "master",
"title": "PR-1",
"title": "PR-2",
} }
} }
component={ component={
} }
} }
indent={true} indent={true}
key="pull-request-1"
key="pull-request-2"
onSelect={[MockFunction]} onSelect={[MockFunction]}
selected={false} selected={false}
setSelectedNode={[Function]} setSelectedNode={[Function]}
"analysisDate": "2018-01-01", "analysisDate": "2018-01-01",
"base": "master", "base": "master",
"branch": "feature/foo/bar", "branch": "feature/foo/bar",
"key": "2",
"key": "1",
"target": "master", "target": "master",
"title": "PR-2",
"title": "PR-1",
} }
} }
component={ component={
} }
} }
indent={true} indent={true}
key="pull-request-2"
key="pull-request-1"
onSelect={[MockFunction]} onSelect={[MockFunction]}
selected={false} selected={false}
setSelectedNode={[Function]} setSelectedNode={[Function]}

+ 19
- 19
server/sonar-web/src/main/js/helpers/__tests__/branch-like-test.ts Прегледај датотеку

const branch3 = mockBranch({ name: 'branch-3' }); const branch3 = mockBranch({ name: 'branch-3' });
const branch4 = mockBranch({ name: 'branch-4' }); const branch4 = mockBranch({ name: 'branch-4' });


const mainPr1 = mockPullRequest({ base: main.name, key: 'PR1' });
const mainPr2 = mockPullRequest({ base: main.name, key: 'PR2' });
const llb1Pr1 = mockPullRequest({ base: branch1.name, key: 'PR1' });
const llb1Pr2 = mockPullRequest({ base: branch1.name, key: 'PR2' });
const llb2Pr1 = mockPullRequest({ base: branch2.name, key: 'PR1' });
const llb2Pr2 = mockPullRequest({ base: branch2.name, key: 'PR1' });
const orphanPR1 = mockPullRequest({ isOrphan: true, key: 'PR1' });
const orphanPR2 = mockPullRequest({ isOrphan: true, key: 'PR2' });
const parentlessPR1 = mockPullRequest({ base: 'not_present_branch_1', key: 'PR1' });
const parentlessPR2 = mockPullRequest({ base: 'not_present_branch_2', key: 'PR2' });
const mainPr1 = mockPullRequest({ base: main.name, key: '1' });
const mainPr2 = mockPullRequest({ base: main.name, key: '2' });
const branch1Pr1 = mockPullRequest({ base: branch1.name, key: '3' });
const branch1Pr2 = mockPullRequest({ base: branch1.name, key: '4' });
const branch2Pr1 = mockPullRequest({ base: branch2.name, key: '5' });
const branch2Pr2 = mockPullRequest({ base: branch2.name, key: '6' });
const orphanPR1 = mockPullRequest({ isOrphan: true, key: '7' });
const orphanPR2 = mockPullRequest({ isOrphan: true, key: '8' });
const parentlessPR1 = mockPullRequest({ base: 'not_present_branch_1', key: '9' });
const parentlessPR2 = mockPullRequest({ base: 'not_present_branch_2', key: '10' });


expect( expect(
getBrancheLikesAsTree([ getBrancheLikesAsTree([
mainPr1, mainPr1,
parentlessPR2, parentlessPR2,
parentlessPR1, parentlessPR1,
llb2Pr2,
llb2Pr1,
llb1Pr2,
llb1Pr1
branch2Pr2,
branch2Pr1,
branch1Pr2,
branch1Pr1
]) ])
).toEqual({ ).toEqual({
mainBranchTree: { mainBranchTree: {
branch: main, branch: main,
pullRequests: [mainPr1, mainPr2]
pullRequests: [mainPr2, mainPr1]
}, },
branchTree: [ branchTree: [
{ branch: branch1, pullRequests: [llb1Pr1, llb1Pr2] },
{ branch: branch2, pullRequests: [llb2Pr1, llb2Pr1] },
{ branch: branch1, pullRequests: [branch1Pr2, branch1Pr1] },
{ branch: branch2, pullRequests: [branch2Pr2, branch2Pr1] },
{ branch: branch3, pullRequests: [] }, { branch: branch3, pullRequests: [] },
{ branch: branch4, pullRequests: [] } { branch: branch4, pullRequests: [] }
], ],
parentlessPullRequests: [parentlessPR1, parentlessPR2],
orphanPullRequests: [orphanPR1, orphanPR2]
parentlessPullRequests: [parentlessPR2, parentlessPR1],
orphanPullRequests: [orphanPR2, orphanPR1]
}); });
}); });
}); });

+ 3
- 1
server/sonar-web/src/main/js/helpers/branch-like.ts Прегледај датотеку

branchLikes.filter(isBranch).filter(b => !isMainBranch(b)), branchLikes.filter(isBranch).filter(b => !isMainBranch(b)),
b => b.name b => b.name
); );
const pullRequests = orderBy(branchLikes.filter(isPullRequest), b => b.key);
const pullRequests = orderBy(branchLikes.filter(isPullRequest), b => parseInt(b.key, 10), [
'desc'
]);
const parentlessPullRequests = pullRequests.filter( const parentlessPullRequests = pullRequests.filter(
pr => !pr.isOrphan && ![mainBranch, ...branches].find(b => !!b && b.name === pr.base) pr => !pr.isOrphan && ![mainBranch, ...branches].find(b => !!b && b.name === pr.base)
); );

Loading…
Откажи
Сачувај