From 732e8d088a69c989a97170eefb3172e78b0a20b5 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Thu, 25 Aug 2022 16:02:00 +0300 Subject: [PATCH 01/11] Added tests to create/get a task with skeletons --- cvat-core/tests/api/tasks.js | 80 ++++++++++++++++++- cvat-core/tests/mocks/dummy-data.mock.js | 99 ++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 2 deletions(-) diff --git a/cvat-core/tests/api/tasks.js b/cvat-core/tests/api/tasks.js index ea1299dda4c4..393748e09f48 100644 --- a/cvat-core/tests/api/tasks.js +++ b/cvat-core/tests/api/tasks.js @@ -18,7 +18,7 @@ describe('Feature: get a list of tasks', () => { test('get all tasks', async () => { const result = await window.cvat.tasks.get(); expect(Array.isArray(result)).toBeTruthy(); - expect(result).toHaveLength(6); + expect(result).toHaveLength(7); for (const el of result) { expect(el).toBeInstanceOf(Task); } @@ -34,6 +34,33 @@ describe('Feature: get a list of tasks', () => { expect(result[0].id).toBe(3); }); + test('get a task with skeletons by an id', async () => { + const result = await window.cvat.tasks.get({ + id: 4, + }); + + expect(Array.isArray(result)).toBeTruthy(); + expect(result).toHaveLength(1); + expect(result[0]).toBeInstanceOf(Task); + expect(result[0].id).toBe(4); + expect(result[0].labels).toBeInstanceOf(Array); + + for (const label of result[0].labels) { + expect(label).toBeInstanceOf(window.cvat.classes.Label); + if (label.type === 'skeleton') { + expect(label.hasParent).toBe(false); + expect(label.structure.sublabels).toBeInstanceOf(Array); + expect(typeof label.structure.svg).toBe('string'); + expect(label.structure.svg.length).not.toBe(0); + + for (const sublabel of label.structure.sublabels) { + expect(sublabel).toBeInstanceOf(window.cvat.classes.Label); + expect(sublabel.hasParent).toBe(true); + } + } + } + }); + test('get a task by an unknown id', async () => { const result = await window.cvat.tasks.get({ id: 50, @@ -154,12 +181,61 @@ describe('Feature: save a task', () => { project_id: 2, bug_tracker: 'bug tracker value', image_quality: 50, - z_order: true, }); const result = await task.save(); expect(result.projectId).toBe(2); }); + + test('create a new task with skeletons', async () => { + const svgSpec = ` + + + + + + + + + + + `; + + const task = new window.cvat.classes.Task({ + name: 'task with skeletons', + labels: [{ + name: 'star skeleton', + type: 'skeleton', + attributes: [], + svg: svgSpec, + sublabels: [{ + name: '1', + type: 'points', + attributes: [] + }, { + name: '2', + type: 'points', + attributes: [] + }, { + name: '3', + type: 'points', + attributes: [] + }, { + name: '4', + type: 'points', + attributes: [] + }, { + name: '5', + type: 'points', + attributes: [] + }] + }], + project_id: null, + }); + + const result = await task.save(); + expect(typeof result.id).toBe('number'); + }); }); describe('Feature: delete a task', () => { diff --git a/cvat-core/tests/mocks/dummy-data.mock.js b/cvat-core/tests/mocks/dummy-data.mock.js index 4655f57e7232..ce7c5a72cc21 100644 --- a/cvat-core/tests/mocks/dummy-data.mock.js +++ b/cvat-core/tests/mocks/dummy-data.mock.js @@ -783,6 +783,105 @@ const tasksDummyData = { stop_frame: 5001, frame_filter: '', }, + { + url: 'http://localhost:7000/api/tasks/4', + id: 4, + name: 'test', + project_id: null, + mode: 'annotation', + owner: { + url: 'http://localhost:7000/api/users/1', + id: 1, + username: 'admin', + first_name: '', + last_name: '', + }, + assignee: null, + bug_tracker: '', + created_date: '2022-08-25T12:10:45.471663Z', + updated_date: '2022-08-25T12:10:45.993989Z', + overlap: 0, + segment_size: 4, + status: 'annotation', + labels: [{ + id: 54, + name: 'star skeleton', + color: '#9cb75a', + attributes: [], + type: 'skeleton', + sublabels: [{ + id: 55, + name: '1', + color: '#d12345', + attributes: [], + type: 'points', + has_parent: true + }, { + id: 56, + name: '2', + color: '#350dea', + attributes: [], + type: 'points', + has_parent: true + }, { + id: 57, + name: '3', + color: '#479ffe', + attributes: [], + type: 'points', + has_parent: true + }, { + id: 58, + name: '4', + color: '#4a649f', + attributes: [], + type: 'points', + has_parent: true + }, { + id: 59, + name: '5', + color: '#478144', + attributes: [], + type: 'points', + has_parent: true + }], + has_parent: false, + svg: + ` + + + + + + + + + ` + }], + segments: [{ + start_frame: 0, + stop_frame: 3, + jobs: [{ + url: 'http://localhost:7000/api/jobs/41', + id: 10, + assignee: null, + status: 'annotation', + stage: 'annotation', + state: 'new', + }] + }], + data_chunk_size: 17, + data_compressed_chunk_type: 'imageset', + data_original_chunk_type: 'imageset', + size: 4, + image_quality: 70, + data: 12, + dimension: '2d', + subset: '', + organization: null, + target_storage: null, + source_storage: null + }, { url: 'http://localhost:7000/api/tasks/3', id: 3, From f96772929de7779a62398a36ac7ac31f09bb42be Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 26 Aug 2022 12:45:41 +0300 Subject: [PATCH 02/11] Added some dummy data for tests --- cvat-core/.eslintrc.js | 3 +- cvat-core/tests/mocks/dummy-data.mock.js | 239 ++++++++++++++++++++++- 2 files changed, 239 insertions(+), 3 deletions(-) diff --git a/cvat-core/.eslintrc.js b/cvat-core/.eslintrc.js index 1a036f8d0134..8c23ac231052 100644 --- a/cvat-core/.eslintrc.js +++ b/cvat-core/.eslintrc.js @@ -25,5 +25,6 @@ module.exports = { 'jest/no-focused-tests': 'error', 'jest/no-identical-title': 'error', 'jest/prefer-to-have-length': 'warn', - } + }, + ignorePatterns: ['tests/mocks/*.js'] }; diff --git a/cvat-core/tests/mocks/dummy-data.mock.js b/cvat-core/tests/mocks/dummy-data.mock.js index ce7c5a72cc21..9cfe6cd52e5c 100644 --- a/cvat-core/tests/mocks/dummy-data.mock.js +++ b/cvat-core/tests/mocks/dummy-data.mock.js @@ -862,8 +862,8 @@ const tasksDummyData = { start_frame: 0, stop_frame: 3, jobs: [{ - url: 'http://localhost:7000/api/jobs/41', - id: 10, + url: 'http://localhost:7000/api/jobs/40', + id: 40, assignee: null, status: 'annotation', stage: 'annotation', @@ -2631,6 +2631,241 @@ const taskAnnotationsDummyData = { ], tracks: [], }, + 40: { + version: 0, + tags: [], + shapes: [{ + type: 'skeleton', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [], + id: 23, + frame: 0, + label_id: 54, + group: 0, + source: 'manual', + attributes: [], + elements: [{ + type: 'points', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 908.0654296875, + 768.8268729552019 + ], + id: 24, + frame: 0, + label_id: 55, + group: 0, + source: 'manual', + attributes: [] + }, { + type: "points", + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 1230.1533057030483, + 523.7802734375 + ], + id: 25, + frame: 0, + label_id: 56, + group: 0, + source: 'manual', + attributes: [] + }, { + type: 'points', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 1525.9969940892624, + 772.6557444966547 + ], + id: 26, + frame: 0, + label_id: 57, + group: 0, + source: 'manual', + attributes: [] + }, { + type: 'points', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 1468.7369236136856, + 1270.4066429432623 + ], + id: 27, + frame: 0, + label_id: 58, + group: 0, + source: 'manual', + attributes: [] + }, { + type: 'points', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 989.1838401839595, + 1258.9201156622657 + ], + id: 28, + frame: 0, + label_id:59, + group: 0, + source: 'manual', + attributes: [] + }] + }], + tracks: [{ + id: 1, + frame: 0, + label_id: 54, + group: 0, + source: 'manual', + shapes: [{ + type: 'skeleton', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 621.2718553459108, + 771.9905099538341, + 970.1964146088677, + 535.5863207547154, + 1290.6900943396213, + 775.6843431842781, + 1228.6590576510816, + 1255.880345911948, + 709.1491327545872, + 1244.7989304835269 + ], + id: 1, + frame: 0, + attributes: [] + }], + attributes: [], + elements: [{ + id: 2, + frame: 0, + label_id: 55, + group: 0, + source: 'manual', + shapes: [{ + type: 'points', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 88.4140625, + 332.85145482411826 + ], + id: 2, + frame: 0, + attributes: [] + }], + attributes: [] + }, { + id: 3, + frame: 0, + label_id: 56, + group: 0, + source: 'manual', + shapes: [{ + type: 'points', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 437.3386217629577, + 96.447265625 + ], + id: 3, + frame: 0, + attributes: [] + }], + attributes: [] + }, { + id: 4, + frame: 0, + label_id: 57, + group: 0, + source: 'manual', + shapes: [{ + type: 'points', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 757.8323014937105, + 336.54528805456357 + ], + id: 4, + frame: 0, + attributes: [] + }], + attributes: [] + }, { + id: 5, + frame: 0, + label_id: 58, + group: 0, + source: 'manual', + shapes: [{ + type: 'points', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 695.8012648051717, + 816.7412907822327 + ], + id: 5, + frame: 0, + attributes: [] + }], + attributes: [] + }, { + id: 6, + frame: 0, + label_id: 59, + group: 0, + source: 'manual', + shapes: [{ + type: 'points', + occluded: false, + outside: false, + z_order: 0, + rotation: 0.0, + points: [ + 176.29133990867558, + 805.659875353811 + ], + id: 6, + frame: 0, + attributes: [] + }], + attributes: [] + }] + }] + } }; const jobAnnotationsDummyData = JSON.parse(JSON.stringify(taskAnnotationsDummyData)); From d4234b45d6687cc31b266adf16f0fea7cca1c0f6 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 26 Aug 2022 13:38:55 +0300 Subject: [PATCH 03/11] Added a couple of tests --- cvat-core/.eslintrc.js | 2 +- cvat-core/tests/api/annotations.js | 50 ++++++++++++++++++++++++ cvat-core/tests/mocks/dummy-data.mock.js | 43 ++++++++++++++------ lint-staged.config.js | 2 +- 4 files changed, 83 insertions(+), 14 deletions(-) diff --git a/cvat-core/.eslintrc.js b/cvat-core/.eslintrc.js index 8c23ac231052..543230536e67 100644 --- a/cvat-core/.eslintrc.js +++ b/cvat-core/.eslintrc.js @@ -26,5 +26,5 @@ module.exports = { 'jest/no-identical-title': 'error', 'jest/prefer-to-have-length': 'warn', }, - ignorePatterns: ['tests/mocks/*.js'] + ignorePatterns: ['tests/**/*.js'] }; diff --git a/cvat-core/tests/api/annotations.js b/cvat-core/tests/api/annotations.js index 47ba508b182d..01dcd4b6548c 100644 --- a/cvat-core/tests/api/annotations.js +++ b/cvat-core/tests/api/annotations.js @@ -1,4 +1,5 @@ // Copyright (C) 2020-2022 Intel Corporation +// Copyright (C) 2022 CVAT.ai Corp // // SPDX-License-Identifier: MIT @@ -64,6 +65,28 @@ describe('Feature: get annotations', () => { expect(annotations).toHaveLength(1); expect(annotations[0].shapeType).toBe('ellipse'); }); + + test('get skeletons with a filter', async () => { + const job = (await window.cvat.jobs.get({ jobID: 40 }))[0]; + const annotations = await job.annotations.get(0, false, JSON.parse('[{"and":[{"==":[{"var":"shape"},"skeleton"]}]}]')); + expect(Array.isArray(annotations)).toBeTruthy(); + expect(annotations).toHaveLength(2); + for (const object of annotations) { + expect(object.shapeType).toBe('skeleton'); + expect(object.elements).toBeInstanceOf(Array); + const label = object.label; + let points = []; + object.elements.forEach((element, idx) => { + expect(element).toBeInstanceOf(cvat.classes.ObjectState); + expect(element.label.id).toBe(label.structure.sublabels[idx].id); + expect(element.shapeType).toBe('points'); + points = [...points, ...element.points]; + }); + expect(points).toEqual(object.points); + } + + expect(annotations[0].shapeType).toBe('skeleton'); + }) }); describe('Feature: get interpolated annotations', () => { @@ -350,6 +373,18 @@ describe('Feature: put annotations', () => { zOrder: 0, })).toThrow(window.cvat.exceptions.ArgumentError); }); + + test('put a skeleton to a job', async() => { + + }); + + test('put a skeleton to a task', async() => { + + }); + + test('put a wrong skeleton to a job', async() => { + + }); }); describe('Feature: check unsaved changes', () => { @@ -770,6 +805,21 @@ describe('Feature: get statistics', () => { expect(statistics).toBeInstanceOf(window.cvat.classes.Statistics); expect(statistics.total.total).toBe(1012); }); + + test('get statistics from a job with skeletons', async () => { + const job = (await window.cvat.jobs.get({ jobID: 40 }))[0]; + await job.annotations.clear(true); + const statistics = await job.annotations.statistics(); + expect(statistics).toBeInstanceOf(window.cvat.classes.Statistics); + expect(statistics.total.total).toBe(30); + const labelName = job.labels[0].name; + expect(statistics.label[labelName].skeleton.shape).toBe(1); + expect(statistics.label[labelName].skeleton.track).toBe(1); + expect(statistics.label[labelName].manually).toBe(2); + expect(statistics.label[labelName].interpolated).toBe(3); + expect(statistics.label[labelName].total).toBe(5); + + }); }); describe('Feature: select object', () => { diff --git a/cvat-core/tests/mocks/dummy-data.mock.js b/cvat-core/tests/mocks/dummy-data.mock.js index 9cfe6cd52e5c..b7afb408738b 100644 --- a/cvat-core/tests/mocks/dummy-data.mock.js +++ b/cvat-core/tests/mocks/dummy-data.mock.js @@ -2741,18 +2741,7 @@ const taskAnnotationsDummyData = { outside: false, z_order: 0, rotation: 0.0, - points: [ - 621.2718553459108, - 771.9905099538341, - 970.1964146088677, - 535.5863207547154, - 1290.6900943396213, - 775.6843431842781, - 1228.6590576510816, - 1255.880345911948, - 709.1491327545872, - 1244.7989304835269 - ], + points: [], id: 1, frame: 0, attributes: [] @@ -2963,6 +2952,36 @@ const frameMetaDummyData = { }, ], }, + 40: { + chunk_size: 17, + size: 4, + image_quality: 70, + start_frame: 0, + stop_frame: 3, + frame_filter: '', + frames: [{ + width: 2560, + height: 1703, + name: '1598296101_1033667.jpg', + has_related_context: false + }, { + width: 1600, + height: 1200, + name: '30fdce7f27b9c7b1d50108d7c16d23ef.jpg', + has_related_context: false + }, { + width: 2880, + height: 1800, + name: '567362-ily-comedy-drama-1finding-3.jpg', + has_related_context: false + }, { + width: 1920, + height: 1080, + name: '730443-under-the-sea-wallpapers-1920x1080-windows-10.jpg', + has_related_context: false + }], + deleted_frames: [] + }, 100: { chunk_size: 36, size: 9, diff --git a/lint-staged.config.js b/lint-staged.config.js index a9b401e84a2e..5c2ca5314e45 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -14,7 +14,7 @@ module.exports = (stagedFiles) => { const eslintExtensions = ['ts', 'tsx', 'js'].map(makePattern); const eslintFiles = micromatch(stagedFiles, eslintExtensions); - const tests = containsInPath('/tests/', eslintFiles); + const tests = containsInPath('/cvat-core/tests/', eslintFiles); const cvatData = containsInPath('/cvat-data/', eslintFiles); const cvatCore = containsInPath('/cvat-core/', eslintFiles); const cvatCanvas = containsInPath('/cvat-canvas/', eslintFiles); From cb96d1dee2b44b089ba15cb3ccbd7842eb4c31f3 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 26 Aug 2022 13:42:38 +0300 Subject: [PATCH 04/11] Aborted extra changes --- lint-staged.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lint-staged.config.js b/lint-staged.config.js index 5c2ca5314e45..a9b401e84a2e 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -14,7 +14,7 @@ module.exports = (stagedFiles) => { const eslintExtensions = ['ts', 'tsx', 'js'].map(makePattern); const eslintFiles = micromatch(stagedFiles, eslintExtensions); - const tests = containsInPath('/cvat-core/tests/', eslintFiles); + const tests = containsInPath('/tests/', eslintFiles); const cvatData = containsInPath('/cvat-data/', eslintFiles); const cvatCore = containsInPath('/cvat-core/', eslintFiles); const cvatCanvas = containsInPath('/cvat-canvas/', eslintFiles); From 6f9cbb8f639fe937df0108514ba400514a7b0cc5 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 26 Aug 2022 14:28:48 +0300 Subject: [PATCH 05/11] Added a couple of put tests --- cvat-core/tests/api/annotations.js | 58 +++++++++++++++++++++++- cvat-core/tests/api/tasks.js | 4 +- cvat-core/tests/mocks/dummy-data.mock.js | 4 +- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/cvat-core/tests/api/annotations.js b/cvat-core/tests/api/annotations.js index 01dcd4b6548c..357054b4347c 100644 --- a/cvat-core/tests/api/annotations.js +++ b/cvat-core/tests/api/annotations.js @@ -374,12 +374,66 @@ describe('Feature: put annotations', () => { })).toThrow(window.cvat.exceptions.ArgumentError); }); - test('put a skeleton to a job', async() => { + test('put a skeleton shape to a job', async() => { + const job = (await window.cvat.jobs.get({ jobID: 40 }))[0]; + const label = job.labels[0]; + await job.annotations.clear(true); + await job.annotations.clear(); + const skeleton = new window.cvat.classes.ObjectState({ + frame: 0, + objectType: window.cvat.enums.ObjectType.SHAPE, + shapeType: window.cvat.enums.ShapeType.SKELETON, + points: [], + label, + elements: label.structure.sublabels.map((sublabel, idx) => ({ + frame: 0, + objectType: window.cvat.enums.ObjectType.SHAPE, + shapeType: window.cvat.enums.ShapeType.POINTS, + points: [idx * 10, idx * 10], + label: sublabel, + })) + }); + await job.annotations.put([skeleton]); + const annotations = await job.annotations.get(0); + expect(annotations.length).toBe(1); + expect(annotations[0].objectType).toBe(window.cvat.enums.ObjectType.SHAPE); + expect(annotations[0].shapeType).toBe(window.cvat.enums.ShapeType.SKELETON); + for (const element of annotations[0].elements) { + expect(element.objectType).toBe(window.cvat.enums.ObjectType.SHAPE); + expect(element.shapeType).toBe(window.cvat.enums.ShapeType.POINTS); + } }); - test('put a skeleton to a task', async() => { + test('put a skeleton track to a task', async() => { + const task = (await window.cvat.tasks.get({ id: 40 }))[0]; + const label = task.labels[0]; + await task.annotations.clear(true); + await task.annotations.clear(); + const skeleton = new window.cvat.classes.ObjectState({ + frame: 0, + objectType: window.cvat.enums.ObjectType.TRACK, + shapeType: window.cvat.enums.ShapeType.SKELETON, + points: [], + label, + elements: label.structure.sublabels.map((sublabel, idx) => ({ + frame: 0, + objectType: window.cvat.enums.ObjectType.TRACK, + shapeType: window.cvat.enums.ShapeType.POINTS, + points: [idx * 10, idx * 10], + label: sublabel, + })) + }); + await task.annotations.put([skeleton]); + const annotations = await task.annotations.get(2); + expect(annotations.length).toBe(1); + expect(annotations[0].objectType).toBe(window.cvat.enums.ObjectType.TRACK); + expect(annotations[0].shapeType).toBe(window.cvat.enums.ShapeType.SKELETON); + for (const element of annotations[0].elements) { + expect(element.objectType).toBe(window.cvat.enums.ObjectType.TRACK); + expect(element.shapeType).toBe(window.cvat.enums.ShapeType.POINTS); + } }); test('put a wrong skeleton to a job', async() => { diff --git a/cvat-core/tests/api/tasks.js b/cvat-core/tests/api/tasks.js index 393748e09f48..bbb990c81cf8 100644 --- a/cvat-core/tests/api/tasks.js +++ b/cvat-core/tests/api/tasks.js @@ -36,13 +36,13 @@ describe('Feature: get a list of tasks', () => { test('get a task with skeletons by an id', async () => { const result = await window.cvat.tasks.get({ - id: 4, + id: 40, }); expect(Array.isArray(result)).toBeTruthy(); expect(result).toHaveLength(1); expect(result[0]).toBeInstanceOf(Task); - expect(result[0].id).toBe(4); + expect(result[0].id).toBe(40); expect(result[0].labels).toBeInstanceOf(Array); for (const label of result[0].labels) { diff --git a/cvat-core/tests/mocks/dummy-data.mock.js b/cvat-core/tests/mocks/dummy-data.mock.js index b7afb408738b..2b4edfff1d2d 100644 --- a/cvat-core/tests/mocks/dummy-data.mock.js +++ b/cvat-core/tests/mocks/dummy-data.mock.js @@ -784,8 +784,8 @@ const tasksDummyData = { frame_filter: '', }, { - url: 'http://localhost:7000/api/tasks/4', - id: 4, + url: 'http://localhost:7000/api/tasks/40', + id: 40, name: 'test', project_id: null, mode: 'annotation', From ebf19fe674d87a981f7b4e02270669b437c2db53 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 26 Aug 2022 14:33:22 +0300 Subject: [PATCH 06/11] Removed extra lines --- cvat-core/tests/api/annotations.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cvat-core/tests/api/annotations.js b/cvat-core/tests/api/annotations.js index 357054b4347c..1d022a57584f 100644 --- a/cvat-core/tests/api/annotations.js +++ b/cvat-core/tests/api/annotations.js @@ -435,10 +435,6 @@ describe('Feature: put annotations', () => { expect(element.shapeType).toBe(window.cvat.enums.ShapeType.POINTS); } }); - - test('put a wrong skeleton to a job', async() => { - - }); }); describe('Feature: check unsaved changes', () => { From a4b428965e8c71dde51b48fd9426ab6c157f0d82 Mon Sep 17 00:00:00 2001 From: Boris Date: Thu, 1 Sep 2022 09:18:54 +0300 Subject: [PATCH 07/11] Added test to check object state logic for complex objects --- cvat-core/tests/api/object-state.js | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/cvat-core/tests/api/object-state.js b/cvat-core/tests/api/object-state.js index 977aaacebde4..bb86279e8555 100644 --- a/cvat-core/tests/api/object-state.js +++ b/cvat-core/tests/api/object-state.js @@ -282,3 +282,40 @@ describe('Feature: delete object', () => { expect(annotationsAfter).toHaveLength(length - 1); }); }); + +describe('Feature: skeletons', () => { + test('lock, hide, occluded, outside for skeletons', async () => { + const job = (await window.cvat.jobs.get({ jobID: 40 }))[0]; + let [skeleton] = await job.annotations.get(0, false, JSON.parse('[{"and":[{"==":[{"var":"shape"},"skeleton"]}]}]')); + expect(skeleton.shapeType).toBe('skeleton'); + skeleton.lock = true; + skeleton.outside = true; + skeleton.occluded = true; + skeleton.hidden = true; + skeleton = await skeleton.save(); + expect(skeleton.lock).toBe(true); + expect(skeleton.outside).toBe(true); + expect(skeleton.occluded).toBe(true); + expect(skeleton.hidden).toBe(true); + expect(skeleton.elements).toBeInstanceOf(Array); + expect(skeleton.elements.length).toBe(skeleton.label.structure.sublabels.length); + for (const element of skeleton.elements) { + expect(element.lock).toBe(true); + expect(element.outside).toBe(true); + expect(element.occluded).toBe(true); + expect(element.hidden).toBe(true); + } + + skeleton.elements[0].lock = false; + skeleton.elements[0].outside = false; + skeleton.elements[0].occluded = false; + skeleton.elements[0].hidden = false; + skeleton.elements[0].save(); + + [skeleton] = await job.annotations.get(0, false, JSON.parse('[{"and":[{"==":[{"var":"shape"},"skeleton"]}]}]')); + expect(skeleton.lock).toBe(false); + expect(skeleton.outside).toBe(false); + expect(skeleton.occluded).toBe(false); + expect(skeleton.hidden).toBe(false); + }); +}); \ No newline at end of file From 417559a4e29cfea9350866b545b0d9bfe5c87aba Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 2 Sep 2022 11:48:53 +0300 Subject: [PATCH 08/11] Updated eslint config file --- cvat-core/.eslintrc.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/cvat-core/.eslintrc.js b/cvat-core/.eslintrc.js index 8d802f410bcc..c56e714e98d7 100644 --- a/cvat-core/.eslintrc.js +++ b/cvat-core/.eslintrc.js @@ -19,7 +19,6 @@ module.exports = { project: './tsconfig.json', tsconfigRootDir: __dirname, }, - ignorePatterns: ['tests/**/*.js'], plugins: ['jest'], rules: { 'jest/no-disabled-tests': 'warn', @@ -27,5 +26,4 @@ module.exports = { 'jest/no-identical-title': 'error', 'jest/prefer-to-have-length': 'warn', }, - ignorePatterns: ['tests/**/*.js'] }; From 85794758322b4fece27ca1832c79cdff9d5bae45 Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 2 Sep 2022 11:55:41 +0300 Subject: [PATCH 09/11] Fixed config --- cvat-core/.eslintrc.js | 11 +---------- cvat-core/tests/api/cloud-storages.js | 2 ++ lint-staged.config.js | 12 ++++++------ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/cvat-core/.eslintrc.js b/cvat-core/.eslintrc.js index c56e714e98d7..a28a5cc1b80a 100644 --- a/cvat-core/.eslintrc.js +++ b/cvat-core/.eslintrc.js @@ -3,9 +3,6 @@ // SPDX-License-Identifier: MIT module.exports = { - env: { - 'jest/globals': true, - }, ignorePatterns: [ '.eslintrc.js', 'webpack.config.js', @@ -14,16 +11,10 @@ module.exports = { 'src/3rdparty/**', 'node_modules/**', 'dist/**', + 'tests/**/*.js', ], parserOptions: { project: './tsconfig.json', tsconfigRootDir: __dirname, }, - plugins: ['jest'], - rules: { - 'jest/no-disabled-tests': 'warn', - 'jest/no-focused-tests': 'error', - 'jest/no-identical-title': 'error', - 'jest/prefer-to-have-length': 'warn', - }, }; diff --git a/cvat-core/tests/api/cloud-storages.js b/cvat-core/tests/api/cloud-storages.js index 66ccf11abdcb..b8f456d9ce03 100644 --- a/cvat-core/tests/api/cloud-storages.js +++ b/cvat-core/tests/api/cloud-storages.js @@ -14,6 +14,8 @@ window.cvat = require('../../src/api'); const { CloudStorage } = require('../../src/cloud-storage'); const { cloudStoragesDummyData } = require('../mocks/dummy-data.mock'); + + describe('Feature: get cloud storages', () => { test('get all cloud storages', async () => { const result = await window.cvat.cloudStorages.get(); diff --git a/lint-staged.config.js b/lint-staged.config.js index de7bc0c4c53d..41cfa50dafca 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -16,12 +16,12 @@ module.exports = (stagedFiles) => { const eslintFiles = micromatch(stagedFiles, eslintExtensions); const scssFiles = micromatch(stagedFiles, scssExtensions); - const tests = containsInPath('/tests/', eslintFiles); - const cvatData = containsInPath('/cvat-data/', eslintFiles); - const cvatCore = containsInPath('/cvat-core/', eslintFiles); - const cvatCanvas = containsInPath('/cvat-canvas/', eslintFiles); - const cvatCanvas3d = containsInPath('/cvat-canvas3d/', eslintFiles); - const cvatUI = containsInPath('/cvat-ui/', eslintFiles); + const tests = containsInPath('/tests/cypress', eslintFiles); + const cvatData = containsInPath('/cvat-data/src', eslintFiles); + const cvatCore = containsInPath('/cvat-core/src', eslintFiles); + const cvatCanvas = containsInPath('/cvat-canvas/src', eslintFiles); + const cvatCanvas3d = containsInPath('/cvat-canvas3d/src', eslintFiles); + const cvatUI = containsInPath('/cvat-ui/src', eslintFiles); const mapping = {}; const commands = []; From 4c10c6968e77e9df5866b0d514ce40b164c1d1f5 Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 2 Sep 2022 11:56:39 +0300 Subject: [PATCH 10/11] Removed extra space --- cvat-core/tests/api/cloud-storages.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/cvat-core/tests/api/cloud-storages.js b/cvat-core/tests/api/cloud-storages.js index b8f456d9ce03..66ccf11abdcb 100644 --- a/cvat-core/tests/api/cloud-storages.js +++ b/cvat-core/tests/api/cloud-storages.js @@ -14,8 +14,6 @@ window.cvat = require('../../src/api'); const { CloudStorage } = require('../../src/cloud-storage'); const { cloudStoragesDummyData } = require('../mocks/dummy-data.mock'); - - describe('Feature: get cloud storages', () => { test('get all cloud storages', async () => { const result = await window.cvat.cloudStorages.get(); From 3ff2586d9dc7459417900a047140056de6bfe897 Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 2 Sep 2022 11:58:23 +0300 Subject: [PATCH 11/11] Fixed lint-staged config --- lint-staged.config.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lint-staged.config.js b/lint-staged.config.js index 41cfa50dafca..e2e443718d1c 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -17,11 +17,11 @@ module.exports = (stagedFiles) => { const scssFiles = micromatch(stagedFiles, scssExtensions); const tests = containsInPath('/tests/cypress', eslintFiles); - const cvatData = containsInPath('/cvat-data/src', eslintFiles); + const cvatData = containsInPath('/cvat-data/', eslintFiles); const cvatCore = containsInPath('/cvat-core/src', eslintFiles); - const cvatCanvas = containsInPath('/cvat-canvas/src', eslintFiles); - const cvatCanvas3d = containsInPath('/cvat-canvas3d/src', eslintFiles); - const cvatUI = containsInPath('/cvat-ui/src', eslintFiles); + const cvatCanvas = containsInPath('/cvat-canvas/', eslintFiles); + const cvatCanvas3d = containsInPath('/cvat-canvas3d/', eslintFiles); + const cvatUI = containsInPath('/cvat-ui/', eslintFiles); const mapping = {}; const commands = [];