Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for basic Management tab on Quality control page #8447

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ function AllocationTable(props: Readonly<Props>): JSX.Element {
render: (active: boolean, record: RowData): JSX.Element => (
active ? (
<DeleteOutlined
className='cvat-allocation-frame-delete'
onClick={() => { onDeleteFrames([record.frame]); }}
/>
) : (
<Icon
className='cvat-allocation-frame-restore'
onClick={() => { onRestoreFrames([record.frame]); }}
component={RestoreIcon}
/>
Expand All @@ -130,7 +132,7 @@ function AllocationTable(props: Readonly<Props>): JSX.Element {
{
selection.selectedRowKeys.length !== 0 ? (
<>
<Col>
<Col className='cvat-allocation-selection-frame-delete'>
<DeleteOutlined
onClick={() => {
const framesToUpdate = selection.selectedRows
Expand All @@ -141,7 +143,7 @@ function AllocationTable(props: Readonly<Props>): JSX.Element {
}}
/>
</Col>
<Col>
<Col className='cvat-allocation-selection-frame-restore'>
<Icon
onClick={() => {
const framesToUpdate = selection.selectedRows
Expand All @@ -163,7 +165,7 @@ function AllocationTable(props: Readonly<Props>): JSX.Element {
if (!rowData.active) {
return 'cvat-allocation-frame-row cvat-allocation-frame-row-excluded';
}
return 'cvat-allocation-frame';
return 'cvat-allocation-frame-row';
}}
columns={columns}
dataSource={data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export default function SummaryComponent(props: Readonly<Props>): JSX.Element {
<Row>
<Col span={10} className='cvat-allocation-summary'>
<Row>
<Col span={12}>
<Col span={12} className='cvat-allocation-summary-excluded'>
<Text>
Excluded count:
{' '}
<Text strong>{excludedCount}</Text>
</Text>
</Col>
<Col span={12}>
<Col span={12} className='cvat-allocation-summary-total'>
<Text>
Total count:
{' '}
Expand All @@ -36,7 +36,7 @@ export default function SummaryComponent(props: Readonly<Props>): JSX.Element {
</Col>
</Row>
<Row>
<Col span={12}>
<Col span={12} className='cvat-allocation-summary-active'>
<Text>
Active count:
{' '}
Expand Down
131 changes: 129 additions & 2 deletions tests/cypress/e2e/features/ground_truth_jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ context('Ground truth jobs', () => {
.should('be.visible');
}

function openManagementTab() {
cy.clickInTaskMenu('Quality control', true);
cy.get('.cvat-task-control-tabs')
.within(() => {
cy.contains('Management').click();
});
}

before(() => {
cy.visit('auth/login');
cy.login();
Expand Down Expand Up @@ -187,6 +195,121 @@ context('Ground truth jobs', () => {
});
});

describe('Testing ground truth management basics', () => {
const serverFiles = ['images/image_1.jpg', 'images/image_2.jpg', 'images/image_3.jpg'];

before(() => {
cy.headlessCreateTask({
labels: [{ name: labelName, attributes: [], type: 'any' }],
name: taskName,
project_id: null,
source_storage: { location: 'local' },
target_storage: { location: 'local' },
}, {
server_files: serverFiles,
image_quality: 70,
use_zip_chunks: true,
use_cache: true,
sorting_method: 'lexicographical',
}).then((taskResponse) => {
taskID = taskResponse.taskID;
[jobID] = taskResponse.jobIDs;
}).then(() => (
cy.headlessCreateJob({
task_id: taskID,
frame_count: 3,
type: 'ground_truth',
frame_selection_method: 'random_uniform',
})
)).then((jobResponse) => {
groundTruthJobID = jobResponse.jobID;
}).then(() => {
cy.visit(`/tasks/${taskID}`);
cy.get('.cvat-task-details').should('exist').and('be.visible');
openManagementTab();
});
});

after(() => {
cy.headlessDeleteTask(taskID);
});

it('Check management page contents.', () => {
cy.get('.cvat-annotations-quality-allocation-table-summary').should('exist');
cy.contains('.cvat-allocation-summary-excluded', '0').should('exist');
cy.contains('.cvat-allocation-summary-total', '3').should('exist');
cy.contains('.cvat-allocation-summary-active', '3').should('exist');

cy.get('.cvat-frame-allocation-table').should('exist');
cy.get('.cvat-allocation-frame-row').should('have.length', 3);
cy.get('.cvat-allocation-frame-row').each(($el, index) => {
cy.wrap($el).within(() => {
cy.contains(`#${index}`).should('exist');
cy.contains(`images/image_${index + 1}.jpg`).should('exist');
});
});
});

it('Check link to frame.', () => {
cy.get('.cvat-allocation-frame-row').last().within(() => {
cy.get('.cvat-open-frame-button').first().click();
});
cy.get('.cvat-spinner').should('not.exist');
cy.url().should('contain', `/tasks/${taskID}/jobs/${groundTruthJobID}`);
cy.checkFrameNum(2);

cy.interactMenu('Open the task');
openManagementTab();
});

it('Disable single frame, enable it back.', () => {
cy.get('.cvat-allocation-frame-row').last().within(() => {
cy.get('.cvat-allocation-frame-delete').click();
});
cy.get('.cvat-spinner').should('not.exist');

cy.get('.cvat-allocation-frame-row-excluded').should('exist');
cy.contains('.cvat-allocation-summary-excluded', '1').should('exist');
cy.contains('.cvat-allocation-summary-active', '2').should('exist');

cy.get('.cvat-allocation-frame-row-excluded').within(() => {
cy.get('.cvat-allocation-frame-restore').click();
});
cy.get('.cvat-spinner').should('not.exist');
cy.get('.cvat-allocation-frame-row-excluded').should('not.exist');
cy.contains('.cvat-allocation-summary-excluded', '0').should('exist');
cy.contains('.cvat-allocation-summary-active', '3').should('exist');
});

it('Select several frames, use group operations.', () => {
function selectFrames() {
cy.get('.cvat-allocation-frame-row').each(($el, index) => {
if (index !== 0) {
cy.wrap($el).within(() => {
cy.get('.ant-table-selection-column input[type="checkbox"]').should('not.be.checked').check();
});
}
});
}

selectFrames();
cy.get('.cvat-allocation-selection-frame-delete').click();
cy.get('.cvat-spinner').should('not.exist');

cy.get('.cvat-allocation-frame-row-excluded').should('have.length', 2);
cy.contains('.cvat-allocation-summary-excluded', '2').should('exist');
cy.contains('.cvat-allocation-summary-active', '1').should('exist');

selectFrames();
cy.get('.cvat-allocation-selection-frame-restore').click();
cy.get('.cvat-spinner').should('not.exist');

cy.get('.cvat-allocation-frame-row-excluded').should('not.exist');
cy.contains('.cvat-allocation-summary-excluded', '0').should('exist');
cy.contains('.cvat-allocation-summary-active', '3').should('exist');
});
});

describe('Regression tests', () => {
const imagesCount = 20;
const imageFileName = 'ground_truth_2';
Expand All @@ -205,8 +328,12 @@ context('Ground truth jobs', () => {
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
cy.createZipArchive(directoryToArchive, archivePath);
cy.createAnnotationTask(
taskName, labelName, attrName,
textDefaultValue, archiveName, false,
taskName,
labelName,
attrName,
textDefaultValue,
archiveName,
false,
klakhov marked this conversation as resolved.
Show resolved Hide resolved
{ multiJobs: true, segmentSize: 1 },
);
cy.openTask(taskName);
Expand Down
19 changes: 16 additions & 3 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ Cypress.Commands.add(
attrName = 'Some attr name',
textDefaultValue = 'Some default value for type Text',
image = 'image.png',
multiAttrParams,
advancedConfigurationParams,
multiAttrParams = null,
advancedConfigurationParams = null,
forProject = false,
attachToProject = false,
projectName,
projectName = '',
expectedResult = 'success',
projectSubsetFieldValue = 'Test',
) => {
Expand Down Expand Up @@ -365,6 +365,19 @@ Cypress.Commands.add('headlessLogout', () => {
cy.clearAllLocalStorage();
});

Cypress.Commands.add('headlessCreateJob', (jobSpec) => {
cy.window().then(async ($win) => {
const data = {
...jobSpec,
};

const job = new $win.cvat.classes.Job(data);

const result = await job.save(data);
klakhov marked this conversation as resolved.
Show resolved Hide resolved
return cy.wrap({ jobID: result.id });
});
klakhov marked this conversation as resolved.
Show resolved Hide resolved
});

Cypress.Commands.add('openTask', (taskName, projectSubsetFieldValue) => {
cy.contains('strong', new RegExp(`^${taskName}$`))
.parents('.cvat-tasks-list-item')
Expand Down
Loading