Skip to content

Commit

Permalink
Merged develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Sekachev committed Mar 18, 2021
2 parents e5f4275 + dacdf37 commit a15ff60
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed export error when invalid polygons are present in overlapping frames (<https://github.com/openvinotoolkit/cvat/pull/2852>)
- Fixed image quality option for tasks created from images (<https://github.com/openvinotoolkit/cvat/pull/2963>)
- Incorrect text on the warning when specifying an incorrect link to the issue tracker (<https://github.com/openvinotoolkit/cvat/pull/2971>)
- Updating label attributes when label contains number attributes (<https://github.com/openvinotoolkit/cvat/pull/2969>)

### Security

Expand Down
30 changes: 17 additions & 13 deletions cvat-ui/src/components/labels-editor/label-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,20 @@ export default class LabelForm extends React.Component<Props> {
const locked = attr ? attr.id >= 0 : false;
const existedValues = attr ? attr.values : [];

const validator = (_: any, values: string[], callback: any): void => {
const validator = (_: any, values: string[]): Promise<void> => {
if (locked && existedValues) {
if (!equalArrayHead(existedValues, values)) {
callback('You can only append new values');
return Promise.reject(new Error('You can only append new values'));
}
}

for (const value of values) {
if (!patterns.validateAttributeValue.pattern.test(value)) {
callback(`Invalid attribute value: "${value}"`);
return Promise.reject(new Error(`Invalid attribute value: "${value}"`));
}
}

callback();
return Promise.resolve();
};

return (
Expand Down Expand Up @@ -223,35 +223,35 @@ export default class LabelForm extends React.Component<Props> {
private renderNumberRangeInput(fieldInstance: any, attr: Attribute | null): JSX.Element {
const { key } = fieldInstance;
const locked = attr ? attr.id >= 0 : false;
const value = attr ? attr.values.join(';') : '';
const value = attr ? attr.values : '';

const validator = (_: any, strNumbers: string, callback: any): void => {
const validator = (_: any, strNumbers: string): Promise<void> => {
const numbers = strNumbers.split(';').map((number): number => Number.parseFloat(number));
if (numbers.length !== 3) {
callback('Three numbers are expected');
return Promise.reject(new Error('Three numbers are expected'));
}

for (const number of numbers) {
if (Number.isNaN(number)) {
callback(`"${number}" is not a number`);
return Promise.reject(new Error(`"${number}" is not a number`));
}
}

const [min, max, step] = numbers;

if (min >= max) {
callback('Minimum must be less than maximum');
return Promise.reject(new Error('Minimum must be less than maximum'));
}

if (max - min < step) {
callback('Step must be less than minmax difference');
return Promise.reject(new Error('Step must be less than minmax difference'));
}

if (step <= 0) {
callback('Step must be a positive number');
return Promise.reject(new Error('Step must be a positive number'));
}

callback();
return Promise.resolve();
};

return (
Expand Down Expand Up @@ -339,7 +339,7 @@ export default class LabelForm extends React.Component<Props> {
{() => (
<Row
justify='space-between'
align='middle'
align='top'
cvat-attribute-id={fieldValue.id}
className='cvat-attribute-inputs-wrapper'
>
Expand Down Expand Up @@ -507,6 +507,10 @@ export default class LabelForm extends React.Component<Props> {
label.attributes.map(
(attribute: Attribute): Store => ({
...attribute,
values:
attribute.input_type.toUpperCase() === 'NUMBER' ?
attribute.values.join(';') :
attribute.values,
type: attribute.input_type.toUpperCase(),
}),
) :
Expand Down
7 changes: 5 additions & 2 deletions cvat-ui/src/components/task-page/bug-tracker-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -34,6 +34,7 @@ export default function BugTrackerEditorComponent(props: Props): JSX.Element {
onOk: () => {
shown = false;
},
className: 'cvat-modal-issue-tracker-update-task-fail',
});
shown = true;
}
Expand All @@ -52,7 +53,9 @@ export default function BugTrackerEditorComponent(props: Props): JSX.Element {
Issue Tracker
</Text>
<br />
<Text editable={{ onChange: onChangeValue }}>{bugTracker}</Text>
<Text editable={{ onChange: onChangeValue }} className='cvat-issue-tracker-value'>
{bugTracker}
</Text>
<Button
type='ghost'
size='small'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

/// <reference types="cypress" />

context('Create a task with set an issue tracker.', () => {
const caseId = '61';
const labelName = `Case ${caseId}`;
const taskName = labelName;
const imagesCount = 1;
const imageFileName = `image_${labelName.replace(' ', '_').toLowerCase()}`;
const width = 800;
const height = 800;
const posX = 10;
const posY = 10;
const color = 'gray';
const archiveName = `${imageFileName}.zip`;
const archivePath = `cypress/fixtures/${archiveName}`;
const imagesFolder = `cypress/fixtures/${imageFileName}`;
const directoryToArchive = imagesFolder;
const dummyBugTrackerUrl = 'http://somebugtracker.info/task12';
const incorrectBugTrackerUrl = 'somebugtracker.info/task12';

before(() => {
cy.visit('auth/login');
cy.login();
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
cy.createZipArchive(directoryToArchive, archivePath);
cy.get('#cvat-create-task-button').click();
});

after(() => {
cy.goToTaskList();
cy.deleteTask(taskName);
});

describe(`Testing "${labelName}"`, () => {
it('Creating a task with incorrect issue tracker URL. The error notification is shown.', () => {
cy.get('[id="name"]').type(taskName);
cy.addNewLabel(labelName);
cy.get('input[type="file"]').attachFile(archiveName, { subjectType: 'drag-n-drop' });
cy.contains('Advanced configuration').click();
cy.get('#bugTracker').type(incorrectBugTrackerUrl);
cy.contains('URL is not a valid URL').should('exist');
cy.get('.cvat-create-task-submit-section').click();
cy.get('.cvat-notification-create-task-fail').should('exist').and('be.visible');
cy.closeNotification('.cvat-notification-create-task-fail');
});

it('Set correct issue tracker URL. The task created.', () => {
cy.get('#bugTracker').clear().type(dummyBugTrackerUrl);
cy.contains('URL is not a valid URL').should('not.exist');
cy.get('.cvat-create-task-submit-section').click();
cy.get('.cvat-notification-create-task-fail').should('not.exist');
cy.get('.cvat-notification-create-task-success').should('exist').and('be.visible');
});

it('Open the task. Change issue tracker URL to incorrect. The error notification is shown.', () => {
cy.goToTaskList();
cy.openTask(taskName);
cy.get('.cvat-issue-tracker-value').should('have.text', dummyBugTrackerUrl);
cy.contains('button', 'Open the issue').should('exist').and('be.visible');
cy.get('.cvat-issue-tracker').find('[aria-label="Edit"]').click();
cy.get('.cvat-issue-tracker-value').find('textarea').clear().type(`${incorrectBugTrackerUrl}{Enter}`);
cy.get('.cvat-modal-issue-tracker-update-task-fail')
.should('exist')
.and('be.visible')
.find('button')
.click(); // Close modal window
});

it('Remove issue trasker URL.', () => {
cy.get('.cvat-issue-tracker-value').should('have.text', dummyBugTrackerUrl);
cy.get('.cvat-issue-tracker').find('[aria-label="Edit"]').click();
cy.get('.cvat-issue-tracker-value').find('textarea').clear().type('{Enter}');
cy.get('.cvat-issue-tracker-value').should('not.exist'); // Not specified
cy.contains('button', 'Open the issue').should('not.exist');
});
});
});

0 comments on commit a15ff60

Please sign in to comment.