Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Fix course messages e2e tests #9536

Merged
merged 2 commits into from
Oct 20, 2024

Conversation

asliayk
Copy link
Contributor

@asliayk asliayk commented Oct 20, 2024

Checklist

General

Motivation and Context

Some of the tests in CourseMessages.spec.ts were failing after the changes in sidebar design. The tests could not identify the newly added button for create channel/browse channels.

Description

browseChannelButton(), createChannelButton(), and createGroupChatButton() have been updated so that tests can identify these buttons again.

Steps for Testing

Check that the test runs through correctly.

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Screenshots

Summary by CodeRabbit

  • Bug Fixes

    • Streamlined method calls for browsing channels, enhancing test clarity and maintainability.
    • Adjusted expected channel names in assertions to match new naming conventions.
  • New Features

    • Updated UI interactions for creating channels and group chats, aligning with the new button structures.

These enhancements improve user experience by ensuring consistent channel management and clearer test outcomes.

Copy link

coderabbitai bot commented Oct 20, 2024

Walkthrough

The pull request includes modifications to the test suite for course messages in Playwright, specifically updating the CourseMessages.spec.ts file to simplify method calls related to browsing channels. The browseChannelsButton method is now asynchronous and no longer requires specific channel type arguments. Additionally, the CourseMessagesPage.ts file has been updated to reflect changes in UI interactions for creating channels and group chats, including new button selectors. These updates aim to enhance clarity and maintainability in the test cases and UI interactions.

Changes

File Change Summary
src/test/playwright/e2e/course/CourseMessages.spec.ts Updated test cases to simplify browseChannelsButton method calls, removing specific channel type arguments and adjusting expected channel names in assertions.
src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts Modified createChannelButton, browseChannelsButton, and createGroupChatButton methods to use new selectors and updated method signatures. browseChannelsButton changed to an asynchronous method.

Possibly related PRs

Suggested labels

tests, ready for review, bugfix, small

Suggested reviewers

  • SimonEntholzer
  • krusche
  • coolchock
  • az108
  • HawKhiem
  • rabeatwork

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (6)
src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts (3)

20-23: LGTM with a minor suggestion.

The changes to createChannelButton method look good and align with the PR objectives. The new selectors seem more robust to potential UI changes.

Consider adding a short wait between the two click actions to ensure the UI has time to respond:

async createChannelButton() {
    await this.page.click('.square-button > .ng-fa-icon');
    await this.page.waitForTimeout(100); // Add a short wait
    await this.page.click('text=Create channel');
}

28-31: Approved with a suggestion for error handling.

The changes to browseChannelsButton method look good. The method is now asynchronous and uses more specific selectors, which should improve reliability.

Consider adding error handling to make the test more robust:

async browseChannelsButton() {
    try {
        await this.page.locator('.btn-primary.btn-sm.square-button').click();
        await this.page.locator('button', { hasText: 'Browse Channels' }).click();
    } catch (error) {
        console.error('Error in browseChannelsButton:', error);
        throw error; // Re-throw the error to fail the test
    }
}

291-294: Approved with a suggestion for consistency.

The changes to createGroupChatButton method look good and align with the PR objectives. The new selectors are more specific and should improve test reliability.

For consistency with the createChannelButton method, consider using the text= selector for the second click:

async createGroupChatButton() {
    await this.page.locator('.btn-primary.btn-sm.square-button').click();
    await this.page.click('text=Create Group Chat');
}

This makes the selector more resilient to changes in the button's attributes while maintaining the intended functionality.

src/test/playwright/e2e/course/CourseMessages.spec.ts (3)

110-111: Approved changes with a suggestion for clarity

The simplification of the browseChannelsButton call and the update to the expected channel name are consistent with the PR objectives and the new naming conventions.

Consider adding a comment explaining the expected channel naming convention for lectures, to improve clarity for future maintainers. For example:

// Channel names for lectures are expected to be in the format 'test-<lecture_name>'
await courseMessages.checkChannelsExists('test-lecture');

118-119: Approved changes with a suggestion for consistency

The simplification of the browseChannelsButton call and the update to the expected channel name for exercises are consistent with the PR objectives and the new naming conventions.

For consistency with the previous suggestion, consider adding a comment explaining the expected channel naming convention for exercises:

// Channel names for exercises are expected to be in the format 'test-<exercise_name>'
await courseMessages.checkChannelsExists('test-exercise');

190-190: Final simplified browseChannelsButton call approved

The simplification of the browseChannelsButton call in this test case is consistent with all previous changes and completes the implementation of the PR objective.

These changes collectively improve the test suite by:

  1. Simplifying the browseChannelsButton method calls across all test cases.
  2. Updating expected channel names to align with new naming conventions.
  3. Enhancing code consistency and maintainability.

