summaryrefslogtreecommitdiff
path: root/spec/frontend/ml/experiment_tracking/components/experiment_spec.js
blob: af722d77532a0227d25ee68c0763e06099067bc2 (plain)
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
import { GlAlert } from '@gitlab/ui';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import ShowExperiment from '~/ml/experiment_tracking/components/experiment.vue';

describe('ShowExperiment', () => {
  let wrapper;

  const createWrapper = (candidates = [], metricNames = [], paramNames = []) => {
    return mountExtended(ShowExperiment, { provide: { candidates, metricNames, paramNames } });
  };

  const findAlert = () => wrapper.findComponent(GlAlert);

  const findEmptyState = () => wrapper.findByText('This Experiment has no logged Candidates');

  it('shows incubation warning', () => {
    wrapper = createWrapper();

    expect(findAlert().exists()).toBe(true);
  });

  describe('no candidates', () => {
    it('shows empty state', () => {
      wrapper = createWrapper();

      expect(findEmptyState().exists()).toBe(true);
    });
  });

  describe('with candidates', () => {
    it('renders correctly', () => {
      wrapper = createWrapper(
        [
          { rmse: 1, l1_ratio: 0.4 },
          { auc: 0.3, l1_ratio: 0.5 },
        ],
        ['rmse', 'auc', 'mae'],
        ['l1_ratio'],
      );

      expect(wrapper.element).toMatchSnapshot();
    });
  });
});