-
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(e2e): add E2E test for multiple connection errors COMPASS-8153 (#…
…6117) * remove commented code * fix connectionStatus: either * test multiple connection errors
- Loading branch information
Showing
7 changed files
with
194 additions
and
51 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
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 |
---|---|---|
|
@@ -281,6 +281,12 @@ async function assertCannotCreateCollection( | |
await createModalElement.waitForDisplayed({ reverse: true }); | ||
} | ||
|
||
function assertNotError(result: any) { | ||
if (typeof result === 'string' && result.includes('MongoNetworkError')) { | ||
expect.fail(result); | ||
} | ||
} | ||
|
||
/** | ||
* Connection tests | ||
*/ | ||
|
@@ -322,10 +328,13 @@ describe('Connection string', function () { | |
it('fails for authentication errors', async function () { | ||
skipForWeb(this, 'connect happens on the outside'); | ||
|
||
// connect | ||
await browser.connectWithConnectionString( | ||
`mongodb://a:[email protected]:${MONGODB_TEST_SERVER_PORT}/test`, | ||
{ connectionStatus: 'failure' } | ||
); | ||
|
||
// check the error | ||
if (TEST_MULTIPLE_CONNECTIONS) { | ||
const toastTitle = await browser.$(Selectors.LGToastTitle).getText(); | ||
expect(toastTitle).to.equal('Authentication failed.'); | ||
|
@@ -949,6 +958,113 @@ describe('Connection form', function () { | |
assertNotError(result); | ||
expect(result).to.have.property('ok', 1); | ||
}); | ||
|
||
it('fails for multiple authentication errors', async function () { | ||
if (!TEST_MULTIPLE_CONNECTIONS) { | ||
this.skip(); | ||
} | ||
|
||
const connection1Name = 'error-1'; | ||
const connection2Name = 'error-2'; | ||
|
||
const connections: { | ||
state: ConnectFormState; | ||
connectionId?: string; | ||
connectionError: string; | ||
toastErrorText: string; | ||
}[] = [ | ||
{ | ||
state: { | ||
hosts: ['127.0.0.1:27091'], | ||
defaultUsername: 'a', | ||
defaultPassword: 'b', | ||
connectionName: connection1Name, | ||
}, | ||
connectionError: 'Authentication failed.', | ||
toastErrorText: `There was a problem connecting to ${connection1Name}`, | ||
}, | ||
{ | ||
state: { | ||
hosts: ['127.0.0.1:16666'], | ||
connectionName: connection2Name, | ||
}, | ||
connectionError: 'connect ECONNREFUSED 127.0.0.1:16666', | ||
toastErrorText: `There was a problem connecting to ${connection2Name}`, | ||
}, | ||
]; | ||
|
||
// connect to two connections that will both fail | ||
// This actually connects back to back rather than truly simultaneously, but | ||
// we can only really check that both toasts display and work anyway. | ||
for (const connection of connections) { | ||
await browser.connectWithConnectionForm(connection.state, { | ||
connectionStatus: 'failure', | ||
}); | ||
} | ||
|
||
// pull the connection ids out of the sidebar | ||
for (const connection of connections) { | ||
if (!connection.state.connectionName) { | ||
throw new Error('expected connectionName'); | ||
} | ||
connection.connectionId = await browser.getConnectionIdByName( | ||
connection.state.connectionName | ||
); | ||
} | ||
|
||
// the last connection to be connected's toast appears on top, so we have to | ||
// deal with the toasts in reverse | ||
const expectedConnections = connections.slice().reverse(); | ||
|
||
for (const expected of expectedConnections) { | ||
if (!expected.connectionId) { | ||
throw new Error('expected connectionId'); | ||
} | ||
|
||
// the toast should appear | ||
const toastSelector = Selectors.connectionToastById( | ||
expected.connectionId | ||
); | ||
await browser.$(toastSelector).waitForDisplayed(); | ||
|
||
// check the toast title | ||
const toastTitle = await browser | ||
.$(`${toastSelector} ${Selectors.LGToastTitle}`) | ||
.getText(); | ||
expect(toastTitle).to.equal(expected.connectionError); | ||
|
||
// check the toast body text | ||
const errorMessage = await browser | ||
.$(`${toastSelector} ${Selectors.ConnectionToastErrorText}`) | ||
.getText(); | ||
expect(errorMessage).to.equal(expected.toastErrorText); | ||
|
||
// click the review button in the toast | ||
await browser.clickVisible( | ||
`${toastSelector} ${Selectors.ConnectionToastErrorReviewButton}` | ||
); | ||
|
||
// the toast should go away because the action was clicked | ||
await browser.$(toastSelector).waitForDisplayed({ reverse: true }); | ||
|
||
// make sure the connection form is populated with this connection | ||
await browser.$(Selectors.ConnectionModal).waitForDisplayed(); | ||
const errorText = await browser | ||
.$(Selectors.ConnectionFormErrorMessage) | ||
.getText(); | ||
expect(errorText).to.equal(expected.connectionError); | ||
|
||
const state = await browser.getConnectFormState(); | ||
expect(state.hosts).to.deep.equal(expected.state.hosts); | ||
expect(state.connectionName).to.equal(expected.state.connectionName); | ||
|
||
// close the modal | ||
await browser.clickVisible(Selectors.ConnectionModalCloseButton); | ||
await browser | ||
.$(Selectors.ConnectionModal) | ||
.waitForDisplayed({ reverse: true }); | ||
} | ||
}); | ||
}); | ||
|
||
// eslint-disable-next-line mocha/max-top-level-suites | ||
|
@@ -961,12 +1077,6 @@ describe('SRV connectivity', function () { | |
}); | ||
|
||
it('resolves SRV connection string using OS DNS APIs', async function () { | ||
if (TEST_MULTIPLE_CONNECTIONS) { | ||
// TODO(COMPASS-8153): we have to add support in custom commands for when | ||
// connections fail | ||
this.skip(); | ||
} | ||
|
||
const compass = await init(this.test?.fullTitle()); | ||
const browser = compass.browser; | ||
|
||
|
@@ -1141,9 +1251,3 @@ describe('FLE2', function () { | |
expect(result).to.be.equal('test'); | ||
}); | ||
}); | ||
|
||
function assertNotError(result: any) { | ||
if (typeof result === 'string' && result.includes('MongoNetworkError')) { | ||
expect.fail(result); | ||
} | ||
} |
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