diff options
Diffstat (limited to 'spec/components/projects/ml')
3 files changed, 67 insertions, 7 deletions
diff --git a/spec/components/projects/ml/models_index_component_spec.rb b/spec/components/projects/ml/models_index_component_spec.rb index b662e8c0a08..f020ae5bbef 100644 --- a/spec/components/projects/ml/models_index_component_spec.rb +++ b/spec/components/projects/ml/models_index_component_spec.rb @@ -43,12 +43,14 @@ RSpec.describe Projects::Ml::ModelsIndexComponent, type: :component, feature_cat { 'name' => model1.name, 'version' => model1.latest_version.version, + 'path' => "/#{project.full_path}/-/ml/models/#{model1.id}", 'versionPackagePath' => "/#{project.full_path}/-/packages/#{model1.latest_version.package_id}", 'versionPath' => "/#{project.full_path}/-/ml/models/#{model1.id}/versions/#{model1.latest_version.id}", 'versionCount' => 1 }, { 'name' => model2.name, + 'path' => "/#{project.full_path}/-/ml/models/#{model2.id}", 'version' => nil, 'versionPackagePath' => nil, 'versionPath' => nil, 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 diff --git a/spec/components/projects/ml/show_ml_model_version_component_spec.rb b/spec/components/projects/ml/show_ml_model_version_component_spec.rb index 973d8123c45..8c7e40d31a2 100644 --- a/spec/components/projects/ml/show_ml_model_version_component_spec.rb +++ b/spec/components/projects/ml/show_ml_model_version_component_spec.rb @@ -4,11 +4,24 @@ require "spec_helper" RSpec.describe Projects::Ml::ShowMlModelVersionComponent, type: :component, feature_category: :mlops do let_it_be(:project) { build_stubbed(:project) } + let_it_be(:user) { project.owner } let_it_be(:model) { build_stubbed(:ml_models, project: project) } - let_it_be(:version) { build_stubbed(:ml_model_versions, model: model) } + let_it_be(:experiment) do + model.default_experiment.iid = 100 + model.default_experiment + end + + let_it_be(:candidate) do + build_stubbed(:ml_candidates, :with_artifact, experiment: experiment, user: user, project: project, + internal_id: 100) + end + + let_it_be(:version) do + build_stubbed(:ml_model_versions, :with_package, model: model, candidate: candidate, description: 'abc') + end subject(:component) do - described_class.new(model_version: version) + described_class.new(model_version: version, current_user: user) end describe 'rendered' do @@ -23,10 +36,28 @@ RSpec.describe Projects::Ml::ShowMlModelVersionComponent, type: :component, feat 'modelVersion' => { 'id' => version.id, 'version' => version.version, + 'description' => 'abc', + 'projectPath' => "/#{project.full_path}", 'path' => "/#{project.full_path}/-/ml/models/#{model.id}/versions/#{version.id}", + 'packageId' => version.package_id, 'model' => { 'name' => model.name, 'path' => "/#{project.full_path}/-/ml/models/#{model.id}" + }, + 'candidate' => { + 'info' => { + 'iid' => candidate.iid, + 'eid' => candidate.eid, + 'pathToArtifact' => "/#{project.full_path}/-/packages/#{candidate.artifact.id}", + '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' => [] } } }) |