diff options
Diffstat (limited to 'spec/components/projects/ml/show_ml_model_component_spec.rb')
-rw-r--r-- | spec/components/projects/ml/show_ml_model_component_spec.rb | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/spec/components/projects/ml/show_ml_model_component_spec.rb b/spec/components/projects/ml/show_ml_model_component_spec.rb index ec125851d3d..34b8cbe96ca 100644 --- a/spec/components/projects/ml/show_ml_model_component_spec.rb +++ b/spec/components/projects/ml/show_ml_model_component_spec.rb @@ -4,14 +4,22 @@ 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) { build_stubbed(:ml_models, :with_latest_version_and_package, project: 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) + 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 @@ -23,11 +31,30 @@ RSpec.describe Projects::Ml::ShowMlModelComponent, type: :component, feature_cat 'id' => model1.id, 'name' => model1.name, 'path' => "/#{project.full_path}/-/ml/models/#{model1.id}", - 'description' => 'This is a placeholder for the short description', + 'description' => 'A description', 'latestVersion' => { - 'version' => model1.latest_version.version + '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 + 'versionCount' => 1, + 'candidateCount' => 2 } }) end |