summaryrefslogtreecommitdiff
path: root/spec/frontend/projects
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-15 15:08:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-15 15:08:26 +0000
commit4279dbc29c63f614e6439e104204165ff0517a59 (patch)
treea2a2dc637398f9c66eeda39ee9e3e209370a84c4 /spec/frontend/projects
parent7912017a137da35c48071a048c99d27737c29f0f (diff)
downloadgitlab-ce-4279dbc29c63f614e6439e104204165ff0517a59.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/projects')
-rw-r--r--spec/frontend/projects/settings/repository/branch_rules/components/branch_rule_spec.js29
-rw-r--r--spec/frontend/projects/settings/repository/branch_rules/mock_data.js24
2 files changed, 40 insertions, 13 deletions
diff --git a/spec/frontend/projects/settings/repository/branch_rules/components/branch_rule_spec.js b/spec/frontend/projects/settings/repository/branch_rules/components/branch_rule_spec.js
index ab29189489e..2aa93fd0e28 100644
--- a/spec/frontend/projects/settings/repository/branch_rules/components/branch_rule_spec.js
+++ b/spec/frontend/projects/settings/repository/branch_rules/components/branch_rule_spec.js
@@ -2,6 +2,7 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import BranchRule, {
i18n,
} from '~/projects/settings/repository/branch_rules/components/branch_rule.vue';
+import { sprintf, n__ } from '~/locale';
import {
branchRuleProvideMock,
branchRulePropsMock,
@@ -19,7 +20,6 @@ describe('Branch rule', () => {
};
const findDefaultBadge = () => wrapper.findByText(i18n.defaultLabel);
- const findProtectedBadge = () => wrapper.findByText(i18n.protectedLabel);
const findBranchName = () => wrapper.findByText(branchRulePropsMock.name);
const findProtectionDetailsList = () => wrapper.findByRole('list');
const findProtectionDetailsListItems = () => wrapper.findAllByRole('listitem');
@@ -32,30 +32,37 @@ describe('Branch rule', () => {
});
describe('badges', () => {
- it('renders both default and protected badges', () => {
+ it('renders default badge', () => {
expect(findDefaultBadge().exists()).toBe(true);
- expect(findProtectedBadge().exists()).toBe(true);
});
it('does not render default badge if isDefault is set to false', () => {
createComponent({ isDefault: false });
expect(findDefaultBadge().exists()).toBe(false);
});
-
- it('does not render protected badge if isProtected is set to false', () => {
- createComponent({ isProtected: false });
- expect(findProtectedBadge().exists()).toBe(false);
- });
});
- it('does not render the protection details list of no details are present', () => {
+ it('does not render the protection details list if no details are present', () => {
createComponent(branchRuleWithoutDetailsPropsMock);
expect(findProtectionDetailsList().exists()).toBe(false);
});
it('renders the protection details list items', () => {
- expect(findProtectionDetailsListItems().at(0).text()).toBe(wrapper.vm.approvalDetails[0]);
- expect(findProtectionDetailsListItems().at(1).text()).toBe(wrapper.vm.approvalDetails[1]);
+ expect(findProtectionDetailsListItems()).toHaveLength(wrapper.vm.approvalDetails.length);
+ expect(findProtectionDetailsListItems().at(0).text()).toBe(i18n.allowForcePush);
+ expect(findProtectionDetailsListItems().at(1).text()).toBe(i18n.codeOwnerApprovalRequired);
+ expect(findProtectionDetailsListItems().at(2).text()).toMatchInterpolatedText(
+ sprintf(i18n.statusChecks, {
+ total: branchRulePropsMock.statusChecksTotal,
+ subject: n__('check', 'checks', branchRulePropsMock.statusChecksTotal),
+ }),
+ );
+ expect(findProtectionDetailsListItems().at(3).text()).toMatchInterpolatedText(
+ sprintf(i18n.approvalRules, {
+ total: branchRulePropsMock.approvalRulesTotal,
+ subject: n__('rule', 'rules', branchRulePropsMock.approvalRulesTotal),
+ }),
+ );
});
it('renders a detail button with the correct href', () => {
diff --git a/spec/frontend/projects/settings/repository/branch_rules/mock_data.js b/spec/frontend/projects/settings/repository/branch_rules/mock_data.js
index 2a55dd7e835..8aa03a12996 100644
--- a/spec/frontend/projects/settings/repository/branch_rules/mock_data.js
+++ b/spec/frontend/projects/settings/repository/branch_rules/mock_data.js
@@ -8,18 +8,36 @@ export const branchRulesMockResponse = {
nodes: [
{
name: 'main',
+ isDefault: true,
branchProtection: {
allowForcePush: true,
codeOwnerApprovalRequired: true,
},
+ approvalRules: {
+ nodes: [{ id: 1 }],
+ __typename: 'ApprovalProjectRuleConnection',
+ },
+ externalStatusChecks: {
+ nodes: [{ id: 1 }, { id: 2 }],
+ __typename: 'BranchRule',
+ },
__typename: 'BranchRule',
},
{
name: 'test-*',
+ isDefault: false,
branchProtection: {
allowForcePush: false,
codeOwnerApprovalRequired: false,
},
+ approvalRules: {
+ nodes: [],
+ __typename: 'ApprovalProjectRuleConnection',
+ },
+ externalStatusChecks: {
+ nodes: [],
+ __typename: 'BranchRule',
+ },
__typename: 'BranchRule',
},
],
@@ -39,19 +57,21 @@ export const branchRuleProvideMock = {
export const branchRulePropsMock = {
name: 'main',
isDefault: true,
- isProtected: true,
branchProtection: {
allowForcePush: true,
codeOwnerApprovalRequired: true,
},
+ approvalRulesTotal: 1,
+ statusChecksTotal: 2,
};
export const branchRuleWithoutDetailsPropsMock = {
name: 'main',
isDefault: false,
- isProtected: false,
branchProtection: {
allowForcePush: false,
codeOwnerApprovalRequired: false,
},
+ approvalRulesTotal: 0,
+ statusChecksTotal: 0,
};