-
Notifications
You must be signed in to change notification settings - Fork 99
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 case for scatter chart #930
Merged
mengweieric
merged 1 commit into
opensearch-project:main
from
nidhisinghai:feature/cypress-scatter-chart
Aug 22, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
228 changes: 228 additions & 0 deletions
228
dashboards-observability/.cypress/integration/VisualizationCharts/10_scatter_chart.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/// <reference types="cypress" /> | ||
import { | ||
delay, | ||
TEST_QUERIES, | ||
querySearch, | ||
landOnEventVisualizations | ||
} from '../../utils/event_constants'; | ||
|
||
const numberOfWindow = 4; | ||
const legendSize = 20; | ||
const pointSize = 30; | ||
const pointSizeUpdated = 35; | ||
const lineWidth = 7; | ||
const lineWidthUpdated = 9; | ||
const fillOpacity = 10; | ||
const fillOpacityUpdated = 50; | ||
const rotateLevel = 45; | ||
const thresholdValue = 50; | ||
|
||
const renderScatterChart = () => { | ||
landOnEventVisualizations(); | ||
querySearch(TEST_QUERIES[6].query, TEST_QUERIES[6].dateRangeDOM); | ||
cy.get('[data-test-subj="configPane__vizTypeSelector"] [data-test-subj="comboBoxInput"]').type('scatter').type('{enter}'); | ||
}; | ||
|
||
describe('Render scatter chart and verify default behaviour ', () => { | ||
beforeEach(() => { | ||
renderScatterChart(); | ||
}); | ||
|
||
it('Render scatter chart and verify by default the data gets render', () => { | ||
cy.get('.xy').should('exist'); | ||
}); | ||
|
||
it('Render scatter chart and verify you see data configuration panel and chart panel', () => { | ||
cy.get('.euiPanel.euiPanel--paddingSmall').should('have.length', numberOfWindow); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: can we add data-test-subj? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This element don't have data-test-subj defined, only class can be used here |
||
cy.get('.euiTitle.euiTitle--xxsmall').contains('Data Configurations').should('exist'); | ||
cy.get('.euiTitle.euiTitle--xxsmall').contains('Dimensions').should('exist'); | ||
cy.get('.euiTitle.euiTitle--xxsmall').contains('Metrics').should('exist'); | ||
cy.get('.euiIEFlexWrapFix').contains('Panel options').click(); | ||
cy.get('.euiIEFlexWrapFix').contains('Legend').click(); | ||
cy.get('.euiIEFlexWrapFix').contains('Chart styles').click(); | ||
cy.get('.euiIEFlexWrapFix').contains('Color theme').click(); | ||
cy.get('.euiIEFlexWrapFix').contains('Thresholds').click(); | ||
cy.get('[aria-label="Press to toggle this panel"]').eq(1).click(); | ||
cy.get('[aria-label="Press to toggle this panel"]').eq(2).click(); | ||
}); | ||
|
||
it('Render scatter chart and verify the data configuration panel and chart panel are collapsable', () => { | ||
cy.get('.euiPanel.euiPanel--paddingSmall').should('have.length', numberOfWindow); | ||
cy.get('[aria-label="Press to toggle this panel"]').eq(1).click(); | ||
cy.get('[aria-label="Press to toggle this panel"]').eq(2).click(); | ||
}); | ||
}); | ||
|
||
describe('Render scatter chart for data configuration panel', () => { | ||
beforeEach(() => { | ||
renderScatterChart(); | ||
}); | ||
|
||
it('Render scatter chart and verify data config panel', () => { | ||
cy.get('.euiComboBoxPill.euiComboBoxPill--plainText').eq(0).should('contain', 'span(timestamp,1d)'); | ||
cy.get('.euiComboBoxPill.euiComboBoxPill--plainText').eq(1).should('contain', 'count()'); | ||
}); | ||
|
||
it('Render scatter chart and verify data config panel no result found if metric is missing', () => { | ||
cy.get('[data-test-subj="comboBoxClearButton"]').eq(1).click(); | ||
cy.get('.euiTextColor.euiTextColor--subdued').contains('No results found').should('exist'); | ||
cy.get('.euiComboBoxOption__content').contains('count()').click(); | ||
cy.get('.main-svg').contains('No results found').should('not.exist'); | ||
}); | ||
}); | ||
|
||
describe('Render scatter chart for panel options', () => { | ||
beforeEach(() => { | ||
renderScatterChart(); | ||
}); | ||
|
||
it('Render scatter chart and verify the title gets updated according to user input ', () => { | ||
cy.get('input[name="title"]').type("scatter Chart"); | ||
cy.get('textarea[name="description"]').should('exist').click(); | ||
cy.get('.gtitle').contains('scatter Chart').should('exist'); | ||
}); | ||
}); | ||
|
||
describe('Render scatter chart for legend', () => { | ||
beforeEach(() => { | ||
renderScatterChart(); | ||
}); | ||
|
||
it('Render scatter chart and verify legends for Show and Hidden', () => { | ||
cy.get('[data-text="Show"]').should('have.text', 'Show'); | ||
cy.get('[data-text="Show"] [data-test-subj="show"]').should('have.attr', 'checked'); | ||
cy.get('[data-text="Hidden"]').should('have.text', 'Hidden').click(); | ||
cy.get('[data-text="Hidden"] [data-test-subj="hidden"]').should('not.have.attr', 'checked'); | ||
cy.get('[data-unformatted="max(bytes)"]').should('not.exist'); | ||
}); | ||
|
||
it('Render scatter chart and verify legends for position Right and Bottom', () => { | ||
cy.get('[data-text="Right"] [data-test-subj="v"]').should('have.attr', 'checked'); | ||
cy.get('[data-text="Bottom"]').should('have.text', 'Bottom').click(); | ||
cy.get('[data-text="Bottom"] [data-test-subj="h"]').should('not.have.attr', 'checked'); | ||
}); | ||
|
||
it('Render scatter chart and increase Legend Size', () => { | ||
cy.get('[data-test-subj="valueFieldNumber"]').eq(0).click().type(legendSize); | ||
cy.get('textarea[name="description"]').should('exist').click(); | ||
cy.get('.legendtext').should('have.css', 'font-size', '20px'); | ||
}); | ||
}); | ||
|
||
describe('Render scatter chart for Chart Styles ', () => { | ||
beforeEach(() => { | ||
renderScatterChart(); | ||
}); | ||
|
||
it('Render ltime serires and verify chart style of Marker Mode', () => { | ||
cy.get('#configPanel__panelOptions .euiFieldText').click().type('scatter chart'); | ||
cy.get('.euiFlexItem .euiFormRow [placeholder="Description"]').click().type('This is the description for scatter chart with chart style of Points'); | ||
cy.get('[data-text="Marker"]').should('have.text', 'Marker').click(); | ||
cy.get('[data-text="Marker"] [data-test-subj="markers"]').should('have.attr', 'checked'); | ||
|
||
}); | ||
|
||
it('Render scatter chart and verify chart style of Marker Mode with larger Point size', () => { | ||
cy.get('#configPanel__panelOptions .euiFieldText').click().type('scatter chart'); | ||
cy.get('.euiFlexItem .euiFormRow [placeholder="Description"]').click().type('This is the description for scatter chart with chart style of Points'); | ||
cy.get('[data-text="Marker"]').should('have.text', 'Marker').click(); | ||
cy.get('[data-text="Marker"] [data-test-subj="markers"]').should('have.attr', 'checked'); | ||
cy.get('input[type="range"]') | ||
.then($el => $el[0].stepUp(pointSize)) | ||
.trigger('change') | ||
cy.get('.euiRangeSlider').should('have.value', pointSizeUpdated) | ||
|
||
}); | ||
|
||
it('Render scatter chart and verify chart style of Lines+Marker Mode', () => { | ||
cy.get('#configPanel__panelOptions .euiFieldText').click().type('scatter chart'); | ||
cy.get('.euiFlexItem .euiFormRow [placeholder="Description"]').click().type('This is the description for scatter chart with chart style of Lines and Marker'); | ||
cy.get('[data-text="Lines + Markers"]').should('have.text', 'Lines + Markers').click(); | ||
cy.get('[data-text="Lines + Markers"] [data-test-subj="lines+markers"]').should('not.have.attr', 'checked'); | ||
|
||
}); | ||
|
||
it('Render scatter chart and verify chart style of Lines+Marker Mode with Line Width, Fill Opacity and Point Size', () => { | ||
cy.get('#configPanel__panelOptions .euiFieldText').click().type('scatter chart'); | ||
cy.get('.euiFlexItem .euiFormRow [placeholder="Description"]').click().type('This is the description for scatter chart with chart style of Lines and Marker'); | ||
cy.get('[data-text="Lines + Markers"]').should('have.text', 'Lines + Markers').click(); | ||
cy.get('[data-text="Lines + Markers"] [data-test-subj="lines+markers"]').should('not.have.attr', 'checked'); | ||
cy.get('input[type="range"]').eq(0) | ||
.then($el => $el[0].stepUp(lineWidth)) | ||
.trigger('change') | ||
cy.get('.euiRangeSlider').eq(0).should('have.value', lineWidthUpdated) | ||
cy.get('input[type="range"]').eq(1) | ||
.then($el => $el[0].stepUp(fillOpacity)) | ||
.trigger('change') | ||
cy.get('.euiRangeSlider').eq(1).should('have.value', fillOpacityUpdated) | ||
cy.get('input[type="range"]').eq(2) | ||
.then($el => $el[0].stepUp(pointSize)) | ||
.trigger('change') | ||
cy.get('.euiRangeSlider').eq(2).should('have.value', pointSizeUpdated) | ||
cy.get('input[type="range"]').eq(3) | ||
.then($el => $el[0].stepUp(rotateLevel)) | ||
.trigger('change') | ||
cy.get('.euiRangeSlider').eq(3).should('have.value', rotateLevel) | ||
}); | ||
}); | ||
|
||
describe('Render scatter chart for color theme', () => { | ||
beforeEach(() => { | ||
renderScatterChart(); | ||
}); | ||
|
||
it('Render scatter chart and "Add Color theme"', () => { | ||
cy.get('.euiButton__text').contains('+ Add color theme').click(); | ||
cy.wait(delay); | ||
cy.get('[data-test-subj="comboBoxInput"]').eq(5).click(); | ||
cy.get('.euiComboBoxOption__content').contains('count()').click(); | ||
cy.get('path[style*="rgb(252, 5, 5)"]').should('exist'); | ||
|
||
}); | ||
}); | ||
|
||
describe('Render scatter chart and work with Thresholds', () => { | ||
beforeEach(() => { | ||
renderScatterChart(); | ||
}); | ||
|
||
it('Render scatter chart and add threshold', () => { | ||
cy.get('.euiButton__text').contains('+ Add threshold').click(); | ||
cy.get('[data-test-subj="nameFieldText"]').type('scatter chart Threshold'); | ||
cy.get('[data-test-subj="valueFieldNumber"]').eq(1).type(thresholdValue); | ||
cy.get('[data-unformatted="scatter chart Threshold"]').should('be.visible'); | ||
cy.get('path[style*="rgb(252, 5, 5)"]').should('exist'); | ||
}); | ||
}); | ||
|
||
describe('Render scatter chart and verify if reset works properly', () => { | ||
beforeEach(() => { | ||
renderScatterChart(); | ||
}); | ||
|
||
it('Render scatter chart with all feild data then click on reset and verify reset works properly', () => { | ||
cy.get('input[placeholder="Title"]').type('scatter chart'); | ||
cy.get('textarea[placeholder="Description"]').type('Description For scatter chart'); | ||
cy.get('[data-text="Hidden"]').should('have.text', 'Hidden').click(); | ||
cy.get('[data-test-subj="valueFieldNumber"]').eq(0).click().type(legendSize); | ||
cy.get('.euiButton__text').contains('+ Add color theme').click(); | ||
cy.wait(delay); | ||
cy.get('[data-test-subj="comboBoxInput"]').eq(5).click(); | ||
cy.get('.euiComboBoxOption__content').contains('count()').click(); | ||
cy.get('.euiButton__text').contains('+ Add threshold').click(); | ||
cy.get('[data-test-subj="nameFieldText"]').type('scatter chart Threshold'); | ||
cy.get('[data-test-subj="valueFieldNumber"]').eq(1).type(thresholdValue); | ||
cy.get('.euiButtonEmpty__text').contains('Reset').click(); | ||
cy.get('input[placeholder="Title"]').should('not.have.value', 'scatter chart'); | ||
cy.get('textarea[placeholder="Description"]').should('not.have.value', 'Description For scatter chart') | ||
cy.get('[data-text="Show"] [data-test-subj="show"]').should('have.attr', 'checked'); | ||
cy.get('[data-text="Right"] [data-test-subj="v"]').should('have.attr', 'checked'); | ||
cy.get('[data-test-subj="valueFieldNumber"]').eq(0).should('have.value', ''); | ||
}); | ||
}); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move all these constants to the corresponding constant file under .cypress/utils?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently for slider and input field we have different default value for different chart (Issue 896), once that gets updated we can move all constants to a common file under .cypress/utils