-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add e2e tests for tab behavior
- Loading branch information
1 parent
4ede15a
commit 0aa003d
Showing
5 changed files
with
149 additions
and
9 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import type { CompassBrowser } from '../helpers/compass-browser'; | ||
import { init, cleanup, screenshotIfFailed } from '../helpers/compass'; | ||
import type { Compass } from '../helpers/compass'; | ||
import * as Selectors from '../helpers/selectors'; | ||
import { createNumbersCollection } from '../helpers/insert-data'; | ||
import { expect } from 'chai'; | ||
|
||
describe('Global Tabs', function () { | ||
let compass: Compass; | ||
let browser: CompassBrowser; | ||
|
||
const collections = ['a', 'b', 'c']; | ||
|
||
before(async function () { | ||
compass = await init(this.test?.fullTitle()); | ||
browser = compass.browser; | ||
}); | ||
|
||
beforeEach(async function () { | ||
for (const collName of collections) { | ||
await createNumbersCollection(collName, 1); | ||
await createNumbersCollection(collName, 1); | ||
await createNumbersCollection(collName, 1); | ||
} | ||
await browser.connectWithConnectionString(); | ||
}); | ||
|
||
afterEach(async function () { | ||
await screenshotIfFailed(compass, this.currentTest); | ||
}); | ||
|
||
after(async function () { | ||
await cleanup(compass); | ||
}); | ||
|
||
it('should open tabs over each other when not modified', async function () { | ||
for (const collName of collections) { | ||
await browser.navigateToCollectionTab( | ||
'test', | ||
collName, | ||
'Documents', | ||
false | ||
); | ||
} | ||
expect(await browser.$$(Selectors.workspaceTab(null))).to.have.lengthOf(1); | ||
}); | ||
|
||
it('should open tabs over each other when not modified', async function () { | ||
for (const collName of collections) { | ||
await browser.navigateToCollectionTab( | ||
'test', | ||
collName, | ||
'Documents', | ||
false | ||
); | ||
// Click something to make sure we "modified" the tab | ||
await browser.clickVisible(Selectors.queryBar('Documents')); | ||
} | ||
expect(await browser.$$(Selectors.workspaceTab(null))).to.have.lengthOf(3); | ||
}); | ||
|
||
it('should close tabs without warning even when "modified" by interacting with the tab', async function () { | ||
for (const collName of collections) { | ||
await browser.navigateToCollectionTab( | ||
'test', | ||
collName, | ||
'Documents', | ||
false | ||
); | ||
// Click something to make sure we "modified" the tab | ||
await browser.clickVisible(Selectors.queryBar('Documents')); | ||
} | ||
await browser.closeWorkspaceTabs(false); | ||
expect(await browser.$$(Selectors.workspaceTab(null))).to.have.lengthOf(0); | ||
}); | ||
|
||
it('should ask for confirmation when closing modified Aggregations tab', async function () { | ||
await browser.navigateToCollectionTab('test', 'a', 'Aggregations'); | ||
|
||
await browser.clickVisible( | ||
Selectors.aggregationPipelineModeToggle('as-text') | ||
); | ||
|
||
await browser.setCodemirrorEditorValue( | ||
Selectors.AggregationAsTextEditor, | ||
'[{$match: { i: 0 }}]' | ||
); | ||
|
||
await browser.clickVisible(Selectors.CloseWorkspaceTab); | ||
await browser.$(Selectors.ConfirmTabCloseModal).waitForDisplayed(); | ||
|
||
await browser.clickVisible( | ||
browser.$(Selectors.ConfirmTabCloseModal).$('button=Cancel') | ||
); | ||
await browser | ||
.$(Selectors.ConfirmTabCloseModal) | ||
.waitForExist({ reverse: true }); | ||
|
||
// Checking first that cancel leaves the tab on the screen | ||
expect(await browser.$$(Selectors.workspaceTab(null))).to.have.lengthOf(1); | ||
|
||
await browser.clickVisible(Selectors.CloseWorkspaceTab); | ||
await browser.$(Selectors.ConfirmTabCloseModal).waitForDisplayed(); | ||
|
||
await browser.clickVisible( | ||
browser.$(Selectors.ConfirmTabCloseModal).$('button=Close tab') | ||
); | ||
await browser | ||
.$(Selectors.ConfirmTabCloseModal) | ||
.waitForExist({ reverse: true }); | ||
|
||
// When confirmed, should remove the tab | ||
expect(await browser.$$(Selectors.workspaceTab(null))).to.have.lengthOf(0); | ||
}); | ||
}); |
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