2020-05-24 23:13:21 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
2021-11-18 22:05:49 +05:30
|
|
|
import data from 'test_fixtures/deploy_keys/keys.json';
|
2020-05-24 23:13:21 +05:30
|
|
|
import deployKeysPanel from '~/deploy_keys/components/keys_panel.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import DeployKeysStore from '~/deploy_keys/store';
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
describe('Deploy keys panel', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const findTableRowHeader = () => wrapper.find('.table-row-header');
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const mountComponent = (props) => {
|
2020-05-24 23:13:21 +05:30
|
|
|
const store = new DeployKeysStore();
|
|
|
|
store.keys = data;
|
|
|
|
wrapper = mount(deployKeysPanel, {
|
|
|
|
propsData: {
|
|
|
|
title: 'test',
|
|
|
|
keys: data.enabled_keys,
|
|
|
|
showHelpBox: true,
|
|
|
|
store,
|
|
|
|
endpoint: 'https://test.host/dummy/endpoint',
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders list of keys', () => {
|
|
|
|
mountComponent();
|
|
|
|
expect(wrapper.findAll('.deploy-key').length).toBe(wrapper.vm.keys.length);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders table header', () => {
|
|
|
|
mountComponent();
|
|
|
|
const tableHeader = findTableRowHeader();
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
expect(tableHeader.exists()).toBe(true);
|
2020-05-24 23:13:21 +05:30
|
|
|
expect(tableHeader.text()).toContain('Deploy key');
|
|
|
|
expect(tableHeader.text()).toContain('Project usage');
|
|
|
|
expect(tableHeader.text()).toContain('Created');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders help box if keys are empty', () => {
|
|
|
|
mountComponent({ keys: [] });
|
|
|
|
|
|
|
|
expect(wrapper.find('.settings-message').exists()).toBe(true);
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(wrapper.find('.settings-message').text().trim()).toBe(
|
|
|
|
'No deploy keys found. Create one with the form above.',
|
|
|
|
);
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders no table header if keys are empty', () => {
|
|
|
|
mountComponent({ keys: [] });
|
|
|
|
expect(findTableRowHeader().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|