Skip to content

Commit 03c03c2

Browse files
committed
commented test for when the toast order is swapped
1 parent 9c698ac commit 03c03c2

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

packages/compass-assistant/src/compass-assistant-drawer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const CompassAssistantDrawer: React.FunctionComponent<{
3333
'The current chat will be cleared, and chat history will not be retrievable.',
3434
buttonText: 'Clear chat',
3535
variant: 'danger',
36+
'data-testid': 'confirm-clear-chat-modal',
3637
});
3738
if (confirmed) {
3839
clearChat();

packages/compass-assistant/src/compass-assistant-provider.spec.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,19 @@ describe('AssistantProvider', function () {
200200
userEvent.click(clearButton);
201201

202202
await waitFor(() => {
203-
expect(screen.getByTestId('confirmation-modal')).to.exist;
203+
expect(screen.getByTestId('confirm-clear-chat-modal')).to.exist;
204204
});
205205

206206
// There should be messages in the chat
207207
expect(screen.getByTestId('assistant-message-1')).to.exist;
208208
expect(screen.getByTestId('assistant-message-2')).to.exist;
209209

210-
const modal = screen.getByTestId('confirmation-modal');
210+
const modal = screen.getByTestId('confirm-clear-chat-modal');
211211
const confirmButton = within(modal).getByText('Clear chat');
212212
userEvent.click(confirmButton);
213213

214214
await waitForElementToBeRemoved(() =>
215-
screen.getByTestId('confirmation-modal')
215+
screen.getByTestId('confirm-clear-chat-modal')
216216
);
217217

218218
expect(mockChat.messages).to.be.empty;
@@ -229,19 +229,19 @@ describe('AssistantProvider', function () {
229229
userEvent.click(clearButton);
230230

231231
await waitFor(() => {
232-
expect(screen.getByTestId('confirmation-modal')).to.exist;
232+
expect(screen.getByTestId('confirm-clear-chat-modal')).to.exist;
233233
});
234234

235235
// There should be messages in the chat
236236
expect(screen.getByTestId('assistant-message-1')).to.exist;
237237
expect(screen.getByTestId('assistant-message-2')).to.exist;
238238

239-
const modal = screen.getByTestId('confirmation-modal');
239+
const modal = screen.getByTestId('confirm-clear-chat-modal');
240240
const cancelButton = within(modal).getByText('Cancel');
241241
userEvent.click(cancelButton);
242242

243243
await waitForElementToBeRemoved(() =>
244-
screen.getByTestId('confirmation-modal')
244+
screen.getByTestId('confirm-clear-chat-modal')
245245
);
246246

247247
expect(mockChat.messages).to.deep.equal(mockMessages);

packages/compass-e2e-tests/helpers/selectors.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ export const ConnectionToastErrorReviewButton =
242242
'[data-testid="connection-error-review"]';
243243
export const ConenctionToastCancelConnectionButton =
244244
'[data-testid="cancel-connection-button"]';
245+
export const ConnectionToastErrorDebugButton =
246+
'[data-testid="connection-error-debug"]';
245247

246248
// Connections sidebar
247249
export const ConnectionsTitle = '[data-testid="connections-header"]';
@@ -1511,3 +1513,9 @@ export const SideDrawer = `[data-testid="${getDrawerIds().root}"]`;
15111513
export const SideDrawerCloseButton = `[data-testid="${
15121514
getDrawerIds().closeButton
15131515
}"]`;
1516+
1517+
// Assistant
1518+
export const AssistantChatMessages = '[data-testid="assistant-chat-messages"]';
1519+
export const AssistantClearChatButton = '[data-testid="assistant-clear-chat"]';
1520+
export const ConfirmClearChatModal = '[data-testid="confirm-clear-chat-modal"]';
1521+
export const ConfirmClearChatModalConfirmButton = `${ConfirmClearChatModal} [data-testid="lg-confirmation_modal-footer-confirm_button"]`;

packages/compass-e2e-tests/tests/connection.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ describe('Connection string', function () {
273273
before(async function () {
274274
compass = await init(this.test?.fullTitle());
275275
browser = compass.browser;
276+
// TODO(COMPASS-9746) the debug toast obscures the connection toast which
277+
// breaks the connect custom commands and who knows what else
278+
//await browser.setFeature('enableAIAssistant', true)
276279
});
277280

278281
beforeEach(async function () {
@@ -326,6 +329,29 @@ describe('Connection string', function () {
326329
.$(Selectors.ConnectionFormErrorMessage)
327330
.getText();
328331
expect(errorText).to.equal('Authentication failed.');
332+
333+
// close the modal
334+
await browser.clickVisible(Selectors.ConnectionModalCloseButton);
335+
await browser
336+
.$(Selectors.ConnectionModal)
337+
.waitForDisplayed({ reverse: true });
338+
339+
// TODO(COMPASS-9746) the toasts should be swapped around which means these actions probably also need to be swapped around
340+
/*
341+
await browser.clickVisible(Selectors.ConnectionToastErrorDebugButton);
342+
const messagesElement = browser.$(Selectors.AssistantChatMessages)
343+
await messagesElement.waitForDisplayed();
344+
// TODO(COMPASS-9744) check the response from the chatbot too
345+
346+
await browser.waitUntil(async () => {
347+
return (await messagesElement.getText()).includes('Given the error message below,');
348+
});
349+
350+
// clear the chat so that a broken message doesn't break every future message
351+
await browser.clickVisible(Selectors.AssistantClearChatButton);
352+
await browser.clickVisible(Selectors.ConfirmClearChatModalConfirmButton);
353+
await browser.clickVisible(Selectors.SideDrawerCloseButton);
354+
*/
329355
});
330356

331357
it('can connect to an Atlas replicaset without srv', async function () {

0 commit comments

Comments
 (0)