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

chore: selectors refactor in SQLLab test suite (Cypress) #10944

Merged
merged 3 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,39 @@ describe('SqlLab query tabs', () => {
});

it('allows you to create a tab', () => {
cy.get('.SqlEditorTabs > ul > li').then(tabList => {
cy.get('[data-test="sql-editor-tabs"]').then(tabList => {
const initialTabCount = tabList.length;
// add tab
cy.get('.SqlEditorTabs > ul > li').last().click();
cy.get('[data-test="add-tab-icon"]').click();
// wait until we find the new tab
cy.get(`.SqlEditorTabs > ul > li:eq(${initialTabCount - 1})`).contains(
'Untitled Query',
);
cy.get('[data-test="sql-editor-tabs"]')
.children()
.eq(initialTabCount - 1)
.contains(`Untitled Query ${initialTabCount + 1}`);
cy.get('[data-test="sql-editor-tabs"]')
.children()
.eq(initialTabCount)
.contains(`Untitled Query ${initialTabCount + 2}`);
});
});

it('allows you to close a tab', () => {
cy.get('.SqlEditorTabs > ul > li').then(tabListA => {
const initialTabCount = tabListA.length;
cy.get('[data-test="sql-editor-tabs"]')
.children()
.then(tabListA => {
const initialTabCount = tabListA.length;

// open the tab dropdown to remove
cy.get('.SqlEditorTabs > ul > li .dropdown-toggle').click({
force: true,
});
// open the tab dropdown to remove
cy.get('[data-test="dropdown-toggle-button"]').click({
force: true,
});

// first item is close
cy.get('.SqlEditorTabs .ddbtn-tab svg').first().click();
// first item is close
cy.get('[data-test="close-tab-menu-option"]').click();

cy.get('.SqlEditorTabs > ul > li').should(
'have.length',
initialTabCount - 1,
);
});
cy.get('[data-test="sql-editor-tabs"]').should(
'have.length',
initialTabCount - 1,
);
});
});
});
5 changes: 4 additions & 1 deletion superset-frontend/src/SqlLab/components/TabbedSqlEditors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ class TabbedSqlEditors extends React.PureComponent {
<>
{isSelected && (
<DropdownButton
data-test="dropdown-toggle-button"
bsSize="small"
id={`ddbtn-tab-${i}`}
title={' '}
Expand All @@ -324,6 +325,7 @@ class TabbedSqlEditors extends React.PureComponent {
className="close-btn"
eventKey="1"
onClick={() => this.removeQueryEditor(qe)}
data-test="close-tab-menu-option"
>
<div className="icon-container">
<i className="fa fa-close" />
Expand Down Expand Up @@ -399,12 +401,13 @@ class TabbedSqlEditors extends React.PureComponent {
onSelect={this.handleSelect.bind(this)}
id="a11y-query-editor-tabs"
className="SqlEditorTabs"
data-test="sql-editor-tabs"
>
{editors}
<Tab
title={
<div>
<i className="fa fa-plus-circle" />
<i data-test="add-tab-icon" className="fa fa-plus-circle" />
&nbsp;
</div>
}
Expand Down