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

Cypress test for issue 1919 #2013

Merged
merged 3 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions tests/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"baseUrl": "http://localhost:8080",
"viewportWidth": 1300,
"viewportHeight": 960,
"defaultCommandTimeout": 10000,
"testFiles": [
"auth_page.js",
"issue_*.js"
Expand Down
64 changes: 64 additions & 0 deletions tests/cypress/integration/issue_1919_check_text_attr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/

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

context('Check label attribute changes', () => {

const issueId='1919'
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 image=`image_${issueId}.png`
const newLabelAttrValue = 'New attribute value'
const width='800'
const height='800'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we use strings instead of numbers here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jimp successfully handles this format as well. But it is better to use a numeric format. Thanks.

const posX=10
const posY=10
const color='gray'

before(() => {
cy.visit('auth/login')
cy.login()
cy.get('[type="submit"]').click()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't cy.get('[type="submit"]').click() be a part of cy.login()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's better that way. Moved.

cy.imageGenerator('cypress/fixtures', image, width, height, color, posX, posY, labelName)
cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, image)
})

describe(`Open task "${taskName}"`, () => {
it('The annotation task present in the list', () => {
cy.contains('strong', taskName)
.parent()
.parent()
.parent()
.contains('a', 'Open').click()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get this button in a simpler way? cy.get('[href="/tasks/${taskID}"]').click()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${taskID} unknown in advance. I tried using a slightly different solution.

})
it('Open a job', () => {
cy.contains('a', 'Job #').click()
cy.url().should('include', '/jobs')
})
it('Create a shape', () => {
cy.createShape(309, 431, 616, 671)
})
it('Open object menu on the created shape', () => {
cy.get('#cvat_canvas_shape_1').trigger('mousemove').rightclick()
})
it('Open object menu details', () => {
cy.get('.cvat-canvas-context-menu > [style="display: flex; margin-bottom: 1px;"] > #cvat-objects-sidebar-state-item-1 > .ant-row > .ant-collapse > .ant-collapse-item > .ant-collapse-header > span')
Copy link
Member

@bsekachev bsekachev Aug 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we escape such long and complex selectors? They are extremely unreliable. Any minor UI change here and these tests will be broken. If you need more specific css selectors, I believe we can add them. In this case we might use for example something like this: #cvat-objects-sidebar-state-item-1 .ant-collapse-header > span

The same comment to selectors below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to shorten the selector.

.should('contain', 'Details')
.click()
})
it('Clear field of text attribute and write new value', () => {
cy.get('.cvat-canvas-context-menu > [style="display: flex; margin-bottom: 1px;"] > #cvat-objects-sidebar-state-item-1 > .ant-row > .ant-collapse > .ant-collapse-item > .ant-collapse-content > .ant-collapse-content-box > .ant-row-flex > .ant-col-16 > .ant-input')
.clear().type(newLabelAttrValue)
})
it('Check what value of right panel is changed too', () => {
cy.get('.cvat-objects-sidebar-states-list > [style="display: flex; margin-bottom: 1px;"] > #cvat-objects-sidebar-state-item-1 > .ant-row > .ant-collapse > .ant-collapse-item > .ant-collapse-content > .ant-collapse-content-box > .ant-row-flex > .ant-col-16 > .ant-input')
.should('have.value', newLabelAttrValue)
})
})
})