Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-27 06:07:12 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-27 06:07:12 +0300
commit39c9abe4fe410ac402d57a364bf89938a2067315 (patch)
treef38997756bbee3f1ea2d7e9f67a5f374e3a87fd1 /spec/frontend
parentdfc8a99695e16feffcc811a536e58e2c9be75ce2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/ml/model_registry/apps/index_ml_models_spec.js15
-rw-r--r--spec/frontend/ml/model_registry/components/model_row_spec.js22
-rw-r--r--spec/frontend/ml/model_registry/mock_data.js1
3 files changed, 27 insertions, 11 deletions
diff --git a/spec/frontend/ml/model_registry/apps/index_ml_models_spec.js b/spec/frontend/ml/model_registry/apps/index_ml_models_spec.js
index 612b5ecbc40..6e0ab2ebe2d 100644
--- a/spec/frontend/ml/model_registry/apps/index_ml_models_spec.js
+++ b/spec/frontend/ml/model_registry/apps/index_ml_models_spec.js
@@ -5,18 +5,23 @@ import { TITLE_LABEL, NO_MODELS_LABEL } from '~/ml/model_registry/translations';
import Pagination from '~/vue_shared/components/incubation/pagination.vue';
import SearchBar from '~/ml/model_registry/components/search_bar.vue';
import { BASE_SORT_FIELDS } from '~/ml/model_registry/constants';
+import TitleArea from '~/vue_shared/components/registry/title_area.vue';
+import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue';
import { mockModels, startCursor, defaultPageInfo } from '../mock_data';
let wrapper;
-const createWrapper = (propsData = { models: mockModels, pageInfo: defaultPageInfo }) => {
+const createWrapper = (
+ propsData = { models: mockModels, pageInfo: defaultPageInfo, modelCount: 2 },
+) => {
wrapper = shallowMountExtended(IndexMlModels, { propsData });
};
const findModelRow = (index) => wrapper.findAllComponents(ModelRow).at(index);
const findPagination = () => wrapper.findComponent(Pagination);
-const findTitle = () => wrapper.findByText(TITLE_LABEL);
const findEmptyLabel = () => wrapper.findByText(NO_MODELS_LABEL);
const findSearchBar = () => wrapper.findComponent(SearchBar);
+const findTitleArea = () => wrapper.findComponent(TitleArea);
+const findModelCountMetadataItem = () => findTitleArea().findComponent(MetadataItem);
describe('MlModelsIndex', () => {
describe('empty state', () => {
@@ -46,7 +51,11 @@ describe('MlModelsIndex', () => {
describe('header', () => {
it('displays the title', () => {
- expect(findTitle().exists()).toBe(true);
+ expect(findTitleArea().props('title')).toBe(TITLE_LABEL);
+ });
+
+ it('sets model metadata item to model count', () => {
+ expect(findModelCountMetadataItem().props('text')).toBe(`2 models`);
});
});
diff --git a/spec/frontend/ml/model_registry/components/model_row_spec.js b/spec/frontend/ml/model_registry/components/model_row_spec.js
index 037abab0ac4..9d16ce5c466 100644
--- a/spec/frontend/ml/model_registry/components/model_row_spec.js
+++ b/spec/frontend/ml/model_registry/components/model_row_spec.js
@@ -8,27 +8,33 @@ const createWrapper = (model = mockModels[0]) => {
wrapper = shallowMountExtended(ModelRow, { propsData: { model } });
};
-const findLink = () => wrapper.findComponent(GlLink);
+const findTitleLink = () => wrapper.findAllComponents(GlLink).at(0);
+const findVersionLink = () => wrapper.findAllComponents(GlLink).at(1);
const findMessage = (message) => wrapper.findByText(message);
describe('ModelRow', () => {
- beforeEach(() => {
+ it('Has a link to the model', () => {
createWrapper();
- });
- it('Has a link to the model', () => {
- expect(findLink().text()).toBe(mockModels[0].name);
- expect(findLink().attributes('href')).toBe(mockModels[0].path);
+ expect(findTitleLink().text()).toBe(mockModels[0].name);
+ expect(findTitleLink().attributes('href')).toBe(mockModels[0].path);
});
it('Shows the latest version and the version count', () => {
- expect(findMessage('1.0 · 3 versions').exists()).toBe(true);
+ createWrapper();
+
+ expect(findVersionLink().text()).toBe(mockModels[0].version);
+ expect(findVersionLink().attributes('href')).toBe(mockModels[0].versionPath);
+ expect(findMessage('· 3 versions').exists()).toBe(true);
});
it('Shows the latest version and no version count if it has only 1 version', () => {
createWrapper(mockModels[1]);
- expect(findMessage('1.1 · No other versions').exists()).toBe(true);
+ expect(findVersionLink().text()).toBe(mockModels[1].version);
+ expect(findVersionLink().attributes('href')).toBe(mockModels[1].versionPath);
+
+ expect(findMessage('· No other versions').exists()).toBe(true);
});
it('Shows no version message if model has no versions', () => {
diff --git a/spec/frontend/ml/model_registry/mock_data.js b/spec/frontend/ml/model_registry/mock_data.js
index 1c606e79fa2..a820c323103 100644
--- a/spec/frontend/ml/model_registry/mock_data.js
+++ b/spec/frontend/ml/model_registry/mock_data.js
@@ -20,6 +20,7 @@ export const mockModels = [
{
name: 'model_1',
version: '1.0',
+ versionPath: 'path/to/version',
path: 'path/to/model_1',
versionCount: 3,
},