Skip to content

Commit

Permalink
Cypress test for issue 1750.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Kruchinin committed Aug 13, 2020
1 parent 8f323cf commit d14b01a
Show file tree
Hide file tree
Showing 7 changed files with 357 additions and 38 deletions.
82 changes: 82 additions & 0 deletions tests/cypress/integration/issue_1750_err_aam_switch_frames.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/

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

context('An error occurs in AAM when switching to 2 frames, if the frames have objects created in shape mode', () => {

const issueId = '1750'
const labelName = `Issue ${issueId}`
const taskName = `New annotation task for ${labelName}`
const attrName = `Attr for ${labelName}`
const textDefaultValue = 'Some default value for type Text'
const images = [`image_${issueId}_1.png`,
`image_${issueId}_2.png`,
`image_${issueId}_3.png`]
const width = 800
const height = 800
const posX = 10
const posY = 10
const color = 'gray'
const archiveName = `images_issue_${issueId}.zip`
const archivePath = `cypress/fixtures/${archiveName}`
const imagesFolder = `cypress/fixtures/image_issue_${issueId}`
const lastElement = images[images.length - 1]

before(() => {
cy.visit('auth/login')
cy.login()
for (let img of images) {
cy.imageGenerator(imagesFolder, img, width, height, color, posX, posY, labelName)
}
cy.wait(2000)
cy.createZipArchive(imagesFolder, archivePath)
cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, archiveName)
cy.openTaskJob(taskName)
})

describe(`Testing issue "${issueId}"`, () => {
it('Create multiple objects', () => {
cy.createShape(309, 431, 409, 531)
cy.createShape(200, 300, 300, 400)
})
it('Go to AAM', () => {
cy.get('.cvat-annotation-header-right-group')
.find('.ant-select-selection-selected-value')
.click()
cy.get('.ant-select-dropdown-menu-item')
.contains('Attribute annotation')
.click()
.should('contain.text', 'Attribute annotation')
})
it('Go to next frame', () => {
cy.get('.cvat-player-buttons')
.find(':nth-child(5)')
.click()
cy.get('.ant-input-number-input')
.should('have.value', '1')
})
it('Go to previous frame', () => {
cy.get('.cvat-player-buttons')
.find(':nth-child(3)')
.click()
cy.get('.ant-input-number-input')
.should('have.value', '0')
})
it('Go to next object', () => {
cy.get('.ant-layout-sider-children > :nth-child(3)')
.should('contain', `${labelName} 1 [1/2]`)
.find('i[aria-label="icon: right"]')
.click({force: true})
})
it('Page with the error is missing', () => {
cy.contains('Oops, something went wrong')
.should('not.exist')
cy.get('.ant-layout-sider-children > :nth-child(3)')
.should('contain', `${labelName} 2 [2/2]`)
})
})
})
30 changes: 30 additions & 0 deletions tests/cypress/plugins/createZipArchive/addPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/

exports.createZipArchive = createZipArchive

const archiver = require('archiver')
const fs = require('fs-extra')

function createZipArchive(args) {
const directoryToArchive = args.directoryToArchive
const output = fs.createWriteStream(args.arhivePath)
const archive = archiver('zip', {
gzip: true,
zlib: { level: 9 }
})

archive.on('error', function(err) {
throw err
})

archive.pipe(output)

archive.directory(`${directoryToArchive}/`, false)
archive.finalize()

return fs.pathExists(archive)
}
12 changes: 12 additions & 0 deletions tests/cypress/plugins/createZipArchive/createZipArchiveCommand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/

Cypress.Commands.add('createZipArchive', function (directoryToArchive, arhivePath) {
return cy.task('createZipArchive', {
directoryToArchive: directoryToArchive,
arhivePath: arhivePath
})
})
2 changes: 2 additions & 0 deletions tests/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
/// <reference types="cypress" />

const {imageGenerator} = require('../plugins/imageGenerator/addPlugin')
const {createZipArchive} = require('../plugins/createZipArchive/addPlugin')

module.exports = (on) => {
on('task', {imageGenerator})
on('task', {createZipArchive})
}
1 change: 1 addition & 0 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

require('cypress-file-upload')
require('../plugins/imageGenerator/imageGeneratorCommand')
require('../plugins/createZipArchive/createZipArchiveCommand')

Cypress.Commands.add('login', (username='admin', password='12qwaszx') => {
cy.get('[placeholder="Username"]').type(username)
Expand Down
Loading

0 comments on commit d14b01a

Please sign in to comment.