Consider updating the documentation for the browseChannelsButton method in the CourseMessagesPage class to reflect its new usage without specific channel type arguments.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7a14167 and f22616b.

📒 Files selected for processing (2)
  • src/test/playwright/e2e/course/CourseMessages.spec.ts (5 hunks)
  • src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (5)
src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts (1)

Line range hint 1-380: Overall assessment: Changes look good and align with PR objectives.

The modifications to createChannelButton, browseChannelsButton, and createGroupChatButton methods improve the robustness and reliability of the test suite. These changes address the issues with end-to-end tests caused by recent changes in the sidebar design, as mentioned in the PR objectives.

Key improvements:

  1. More specific and reliable selectors are now used.
  2. The browseChannelsButton method has been simplified and made asynchronous.
  3. The changes are consistent across the modified methods.

Minor suggestions have been made for each method to further enhance error handling, timing, and consistency. These suggestions, if implemented, would make the tests even more robust and maintainable.

src/test/playwright/e2e/course/CourseMessages.spec.ts (4)

35-35: Simplified browseChannelsButton call approved

The removal of the specific channel type argument from the browseChannelsButton call aligns with the PR objective and simplifies the code. This change enhances maintainability and readability.


127-127: Simplified browseChannelsButton call approved

The removal of the specific channel type argument from the browseChannelsButton call is consistent with previous changes and aligns with the PR objectives. This change contributes to the overall simplification and maintainability of the test suite.


166-166: Simplified browseChannelsButton call approved

The simplification of the browseChannelsButton call in this test case is consistent with previous changes and supports the PR's goal of updating the function to work without specific channel type arguments. This change contributes to the overall improvement in code consistency and maintainability.


Line range hint 1-424: Summary of changes and final recommendations

The changes in this file successfully address the PR objectives by simplifying the browseChannelsButton method calls and updating expected channel names. These modifications should resolve the test failures caused by recent changes in the sidebar design.

To ensure the changes have fully resolved the issues:

  1. Run the entire test suite to verify that all tests pass with the new implementation.
  2. Consider adding a test case that specifically checks the functionality of the new "Create Channel" and "Browse Channel" buttons in the sidebar.

Here's a script to run the tests and check for any remaining failures:

This script will help verify that the changes have resolved the failing tests and that no new issues have been introduced.

Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@pzdr7 pzdr7 left a comment

Choose a reason for hiding this comment

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

Some small comments on the code

Comment on lines -28 to +30
browseChannelsButton(channelGroup: string) {
return this.page.locator(`#plusButton-${channelGroup}`);
async browseChannelsButton() {
await this.page.locator('.btn-primary.btn-sm.square-button').click();
await this.page.locator('button', { hasText: 'Browse Channels' }).click();
Copy link
Contributor

Choose a reason for hiding this comment

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

The method name is not super intuitive to me - I'd expect the method to return a locator to the browse button (like it did in the old implementation). Could we rename it to openBrowseChannelModal or something similar?

Comment on lines 18 to 20
* Clicks the button to initiate channel creation.
*/
async createChannelButton() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest the name openChannelCreation here

Comment on lines 291 to +293
async createGroupChatButton() {
await this.page.locator('#plusButton-groupChats').click();
await this.page.locator('.btn-primary.btn-sm.square-button').click();
await this.page.locator('button', { hasText: 'Create Group Chat' }).click();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe openGroupChatCreation?

@@ -18,15 +18,16 @@ export class CourseMessagesPage {
* Clicks the button to initiate channel creation.
*/
async createChannelButton() {
await this.page.locator('#plusButton-generalChannels').click();
await this.page.locator('.modal-content #createChannel').click();
await this.page.click('.square-button > .ng-fa-icon');
Copy link
Contributor

Choose a reason for hiding this comment

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

As I see it, all three buttons (create channel, browse channels, create group chat) are under the same menu and can be accessed via the same button.

Why do you use this.page.click('.square-button > .ng-fa-icon'); here but this.page.locator('.btn-primary.btn-sm.square-button').click() in the other methods? Could we simply assign an ID to the button that opens the dropdown and use that to find it?

Copy link
Member

@krusche krusche left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the e2e tests.
I suggest to improve the code according to @pzdr7’s feedback in a follow up so that the tests pass on develop again and do not disturb any other PRs

@krusche krusche merged commit 9d8b398 into develop Oct 20, 2024
41 of 47 checks passed
@krusche krusche deleted the bugfix/fix-broken-channel-e2e-tests branch October 20, 2024 20:26
SimonEntholzer pushed a commit that referenced this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants