-
Notifications
You must be signed in to change notification settings - Fork 190
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 to delete modal (#5153)
* chore: add e2e tests to delete modal * chore: remove unnecessary todos * chore: check modal visibility before confirmation
- Loading branch information
Showing
3 changed files
with
139 additions
and
5 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
112 changes: 112 additions & 0 deletions
112
packages/compass-e2e-tests/tests/collection-bulk-delete.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,112 @@ | ||
import { expect } from 'chai'; | ||
import type { CompassBrowser } from '../helpers/compass-browser'; | ||
import { startTelemetryServer } from '../helpers/telemetry'; | ||
import type { Telemetry } from '../helpers/telemetry'; | ||
import { beforeTests, afterTests, afterTest } from '../helpers/compass'; | ||
import type { Compass } from '../helpers/compass'; | ||
import * as Selectors from '../helpers/selectors'; | ||
import { createNumbersCollection } from '../helpers/insert-data'; | ||
|
||
describe('Bulk Delete', () => { | ||
let compass: Compass; | ||
let browser: CompassBrowser; | ||
let telemetry: Telemetry; | ||
|
||
before(async function () { | ||
telemetry = await startTelemetryServer(); | ||
compass = await beforeTests({ | ||
extraSpawnArgs: ['--enableBulkDeleteOperations'], | ||
}); | ||
browser = compass.browser; | ||
}); | ||
|
||
after(async function () { | ||
await afterTests(compass, this.currentTest); | ||
await telemetry.stop(); | ||
}); | ||
|
||
beforeEach(async function () { | ||
await createNumbersCollection(); | ||
await browser.connectWithConnectionString(); | ||
await browser.navigateToCollectionTab('test', 'numbers', 'Documents'); | ||
}); | ||
|
||
afterEach(async function () { | ||
await afterTest(compass, this.currentTest); | ||
}); | ||
|
||
it('deletes documents matching a filter', async function () { | ||
//const telemetryEntry = await browser.listenForTelemetryEvents(telemetry); | ||
|
||
// Set a query that we'll use. | ||
await browser.runFindOperation('Documents', '{ i: 5 }'); | ||
|
||
// Open the modal. | ||
await browser.clickVisible(Selectors.OpenBulkDeleteButton); | ||
await browser.$(Selectors.BulkDeleteModal).waitForDisplayed(); | ||
|
||
// Check that it will update the expected number of documents | ||
expect(await browser.$(Selectors.BulkDeleteModalTitle).getText()).to.equal( | ||
'Delete 1 document' | ||
); | ||
|
||
expect( | ||
await browser.$(Selectors.BulkDeleteModalDeleteButton).getText() | ||
).to.equal('Delete 1 document'); | ||
|
||
// Press delete | ||
await browser.clickVisible(Selectors.BulkDeleteModalDeleteButton); | ||
|
||
// The modal should go away | ||
await browser | ||
.$(Selectors.BulkDeleteModal) | ||
.waitForDisplayed({ reverse: true }); | ||
|
||
// Press delete in the confirmation modal | ||
await browser.clickVisible(Selectors.ConfirmationModalConfirmButton()); | ||
await browser.runFindOperation('Documents', '{ i: 5 }'); | ||
|
||
// the document is deleted | ||
expect( | ||
await browser.$(Selectors.DocumentListActionBarMessage).getText() | ||
).to.equal('0 – 0 of 0'); | ||
}); | ||
|
||
it('does not delete documents when cancelled', async function () { | ||
//const telemetryEntry = await browser.listenForTelemetryEvents(telemetry); | ||
|
||
// Set a query that we'll use. | ||
await browser.runFindOperation('Documents', '{ i: 5 }'); | ||
|
||
// Open the modal. | ||
await browser.clickVisible(Selectors.OpenBulkDeleteButton); | ||
await browser.$(Selectors.BulkDeleteModal).waitForDisplayed(); | ||
|
||
// Check that it will update the expected number of documents | ||
expect(await browser.$(Selectors.BulkDeleteModalTitle).getText()).to.equal( | ||
'Delete 1 document' | ||
); | ||
|
||
expect( | ||
await browser.$(Selectors.BulkDeleteModalDeleteButton).getText() | ||
).to.equal('Delete 1 document'); | ||
|
||
// Press delete | ||
await browser.clickVisible(Selectors.BulkDeleteModalDeleteButton); | ||
|
||
// The modal should go away | ||
await browser | ||
.$(Selectors.BulkDeleteModal) | ||
.waitForDisplayed({ reverse: true }); | ||
|
||
// Press cancel in the confirmation modal | ||
await browser.clickVisible(Selectors.ConfirmationModalCancelButton()); | ||
|
||
await browser.runFindOperation('Documents', '{ i: 5 }'); | ||
|
||
// the document is not deleted | ||
expect( | ||
await browser.$(Selectors.DocumentListActionBarMessage).getText() | ||
).to.equal('1 – 1 of 1'); | ||
}); | ||
}); |