-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
chore: E2E tests for the Drill to detail modal #21187
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dfaaa1b
Add example ECharts Dashboard
geido caebf71
[WIP] E2E test
geido d258531
Add echarts interactions
geido cbd7fdc
Lint
geido 321a7bf
Merge branch 'master' of https://github.com/apache/superset into chor…
geido 0cb2238
DRY
geido 8f2a153
Merge branch 'master' of https://github.com/apache/superset into chor…
geido 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
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
294 changes: 294 additions & 0 deletions
294
superset-frontend/cypress-base/cypress/integration/dashboard/drilltodetail.test.ts
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,294 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import { | ||
waitForChartLoad, | ||
ECHARTS_CHARTS, | ||
ECHARTS_DASHBOARD, | ||
} from './dashboard.helper'; | ||
|
||
function interceptSamples() { | ||
cy.intercept(`/datasource/samples*`).as('samples'); | ||
} | ||
|
||
describe('Drill to detail modal', () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
cy.visit(ECHARTS_DASHBOARD); | ||
ECHARTS_CHARTS.forEach(waitForChartLoad); | ||
}); | ||
|
||
it('opens the modal from the context menu', () => { | ||
cy.get( | ||
"[data-test-viz-type='big_number_total'] [aria-label='More Options']", | ||
).click(); | ||
cy.get('.ant-dropdown') | ||
.not('.ant-dropdown-hidden') | ||
.find("[role='menu'] [role='menuitem']") | ||
.eq(5) | ||
.should('contain', 'Drill to detail') | ||
.click(); | ||
cy.get("[role='dialog'] .draggable-trigger").should( | ||
'contain', | ||
'Drill to detail: Number of Girls', | ||
); | ||
}); | ||
|
||
it('refreshes the data', () => { | ||
interceptSamples(); | ||
|
||
cy.get( | ||
"[data-test-viz-type='big_number_total'] [aria-label='More Options']", | ||
).click(); | ||
cy.get('.ant-dropdown') | ||
.not('.ant-dropdown-hidden') | ||
.find("[role='menu'] [role='menuitem']") | ||
.eq(5) | ||
.should('contain', 'Drill to detail') | ||
.click(); | ||
// move to the last page | ||
cy.get(".pagination-container [role='navigation'] [role='button']") | ||
.eq(7) | ||
.click(); | ||
cy.wait('@samples'); | ||
// reload | ||
cy.get("[aria-label='reload']").click(); | ||
cy.wait('@samples'); | ||
// make sure it started back from first page | ||
cy.get(".pagination-container [role='navigation'] li.active").should( | ||
'contain', | ||
'1', | ||
); | ||
}); | ||
|
||
it('paginates', () => { | ||
interceptSamples(); | ||
|
||
cy.get( | ||
"[data-test-viz-type='big_number_total'] [aria-label='More Options']", | ||
).click(); | ||
cy.get('.ant-dropdown') | ||
.not('.ant-dropdown-hidden') | ||
.find("[role='menu'] [role='menuitem']") | ||
.eq(5) | ||
.should('contain', 'Drill to detail') | ||
.click(); | ||
cy.wait('@samples'); | ||
|
||
// checking the data | ||
cy.get("[data-test='row-count-label']").should('contain', '36.4k rows'); | ||
cy.get("[role='rowgroup'] [role='row']") | ||
.should('have.length', 50) | ||
.then($rows => { | ||
expect($rows).to.contain('Amy'); | ||
}); | ||
// checking the paginated data | ||
cy.get(".pagination-container [role='navigation'] [role='button']") | ||
.should('have.length', 9) | ||
.then($pages => { | ||
expect($pages).to.contain('1'); | ||
expect($pages).to.contain('729'); | ||
}); | ||
cy.get(".pagination-container [role='navigation'] [role='button']") | ||
.eq(7) | ||
.click(); | ||
cy.wait('@samples'); | ||
cy.get("[role='rowgroup'] [role='row']") | ||
.should('have.length', 46) | ||
.then($rows => { | ||
expect($rows).to.contain('Victoria'); | ||
}); | ||
}); | ||
|
||
it('clears filters', () => { | ||
interceptSamples(); | ||
|
||
// opens the modal by clicking on the box on the chart | ||
cy.get("[data-test-viz-type='box_plot'] canvas").then($canvas => { | ||
const canvasWidth = $canvas.width() || 0; | ||
const canvasHeight = $canvas.height() || 0; | ||
const canvasCenterX = canvasWidth / 6; | ||
const canvasCenterY = canvasHeight / 6; | ||
|
||
cy.wrap($canvas) | ||
.scrollIntoView() | ||
.rightclick(canvasCenterX, canvasCenterY, { force: true }); | ||
cy.get('.ant-dropdown') | ||
.not('.ant-dropdown-hidden') | ||
.find("[role='menu'] [role='menuitem']") | ||
.should('contain', 'Drill to detail by East Asia & Pacific') | ||
.click(); | ||
cy.wait('@samples'); | ||
|
||
// checking the filter | ||
cy.get("[data-test='filter-val']").should( | ||
'contain', | ||
'East Asia & Pacific', | ||
); | ||
cy.get("[data-test='row-count-label']").should('contain', '1.98k rows'); | ||
cy.get(".pagination-container [role='navigation'] [role='button']") | ||
.should('have.length', 9) | ||
.then($pages => { | ||
expect($pages).to.contain('1'); | ||
expect($pages).to.contain('40'); | ||
}); | ||
|
||
// close the filter and test that data was reloaded | ||
cy.get("[data-test='filter-col']").find("[aria-label='close']").click(); | ||
cy.wait('@samples'); | ||
cy.get("[data-test='row-count-label']").should('contain', '11.8k rows'); | ||
cy.get(".pagination-container [role='navigation'] li.active").should( | ||
'contain', | ||
'1', | ||
); | ||
cy.get(".pagination-container [role='navigation'] [role='button']") | ||
.should('have.length', 9) | ||
.then($pages => { | ||
expect($pages).to.contain('1'); | ||
expect($pages).to.contain('236'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Time-series Bar Chart V2', () => { | ||
it('opens the modal with the correct filters', () => { | ||
interceptSamples(); | ||
|
||
cy.get("[data-test-viz-type='echarts_timeseries_bar'] canvas").then( | ||
$canvas => { | ||
cy.wrap($canvas) | ||
.scrollIntoView() | ||
.rightclick(70, 100, { force: true }); | ||
cy.get('.ant-dropdown') | ||
.not('.ant-dropdown-hidden') | ||
.find("[role='menu'] [role='menuitem']") | ||
.should('have.length', 3) | ||
.then($menuitems => { | ||
expect($menuitems).to.contain('Drill to detail by 1965'); | ||
expect($menuitems).to.contain('Drill to detail by boy'); | ||
expect($menuitems).to.contain('Drill to detail by all'); | ||
}) | ||
.eq(2) | ||
.click(); | ||
cy.wait('@samples'); | ||
|
||
cy.get("[data-test='filter-val']").then($filters => { | ||
expect($filters).to.contain('1965'); | ||
expect($filters).to.contain('boy'); | ||
}); | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
describe('Box plot', () => { | ||
it('opens the modal with the correct filters', () => { | ||
interceptSamples(); | ||
|
||
// opens the modal by clicking on the box on the chart | ||
cy.get("[data-test-viz-type='box_plot'] canvas").then($canvas => { | ||
const canvasWidth = $canvas.width() || 0; | ||
const canvasHeight = $canvas.height() || 0; | ||
const canvasCenterX = canvasWidth / 6; | ||
const canvasCenterY = canvasHeight / 6; | ||
|
||
cy.wrap($canvas) | ||
.scrollIntoView() | ||
.rightclick(canvasCenterX, canvasCenterY, { force: true }); | ||
cy.get('.ant-dropdown') | ||
.not('.ant-dropdown-hidden') | ||
.find("[role='menu'] [role='menuitem']") | ||
.should('contain', 'Drill to detail by East Asia & Pacific') | ||
.click(); | ||
cy.wait('@samples'); | ||
|
||
// checking the filter | ||
cy.get("[data-test='filter-val']").should( | ||
'contain', | ||
'East Asia & Pacific', | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Pie', () => { | ||
it('opens the modal with the correct filters', () => { | ||
interceptSamples(); | ||
|
||
// opens the modal by clicking on the slice of the Pie chart | ||
cy.get("[data-test-viz-type='pie'] canvas").then($canvas => { | ||
const canvasWidth = $canvas.width() || 0; | ||
const canvasHeight = $canvas.height() || 0; | ||
const canvasCenterX = canvasWidth / 2; | ||
const canvasCenterY = canvasHeight / 2; | ||
|
||
cy.wrap($canvas) | ||
.scrollIntoView() | ||
.rightclick(canvasCenterX, canvasCenterY, { force: true }); | ||
cy.get('.ant-dropdown') | ||
.not('.ant-dropdown-hidden') | ||
.find("[role='menu'] [role='menuitem']") | ||
.should('contain', 'Drill to detail by boy') | ||
.click(); | ||
cy.wait('@samples'); | ||
|
||
// checking the filtered and paginated data | ||
cy.get("[data-test='filter-val']").should('contain', 'boy'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Big number total', () => { | ||
it('opens the modal with no filters', () => { | ||
interceptSamples(); | ||
|
||
// opens the modal by clicking on the number on the chart | ||
cy.get( | ||
"[data-test-viz-type='big_number_total'] .header-line", | ||
).rightclick(); | ||
cy.get('.ant-dropdown') | ||
.not('.ant-dropdown-hidden') | ||
.find("[role='menu'] [role='menuitem']") | ||
.should('contain', 'Drill to detail') | ||
.click(); | ||
cy.wait('@samples'); | ||
|
||
cy.get("[data-test='filter-val']").should('not.exist'); | ||
}); | ||
}); | ||
|
||
describe('Big number with trendline', () => { | ||
it('opens the modal with the correct data', () => { | ||
interceptSamples(); | ||
|
||
// opens the modal by clicking on the number | ||
cy.get("[data-test-viz-type='big_number'] .header-line").rightclick(); | ||
cy.get('.ant-dropdown') | ||
.not('.ant-dropdown-hidden') | ||
.find("[role='menu'] [role='menuitem']") | ||
.should('contain', 'Drill to detail') | ||
.click(); | ||
cy.wait('@samples'); | ||
|
||
cy.get("[data-test='filter-val']").should('not.exist'); | ||
|
||
// TODO: test clicking on a trendline | ||
// Cypress is refusing to rightclick on the dot | ||
}); | ||
}); | ||
}); |
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
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
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
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
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
Oops, something went wrong.
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 extract the code that opens the modal to a function? Specifically this part:
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.
+1
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.
Sure. Updated