1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import MlCandidatesShow from '~/ml/experiment_tracking/routes/candidates/show';
import { TITLE_LABEL } from '~/ml/experiment_tracking/routes/candidates/show/translations';
import DeleteButton from '~/ml/experiment_tracking/components/delete_button.vue';
import ModelExperimentsHeader from '~/ml/experiment_tracking/components/model_experiments_header.vue';
describe('MlCandidatesShow', () => {
let wrapper;
const createWrapper = () => {
const candidate = {
params: [
{ name: 'Algorithm', value: 'Decision Tree' },
{ name: 'MaxDepth', value: '3' },
],
metrics: [
{ name: 'AUC', value: '.55' },
{ name: 'Accuracy', value: '.99' },
],
metadata: [
{ name: 'FileName', value: 'test.py' },
{ name: 'ExecutionTime', value: '.0856' },
],
info: {
iid: 'candidate_iid',
eid: 'abcdefg',
path_to_artifact: 'path_to_artifact',
experiment_name: 'The Experiment',
experiment_path: 'path/to/experiment',
status: 'SUCCESS',
path: 'path_to_candidate',
},
};
wrapper = shallowMountExtended(MlCandidatesShow, { propsData: { candidate } });
};
beforeEach(createWrapper);
const findDeleteButton = () => wrapper.findComponent(DeleteButton);
const findHeader = () => wrapper.findComponent(ModelExperimentsHeader);
it('shows delete button', () => {
expect(findDeleteButton().exists()).toBe(true);
});
it('passes the delete path to delete button', () => {
expect(findDeleteButton().props('deletePath')).toBe('path_to_candidate');
});
it('passes the right title', () => {
expect(findHeader().props('pageTitle')).toBe(TITLE_LABEL);
});
it('renders correctly', () => {
expect(wrapper.element).toMatchSnapshot();
});
});
|