Skip to content
代码片段 群组 项目
未验证 提交 366be8ff 编辑于 作者: Kushal Pandya's avatar Kushal Pandya 提交者: GitLab
浏览文件

Merge branch 'ph/fixApprovalsButtonText' into 'master'

Fixes the approval button text

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/143958



Merged-by: default avatarKushal Pandya <kushal@gitlab.com>
Approved-by: default avatarKushal Pandya <kushal@gitlab.com>
Co-authored-by: default avatarPhil Hughes <me@iamphill.com>
No related branches found
No related tags found
无相关合并请求
......@@ -61,6 +61,11 @@ export default {
required: false,
default: false,
},
hasAllApprovals: {
type: Boolean,
required: false,
default: false,
},
},
data() {
return {
......@@ -73,7 +78,7 @@ export default {
return this.mr.approvalsWidgetType === 'base';
},
isApproved() {
return Boolean(this.approvals.approved || this.approvedBy.length);
return this.hasAllApprovals;
},
isOptional() {
return this.isOptionalDefault !== null ? this.isOptionalDefault : !this.approvedBy.length;
......
......@@ -47,6 +47,9 @@ export default {
requirePasswordToApprove() {
return !this.isBasic && this.mr.requirePasswordToApprove;
},
hasAllApprovals() {
return (this.approvals.approvalsLeft || 0) === 0;
},
},
methods: {
toggleCollapsed() {
......@@ -63,6 +66,7 @@ export default {
:require-password-to-approve="requirePasswordToApprove"
:modal-id="modalId"
:collapsed="collapsed"
:has-all-approvals="hasAllApprovals"
@toggle="toggleCollapsed"
>
<template v-if="!isBasic" #default="{ isApproving, approveWithAuth, hasApprovalAuthError }">
......
......@@ -122,6 +122,75 @@ describe('MRWidget approvals', () => {
canApproveResponse = createCanApproveResponse();
});
describe('with approvers, with SAML auth requried for approval', () => {
beforeEach(async () => {
canApproveResponse.data.project.mergeRequest.approvedBy.nodes =
approvedByCurrentUser.data.project.mergeRequest.approvedBy.nodes;
canApproveResponse.data.project.mergeRequest.approvedBy.nodes[0].id = 69;
mr.requireSamlAuthToApprove = true;
createComponent({}, canApproveResponse);
await waitForPromises();
});
it('approve additionally action is rendered with correct text', () => {
expect(findActionData()).toEqual({
variant: 'confirm',
text: 'Approve additionally with SAML',
category: 'secondary',
});
});
});
describe('with approvers', () => {
beforeEach(async () => {
canApproveResponse.data.project.mergeRequest.approvedBy.nodes =
approvedByCurrentUser.data.project.mergeRequest.approvedBy.nodes;
canApproveResponse.data.project.mergeRequest.approvedBy.nodes[0].id = 2;
createComponent({}, canApproveResponse);
await waitForPromises();
});
it('approve additionally action is rendered', () => {
expect(findActionData()).toEqual({
variant: 'confirm',
text: 'Approve additionally',
category: 'secondary',
});
});
});
describe('has approvals left', () => {
it('shows approve text', async () => {
const response = JSON.parse(JSON.stringify(approvedByCurrentUser));
response.data.project.mergeRequest.approvalsLeft = 1;
response.data.project.mergeRequest.userPermissions.canApprove = true;
gon.current_user_id = 10000000;
createComponent({}, response);
await waitForPromises();
expect(findAction().text()).toBe('Approve');
});
});
describe('no approvals left', () => {
it('shows approve additionally text', async () => {
const response = JSON.parse(JSON.stringify(approvedByCurrentUser));
response.data.project.mergeRequest.approvalsLeft = 0;
response.data.project.mergeRequest.userPermissions.canApprove = true;
gon.current_user_id = 10000000;
createComponent({}, response);
await waitForPromises();
expect(findAction().text()).toBe('Approve additionally');
});
});
describe('and MR is approved', () => {
beforeEach(() => {
canApproveResponse.data.project.mergeRequest.approved = true;
......
......@@ -224,45 +224,6 @@ describe('MRWidget approvals', () => {
});
});
});
describe('with approvers, with SAML auth requried for approval', () => {
beforeEach(async () => {
canApproveResponse.data.project.mergeRequest.approvedBy.nodes =
approvedByCurrentUser.data.project.mergeRequest.approvedBy.nodes;
canApproveResponse.data.project.mergeRequest.approvedBy.nodes[0].id = 69;
mr.requireSamlAuthToApprove = true;
createComponent({}, { query: canApproveResponse });
await waitForPromises();
});
it('approve additionally action is rendered with correct text', () => {
expect(findActionData()).toEqual({
variant: 'confirm',
text: 'Approve additionally with SAML',
category: 'secondary',
});
});
});
describe('with approvers', () => {
beforeEach(async () => {
canApproveResponse.data.project.mergeRequest.approvedBy.nodes =
approvedByCurrentUser.data.project.mergeRequest.approvedBy.nodes;
canApproveResponse.data.project.mergeRequest.approvedBy.nodes[0].id = 2;
createComponent({}, { query: canApproveResponse });
await waitForPromises();
});
it('approve additionally action is rendered', () => {
expect(findActionData()).toEqual({
variant: 'confirm',
text: 'Approve additionally',
category: 'secondary',
});
});
});
});
describe('when SAML auth is required and user clicks Approve with SAML', () => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册