Skip to content

Conversation

@gagik
Copy link
Contributor

@gagik gagik commented Aug 26, 2025

Updates selectors and mocks methods to match leafygreen components.

Copilot AI review requested due to automatic review settings August 26, 2025 11:24
@gagik gagik requested a review from a team as a code owner August 26, 2025 11:24
@gagik gagik force-pushed the gagik/fix-assistant-tests branch from b04a9d2 to 76c6025 Compare August 26, 2025 11:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes failing assistant tests by updating test selectors and mock methods to match the leafygreen chat components. The changes primarily involve replacing test IDs with accessibility-based selectors and addressing component API changes.

  • Updates test selectors from data-testid attributes to accessibility-based selectors (placeholder text and aria-labels)
  • Adds mock for scrollTo method and updates styling to fix layout issues
  • Adds new leafygreen component features like MessageActions and sourceType properties

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
compass-assistant-provider.spec.tsx Updates selectors and re-enables previously skipped tests
assistant-chat.tsx Adds styling fixes, MessageActions component, and input trimming logic
assistant-chat.spec.tsx Updates selectors, adds scrollTo mock, and adjusts test expectations for leafygreen components

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


// TODO(COMPASS-9751): These are temporary patches to make the Assistant chat take the entire
// width and height of the drawer since Leafygreen doesn't support this yet.
const assistantChatFixesStyles = css({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't required for the tests but are CSS patchups that I feel like I might as well include here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raised both with LG

@gagik gagik added the no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) label Aug 26, 2025
Comment on lines 14 to 21
// Mock scrollTo method for DOM elements to prevent test failures
before(function () {
if (!Element.prototype.scrollTo) {
Element.prototype.scrollTo = function () {
// No-op implementation for testing
};
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// width and height of the drawer since Leafygreen doesn't support this yet.
const assistantChatFixesStyles = css({
// Negative margin to patch the padding of the drawer.
margin: -spacing[400],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're doing more or less the same for data modeling, I wonder if we should move this to our drawer portal already

Copy link
Contributor Author

@gagik gagik Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we will raise this with Leafygreen to confirm they'll also do this and there'll be a discussion about this during the Atlas Chatbots Sync if you'd be interested (invited you as optional)


userEvent.type(
screen.getByTestId('assistant-chat-input'),
screen.getByPlaceholderText('Ask MongoDB Assistant a question'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good example of how not relying on test-ids would save us some refactoring time 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

funnily enough I opted for testids back then because I thought this would be less design dependent but the inability to pass it to specific subcomments did backfire..

agree generally though, with the only risk being stuff like text being duplicated in multiple components which is something I ran into a lot with context menu tests

Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move scrollTo stub to the shared stubs place, otherwise lgtm

@lerouxb lerouxb merged commit c832b30 into main Aug 26, 2025
53 of 57 checks passed
@lerouxb lerouxb deleted the gagik/fix-assistant-tests branch August 26, 2025 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants