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
59
60
61
62
|
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Projects::Ml::ShowMlModelComponent, type: :component, feature_category: :mlops do
let_it_be(:project) { build_stubbed(:project) }
let_it_be(:model1) do
build_stubbed(:ml_models, :with_latest_version_and_package, project: project, description: "A description")
end
let_it_be(:experiment) { model1.default_experiment.tap { |e| e.iid = 100 } }
let_it_be(:candidate) { model1.latest_version.candidate.tap { |c| c.iid = 101 } }
let_it_be(:candidates) { Array.new(2) { build_stubbed(:ml_candidates, experiment: experiment) } }
subject(:component) do
described_class.new(model: model1, current_user: model1.user)
end
describe 'rendered' do
before do
allow(model1).to receive(:candidates).and_return(candidates)
render_inline component
end
it 'renders element with view_model' do
element = page.find("#js-mount-show-ml-model")
expect(Gitlab::Json.parse(element['data-view-model'])).to eq({
'model' => {
'id' => model1.id,
'name' => model1.name,
'path' => "/#{project.full_path}/-/ml/models/#{model1.id}",
'description' => 'A description',
'latestVersion' => {
'version' => model1.latest_version.version,
'description' => model1.latest_version.description,
'projectPath' => "/#{project.full_path}",
'packageId' => model1.latest_version.package_id,
'candidate' => {
'info' => {
'iid' => candidate.iid,
'eid' => candidate.eid,
'pathToArtifact' => nil,
'experimentName' => candidate.experiment.name,
'pathToExperiment' => "/#{project.full_path}/-/ml/experiments/#{experiment.iid}",
'status' => 'running',
'path' => "/#{project.full_path}/-/ml/candidates/#{candidate.iid}",
'ciJob' => nil
},
'metrics' => [],
'params' => [],
'metadata' => []
}
},
'versionCount' => 1,
'candidateCount' => 2
}
})
end
end
end
|