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

* changed selectors for not skipped tests in sqllab suite

* linter fixes

* linter fixes
This commit is contained in:
adam-stasiak-polidea 2020-09-22 00:49:44 +02:00 committed by GitHub
parent a8f5029cb1
commit dc893fe1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 21 deletions

View File

@ -24,33 +24,39 @@ describe('SqlLab query tabs', () => {
}); });
it('allows you to create a tab', () => { 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; const initialTabCount = tabList.length;
// add tab // add tab
cy.get('.SqlEditorTabs > ul > li').last().click(); cy.get('[data-test="add-tab-icon"]').click();
// wait until we find the new tab // wait until we find the new tab
cy.get(`.SqlEditorTabs > ul > li:eq(${initialTabCount - 1})`).contains( cy.get('[data-test="sql-editor-tabs"]')
'Untitled Query', .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', () => { it('allows you to close a tab', () => {
cy.get('.SqlEditorTabs > ul > li').then(tabListA => { cy.get('[data-test="sql-editor-tabs"]')
const initialTabCount = tabListA.length; .children()
.then(tabListA => {
const initialTabCount = tabListA.length;
// open the tab dropdown to remove // open the tab dropdown to remove
cy.get('.SqlEditorTabs > ul > li .dropdown-toggle').click({ cy.get('[data-test="dropdown-toggle-button"]').click({
force: true, force: true,
});
// first item is close
cy.get('[data-test="close-tab-menu-option"]').click();
cy.get('[data-test="sql-editor-tabs"]').should(
'have.length',
initialTabCount - 1,
);
}); });
// first item is close
cy.get('.SqlEditorTabs .ddbtn-tab svg').first().click();
cy.get('.SqlEditorTabs > ul > li').should(
'have.length',
initialTabCount - 1,
);
});
}); });
}); });

View File

@ -312,6 +312,7 @@ class TabbedSqlEditors extends React.PureComponent {
<> <>
{isSelected && ( {isSelected && (
<DropdownButton <DropdownButton
data-test="dropdown-toggle-button"
bsSize="small" bsSize="small"
id={`ddbtn-tab-${i}`} id={`ddbtn-tab-${i}`}
title={' '} title={' '}
@ -321,6 +322,7 @@ class TabbedSqlEditors extends React.PureComponent {
className="close-btn" className="close-btn"
eventKey="1" eventKey="1"
onClick={() => this.removeQueryEditor(qe)} onClick={() => this.removeQueryEditor(qe)}
data-test="close-tab-menu-option"
> >
<div className="icon-container"> <div className="icon-container">
<i className="fa fa-close" /> <i className="fa fa-close" />
@ -396,12 +398,13 @@ class TabbedSqlEditors extends React.PureComponent {
onSelect={this.handleSelect.bind(this)} onSelect={this.handleSelect.bind(this)}
id="a11y-query-editor-tabs" id="a11y-query-editor-tabs"
className="SqlEditorTabs" className="SqlEditorTabs"
data-test="sql-editor-tabs"
> >
{editors} {editors}
<Tab <Tab
title={ title={
<div> <div>
<i className="fa fa-plus-circle" /> <i data-test="add-tab-icon" className="fa fa-plus-circle" />
&nbsp; &nbsp;
</div> </div>
} }