summaryrefslogtreecommitdiff
path: root/spec/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js18
-rw-r--r--spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js48
-rw-r--r--spec/frontend/ci_variable_list/components/ci_variable_table_spec.js7
-rw-r--r--spec/frontend/ci_variable_list/services/mock_data.js27
-rw-r--r--spec/frontend/ci_variable_list/store/mutations_spec.js4
-rw-r--r--spec/frontend/ci_variable_list/store/utils_spec.js2
-rw-r--r--spec/frontend/contributors/store/getters_spec.js32
-rw-r--r--spec/frontend/reports/store/utils_spec.js34
-rw-r--r--spec/frontend/sidebar/mock_data.js2
9 files changed, 114 insertions, 60 deletions
diff --git a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
index be2c017cc7e..8db6626fca3 100644
--- a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
+++ b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
@@ -35,10 +35,6 @@ describe('Ci variable modal', () => {
expect(findModal().props('actionPrimary').attributes.disabled).toBeTruthy();
});
- it('masked checkbox is disabled when value does not meet regex requirements', () => {
- expect(wrapper.find({ ref: 'masked-ci-variable' }).attributes('disabled')).toBeTruthy();
- });
-
describe('Adding a new variable', () => {
beforeEach(() => {
const [variable] = mockData.mockVariables;
@@ -49,13 +45,6 @@ describe('Ci variable modal', () => {
expect(findModal().props('actionPrimary').attributes.disabled).toBeFalsy();
});
- it('masked checkbox is enabled when value meets regex requirements', () => {
- store.state.maskableRegex = '^[a-zA-Z0-9_+=/@:-]{8,}$';
- return wrapper.vm.$nextTick(() => {
- expect(wrapper.find({ ref: 'masked-ci-variable' }).attributes('disabled')).toBeFalsy();
- });
- });
-
it('Add variable button dispatches addVariable action', () => {
findModal().vm.$emit('ok');
expect(store.dispatch).toHaveBeenCalledWith('addVariable');
@@ -74,7 +63,7 @@ describe('Ci variable modal', () => {
});
it('button text is Update variable when updating', () => {
- expect(wrapper.vm.modalActionText).toBe('Update Variable');
+ expect(wrapper.vm.modalActionText).toBe('Update variable');
});
it('Update variable button dispatches updateVariable with correct variable', () => {
@@ -89,5 +78,10 @@ describe('Ci variable modal', () => {
findModal().vm.$emit('hidden');
expect(store.dispatch).toHaveBeenCalledWith('resetEditing');
});
+
+ it('dispatches deleteVariable with correct variable to delete', () => {
+ findModal().vm.$emit('secondary');
+ expect(store.dispatch).toHaveBeenCalledWith('deleteVariable', mockData.mockVariables[0]);
+ });
});
});
diff --git a/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js
new file mode 100644
index 00000000000..5d37f059161
--- /dev/null
+++ b/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js
@@ -0,0 +1,48 @@
+import { shallowMount } from '@vue/test-utils';
+import { GlButton } from '@gitlab/ui';
+import CiVariablePopover from '~/ci_variable_list/components/ci_variable_popover.vue';
+import mockData from '../services/mock_data';
+
+describe('Ci Variable Popover', () => {
+ let wrapper;
+
+ const defaultProps = {
+ target: 'ci-variable-value-22',
+ value: mockData.mockPemCert,
+ tooltipText: 'Copy value',
+ };
+
+ const createComponent = (props = defaultProps) => {
+ wrapper = shallowMount(CiVariablePopover, {
+ propsData: { ...props },
+ });
+ };
+
+ const findButton = () => wrapper.find(GlButton);
+
+ beforeEach(() => {
+ createComponent();
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ wrapper = null;
+ });
+
+ it('displays max count plus ... when character count is over 95', () => {
+ expect(wrapper.text()).toHaveLength(98);
+ });
+
+ it('copies full value to clipboard', () => {
+ expect(findButton().attributes('data-clipboard-text')).toEqual(mockData.mockPemCert);
+ });
+
+ it('displays full value when count is less than max count', () => {
+ createComponent({
+ target: 'ci-variable-value-22',
+ value: 'test_variable_value',
+ tooltipText: 'Copy value',
+ });
+ expect(wrapper.text()).toEqual('test_variable_value');
+ });
+});
diff --git a/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js
index 973a9c51f16..36aeffe7798 100644
--- a/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js
+++ b/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js
@@ -17,12 +17,12 @@ describe('Ci variable table', () => {
store.state.isGroup = true;
jest.spyOn(store, 'dispatch').mockImplementation();
wrapper = mount(CiVariableTable, {
+ attachToDocument: true,
localVue,
store,
});
};
- const findDeleteButton = () => wrapper.find({ ref: 'delete-ci-variable' });
const findRevealButton = () => wrapper.find({ ref: 'secret-value-reveal-button' });
const findEditButton = () => wrapper.find({ ref: 'edit-ci-variable' });
const findEmptyVariablesPlaceholder = () => wrapper.find({ ref: 'empty-variables' });
@@ -71,11 +71,6 @@ describe('Ci variable table', () => {
store.state.variables = mockData.mockVariables;
});
- it('dispatches deleteVariable with correct variable to delete', () => {
- findDeleteButton().trigger('click');
- expect(store.dispatch).toHaveBeenCalledWith('deleteVariable', mockData.mockVariables[0]);
- });
-
it('reveals secret values when button is clicked', () => {
findRevealButton().trigger('click');
expect(store.dispatch).toHaveBeenCalledWith('toggleValues', false);
diff --git a/spec/frontend/ci_variable_list/services/mock_data.js b/spec/frontend/ci_variable_list/services/mock_data.js
index b04cd223d42..5e0fa55a20c 100644
--- a/spec/frontend/ci_variable_list/services/mock_data.js
+++ b/spec/frontend/ci_variable_list/services/mock_data.js
@@ -6,8 +6,9 @@ export default {
key: 'test_var',
masked: false,
protected: false,
+ secret_value: 'test_val',
value: 'test_val',
- variable_type: 'Variable',
+ variable_type: 'Var',
},
],
@@ -18,6 +19,7 @@ export default {
key: 'test_var',
masked: false,
protected: false,
+ secret_value: 'test_val',
value: 'test_val',
variable_type: 'env_var',
},
@@ -27,6 +29,7 @@ export default {
key: 'test_var_2',
masked: false,
protected: false,
+ secret_value: 'test_val_2',
value: 'test_val_2',
variable_type: 'file',
},
@@ -34,20 +37,22 @@ export default {
mockVariablesDisplay: [
{
- environment_scope: 'All environments',
+ environment_scope: 'All',
id: 113,
key: 'test_var',
masked: false,
protected: false,
+ secret_value: 'test_val',
value: 'test_val',
- variable_type: 'Variable',
+ variable_type: 'Var',
},
{
- environment_scope: 'All environments',
+ environment_scope: 'All',
id: 114,
key: 'test_var_2',
masked: false,
protected: false,
+ secret_value: 'test_val_2',
value: 'test_val_2',
variable_type: 'File',
},
@@ -69,4 +74,18 @@ export default {
state: 'available',
},
],
+
+ mockPemCert: `-----BEGIN CERTIFICATE REQUEST-----
+ MIIB9TCCAWACAQAwgbgxGTAXBgNVBAoMEFF1b1ZhZGlzIExpbWl0ZWQxHDAaBgNV
+ BAsME0RvY3VtZW50IERlcGFydG1lbnQxOTA3BgNVBAMMMFdoeSBhcmUgeW91IGRl
+ Y29kaW5nIG1lPyAgVGhpcyBpcyBvbmx5IGEgdGVzdCEhITERMA8GA1UEBwwISGFt
+ aWx0b24xETAPBgNVBAgMCFBlbWJyb2tlMQswCQYDVQQGEwJCTTEPMA0GCSqGSIb3
+ DQEJARYAMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCJ9WRanG/fUvcfKiGl
+ EL4aRLjGt537mZ28UU9/3eiJeJznNSOuNLnF+hmabAu7H0LT4K7EdqfF+XUZW/2j
+ RKRYcvOUDGF9A7OjW7UfKk1In3+6QDCi7X34RE161jqoaJjrm/T18TOKcgkkhRzE
+ apQnIDm0Ea/HVzX/PiSOGuertwIDAQABMAsGCSqGSIb3DQEBBQOBgQBzMJdAV4QP
+ Awel8LzGx5uMOshezF/KfP67wJ93UW+N7zXY6AwPgoLj4Kjw+WtU684JL8Dtr9FX
+ ozakE+8p06BpxegR4BR3FMHf6p+0jQxUEAkAyb/mVgm66TyghDGC6/YkiKoZptXQ
+ 98TwDIK/39WEB/V607As+KoYazQG8drorw==
+ -----END CERTIFICATE REQUEST-----`,
};
diff --git a/spec/frontend/ci_variable_list/store/mutations_spec.js b/spec/frontend/ci_variable_list/store/mutations_spec.js
index 1bb34e88cf5..05513edff7b 100644
--- a/spec/frontend/ci_variable_list/store/mutations_spec.js
+++ b/spec/frontend/ci_variable_list/store/mutations_spec.js
@@ -48,12 +48,12 @@ describe('CI variable list mutations', () => {
describe('CLEAR_MODAL', () => {
it('should clear modal state ', () => {
const modalState = {
- variable_type: 'Variable',
+ variable_type: 'Var',
key: '',
secret_value: '',
protected: false,
masked: false,
- environment_scope: 'All environments',
+ environment_scope: 'All',
};
mutations[types.CLEAR_MODAL](stateCopy);
diff --git a/spec/frontend/ci_variable_list/store/utils_spec.js b/spec/frontend/ci_variable_list/store/utils_spec.js
index 070bc996d75..5b10370324a 100644
--- a/spec/frontend/ci_variable_list/store/utils_spec.js
+++ b/spec/frontend/ci_variable_list/store/utils_spec.js
@@ -19,6 +19,7 @@ describe('CI variables store utils', () => {
key: 'test_var',
masked: 'false',
protected: 'false',
+ secret_value: 'test_val',
value: 'test_val',
variable_type: 'env_var',
});
@@ -29,6 +30,7 @@ describe('CI variables store utils', () => {
key: 'test_var_2',
masked: 'false',
protected: 'false',
+ secret_value: 'test_val_2',
value: 'test_val_2',
variable_type: 'file',
});
diff --git a/spec/frontend/contributors/store/getters_spec.js b/spec/frontend/contributors/store/getters_spec.js
index 62ae9b36f87..e6342a669b7 100644
--- a/spec/frontend/contributors/store/getters_spec.js
+++ b/spec/frontend/contributors/store/getters_spec.js
@@ -29,33 +29,39 @@ describe('Contributors Store Getters', () => {
beforeAll(() => {
state.chartData = [
+ { author_name: 'John Smith', author_email: 'jawnnypoo@gmail.com', date: '2019-05-05' },
{ author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-05-05' },
- { author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-05-05' },
- { author_name: 'Carlson', author_email: 'jawnnypoo@gmail.com', date: '2019-03-03' },
- { author_name: 'Carlson', author_email: 'jawnnypoo@gmail.com', date: '2019-05-05' },
- { author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-04-04' },
+ { author_name: 'Carlson', author_email: 'carlson123@gitlab.com', date: '2019-03-03' },
+ { author_name: 'Carlson', author_email: 'carlson123@gmail.com', date: '2019-05-05' },
{ author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-04-04' },
+ { author_name: 'Johan', author_email: 'jawnnypoo@gmail.com', date: '2019-04-04' },
{ author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-03-03' },
];
parsed = getters.parsedData(state);
});
- it('should group contributions by date ', () => {
+ it('should group contributions by date', () => {
expect(parsed.total).toMatchObject({ '2019-05-05': 3, '2019-03-03': 2, '2019-04-04': 2 });
});
- it('should group contributions by author ', () => {
- expect(parsed.byAuthor).toMatchObject({
- Carlson: {
- email: 'jawnnypoo@gmail.com',
- commits: 2,
+ it('should group contributions by email and use most recent name', () => {
+ expect(parsed.byAuthorEmail).toMatchObject({
+ 'carlson123@gmail.com': {
+ name: 'Carlson',
+ commits: 1,
dates: {
- '2019-03-03': 1,
'2019-05-05': 1,
},
},
- John: {
- email: 'jawnnypoo@gmail.com',
+ 'carlson123@gitlab.com': {
+ name: 'Carlson',
+ commits: 1,
+ dates: {
+ '2019-03-03': 1,
+ },
+ },
+ 'jawnnypoo@gmail.com': {
+ name: 'John Smith',
commits: 5,
dates: {
'2019-03-03': 1,
diff --git a/spec/frontend/reports/store/utils_spec.js b/spec/frontend/reports/store/utils_spec.js
index 0d9a8dd4585..9ae456658dc 100644
--- a/spec/frontend/reports/store/utils_spec.js
+++ b/spec/frontend/reports/store/utils_spec.js
@@ -30,9 +30,7 @@ describe('Reports store utils', () => {
const data = { failed: 3, total: 10 };
const result = utils.summaryTextBuilder(name, data);
- expect(result).toBe(
- 'Test summary contained 3 failed/error test results out of 10 total tests',
- );
+ expect(result).toBe('Test summary contained 3 failed out of 10 total tests');
});
it('should render text for multiple errored results', () => {
@@ -40,9 +38,7 @@ describe('Reports store utils', () => {
const data = { errored: 7, total: 10 };
const result = utils.summaryTextBuilder(name, data);
- expect(result).toBe(
- 'Test summary contained 7 failed/error test results out of 10 total tests',
- );
+ expect(result).toBe('Test summary contained 7 errors out of 10 total tests');
});
it('should render text for multiple fixed results', () => {
@@ -59,7 +55,7 @@ describe('Reports store utils', () => {
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 3 failed/error test results and 4 fixed test results out of 10 total tests',
+ 'Test summary contained 3 failed and 4 fixed test results out of 10 total tests',
);
});
@@ -69,18 +65,17 @@ describe('Reports store utils', () => {
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 1 failed/error test result and 1 fixed test result out of 10 total tests',
+ 'Test summary contained 1 failed and 1 fixed test result out of 10 total tests',
);
});
it('should render text for singular failed, errored, and fixed results', () => {
- // these will be singular when the copy is updated
const name = 'Test summary';
const data = { failed: 1, errored: 1, resolved: 1, total: 10 };
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 2 failed/error test results and 1 fixed test result out of 10 total tests',
+ 'Test summary contained 1 failed, 1 error and 1 fixed test result out of 10 total tests',
);
});
@@ -90,7 +85,7 @@ describe('Reports store utils', () => {
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 5 failed/error test results and 4 fixed test results out of 10 total tests',
+ 'Test summary contained 2 failed, 3 errors and 4 fixed test results out of 10 total tests',
);
});
});
@@ -117,7 +112,7 @@ describe('Reports store utils', () => {
const data = { failed: 3, total: 10 };
const result = utils.reportTextBuilder(name, data);
- expect(result).toBe('Rspec found 3 failed/error test results out of 10 total tests');
+ expect(result).toBe('Rspec found 3 failed out of 10 total tests');
});
it('should render text for multiple errored results', () => {
@@ -125,7 +120,7 @@ describe('Reports store utils', () => {
const data = { errored: 7, total: 10 };
const result = utils.reportTextBuilder(name, data);
- expect(result).toBe('Rspec found 7 failed/error test results out of 10 total tests');
+ expect(result).toBe('Rspec found 7 errors out of 10 total tests');
});
it('should render text for multiple fixed results', () => {
@@ -141,9 +136,7 @@ describe('Reports store utils', () => {
const data = { failed: 3, resolved: 4, total: 10 };
const result = utils.reportTextBuilder(name, data);
- expect(result).toBe(
- 'Rspec found 3 failed/error test results and 4 fixed test results out of 10 total tests',
- );
+ expect(result).toBe('Rspec found 3 failed and 4 fixed test results out of 10 total tests');
});
it('should render text for a singular fixed, and a singular failed result', () => {
@@ -151,19 +144,16 @@ describe('Reports store utils', () => {
const data = { failed: 1, resolved: 1, total: 10 };
const result = utils.reportTextBuilder(name, data);
- expect(result).toBe(
- 'Rspec found 1 failed/error test result and 1 fixed test result out of 10 total tests',
- );
+ expect(result).toBe('Rspec found 1 failed and 1 fixed test result out of 10 total tests');
});
it('should render text for singular failed, errored, and fixed results', () => {
- // these will be singular when the copy is updated
const name = 'Rspec';
const data = { failed: 1, errored: 1, resolved: 1, total: 10 };
const result = utils.reportTextBuilder(name, data);
expect(result).toBe(
- 'Rspec found 2 failed/error test results and 1 fixed test result out of 10 total tests',
+ 'Rspec found 1 failed, 1 error and 1 fixed test result out of 10 total tests',
);
});
@@ -173,7 +163,7 @@ describe('Reports store utils', () => {
const result = utils.reportTextBuilder(name, data);
expect(result).toBe(
- 'Rspec found 5 failed/error test results and 4 fixed test results out of 10 total tests',
+ 'Rspec found 2 failed, 3 errors and 4 fixed test results out of 10 total tests',
);
});
});
diff --git a/spec/frontend/sidebar/mock_data.js b/spec/frontend/sidebar/mock_data.js
index c7e52eae9bd..3dde40260eb 100644
--- a/spec/frontend/sidebar/mock_data.js
+++ b/spec/frontend/sidebar/mock_data.js
@@ -204,7 +204,7 @@ const mockData = {
},
rootPath: '/',
fullPath: '/gitlab-org/gitlab-shell',
- id: 1,
+ iid: 1,
},
time: {
time_estimate: 3600,