Skip to content

Commit

Permalink
chore(variable_test): added cypress test for variable searching based…
Browse files Browse the repository at this point in the history
… on labels & variable name (#18425)
  • Loading branch information
asalem1 authored Jun 10, 2020
1 parent d7192ed commit ac559d8
Showing 1 changed file with 67 additions and 3 deletions.
70 changes: 67 additions & 3 deletions ui/cypress/e2e/variables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Variables', () => {
})
})

it('can CRUD a CSV, map, and query variable', () => {
it('can CRUD a CSV, map, and query variable and search for variables based on names', () => {
// Navigate away from and back to variables index
cy.getByTestID('nav-item-dashboards').click()
cy.getByTestID('nav-item-settings').click()
Expand Down Expand Up @@ -103,6 +103,13 @@ describe('Variables', () => {

cy.getByTestID('resource-card variable').should('have.length', 2)

// Search variable by name
cy.getByTestID('search-widget').type(variableName)

cy.getByTestID('resource-card variable')
.should('have.length', 1)
.contains(variableName)

// Delete a variable
cy.getByTestID('context-delete-menu')
.first()
Expand All @@ -113,6 +120,12 @@ describe('Variables', () => {

cy.getByTestID('notification-success--dismiss').click()

cy.getByTestID('search-widget').clear()

cy.getByTestID('resource-card variable')
.should('have.length', 1)
.contains('Little Variable')

// Rename the variable
cy.getByTestID('context-menu')
.first()
Expand Down Expand Up @@ -154,18 +167,69 @@ describe('Variables', () => {
cy.getByTestID('import-overlay--textarea').contains('this is invalid')
})

it('can add a label', () => {
it('can create and delete a label and filter a variable by label name & sort by variable name', () => {
cy.getByTestID('resource-card variable').within(() => {
cy.getByTestID('inline-labels--add').click()
})

const labelName = 'l1'
const labelName = 'label'
cy.getByTestID('inline-labels--popover--contents').type(labelName)
cy.getByTestID('inline-labels--create-new').click()
cy.getByTestID('create-label-form--submit').click()

cy.getByTestID('add-resource-dropdown--button').click()

cy.getByTestID('add-resource-dropdown--new').should('have.length', 1)

cy.getByTestID('add-resource-dropdown--new').click()

cy.getByTestID('variable-type-dropdown--button').click()
cy.getByTestID('variable-type-dropdown-constant').click()

// Create a CSV variable
const variableName = 'a Second Variable'
const defaultVar = 'Little Variable'
cy.getByInputName('name').type(variableName)

cy.get('textarea').type('1,2,3,4,5,6')

cy.getByTestID('csv-value-select-dropdown')
.click()
.contains('6')
.click()

cy.get('form')
.contains('Create')
.click()

cy.getByTestID('search-widget').type(labelName)

cy.getByTestID('resource-card variable')
.should('have.length', 1)
.contains(defaultVar)

// Delete the label
cy.getByTestID(`label--pill--delete ${labelName}`).click({force: true})
cy.getByTestID('resource-card variable').should('have.length', 0)
cy.getByTestID('search-widget').clear()
cy.getByTestID('inline-labels--empty').should('exist')

cy.getByTestID('resource-card variable')
.should('have.length', 2)
.first()
.contains(variableName)
cy.getByTestID('resource-card variable')
.last()
.contains(defaultVar)

cy.getByTestID('resource-sorter--button').click()
cy.getByTestID('resource-sorter--name-desc').click()

cy.getByTestID('resource-card variable')
.first()
.contains(defaultVar)
cy.getByTestID('resource-card variable')
.last()
.contains(variableName)
})
})

0 comments on commit ac559d8

Please sign in to comment.