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

feat(game-lobby): player group organizer #893

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

antoinezanardi
Copy link
Owner

@antoinezanardi antoinezanardi commented Sep 19, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new "Group Organizer" button in the game lobby header, enhancing user interactivity.
    • Updated game composition logic to allow for a broader range of roles, increasing gameplay diversity.
  • Bug Fixes

    • Improved visibility logic for the group organizer button based on player roles.
  • UI Enhancements

    • Updated icons for better visual representation of functionalities.
    • Added responsive design elements to improve user experience across devices.
  • Localization

    • Added English and French translations for the "Group Organizer" button.
  • Tests

    • Expanded test coverage for the new group organizer button, ensuring proper functionality and event emissions.

@antoinezanardi antoinezanardi added the 🚀 feature New feature or request label Sep 19, 2024
@antoinezanardi antoinezanardi self-assigned this Sep 19, 2024
Copy link

coderabbitai bot commented Sep 19, 2024

Walkthrough

The changes in this pull request introduce several enhancements to the game lobby components, including the addition of a group organizer button, modifications to existing buttons, and updates to icons. Key functionalities such as event emissions and visibility logic are implemented to improve user interaction. Additionally, localization support is expanded for both English and French languages, and unit tests are added to ensure the reliability of the new features.

Changes

Files Change Summary
app/components/pages/game-lobby/GameLobbyFooter/GameLobbyRandomCompositionButton/GameLobbyRandomCompositionButton.vue Removed the excludedRoles parameter from the fetchRandomGameComposition function call, allowing the inclusion of the "prejudiced-manipulator" role in game compositions.
app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeader.vue Added a new event handler for the group organizer button, enhancing interactivity.
app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/GameLobbyHeaderGroupOrganizerButton.vue Introduced a new button component for group organizers, featuring visual feedback and conditional rendering based on player group status.
app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/game-lobby-header-group-organizer-button.types.ts Defined a new TypeScript type for emitted events from the group organizer button.
app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderPositionCoordinatorButton/GameLobbyHeaderPositionCoordinatorButton.vue Updated the button icon from "users" to "group-arrows-rotate" to better convey functionality.
app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderSetupButtons.vue Integrated the group organizer button with visibility logic based on player roles and added an event handler for its click event.
app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/game-lobby-header-setup-buttons.types.ts Added a new event type for the group organizer button's click event.
app/components/pages/game-lobby/GameLobbyHeader/game-lobby-header.types.ts Added a new event type for the group organizer button's click event.
app/pages/game-lobby.vue Introduced a new event handler for the group organizer button click event, currently logging a message to the console.
app/plugins/vue-font-awesome-icon/vue-font-awesome-icon.ts Added a new Font Awesome icon for use in the application.
modules/i18n/locales/en.json Added a localization entry for the group organizer button in English.
modules/i18n/locales/fr.json Added a localization entry for the group organizer button in French.
tests/unit/specs/components/pages/game-lobby/GameLobbyFooter/GameLobbyRandomCompositionButton/GameLobbyRandomCompositionButton.nuxt.spec.ts Modified the test to reflect the removal of the excludedRoles parameter in the fetchRandomGameComposition method call.
tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeader.nuxt.spec.ts Added a test case to verify the emission of the groupOrganizerButtonClick event.
tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/GameLobbyHeaderGroupOrganizerButton.nuxt.spec.ts Introduced tests for the new group organizer button, covering rendering, icon visibility, translation, and event emission.
tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderSetupButtons.nuxt.spec.ts Added tests for the group organizer button's rendering logic and event emission based on player roles.
tests/unit/utils/factories/composables/api/game/dto/create-game/create-game-player/create-game-player.dto.factory.ts Simplified the assignment logic for the group property in the createFakeCreateGamePlayerDto function.

Possibly related PRs

Poem

In the game lobby, a button does gleam,
For group organizers, it fulfills a dream.
With roles now included, the fun will ignite,
A click here, a click there, all feels just right!
So hop along, players, let’s gather and play,
With new features in place, it’s a wonderful day! 🐇✨


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 846baa2 and 00599d9.

Files selected for processing (2)
  • modules/i18n/locales/en.json (1 hunks)
  • modules/i18n/locales/fr.json (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • modules/i18n/locales/en.json
  • modules/i18n/locales/fr.json

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 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.

Tip

Early access features: enabled

We are currently testing new code review model(s) that may lead to higher noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

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: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 36cce97 and 846baa2.

Files ignored due to path filters (2)
  • tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/__snapshots__/GameLobbyHeaderGroupOrganizerButton.nuxt.spec.ts.snap is excluded by !**/*.snap
  • tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/__snapshots__/GameLobbyHeaderSetupButtons.nuxt.spec.ts.snap is excluded by !**/*.snap
Files selected for processing (18)
  • app/components/pages/game-lobby/GameLobbyFooter/GameLobbyRandomCompositionButton/GameLobbyRandomCompositionButton.vue (0 hunks)
  • app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeader.vue (2 hunks)
  • app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/GameLobbyHeaderGroupOrganizerButton.vue (1 hunks)
  • app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/game-lobby-header-group-organizer-button.types.ts (1 hunks)
  • app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderPositionCoordinatorButton/GameLobbyHeaderPositionCoordinatorButton.vue (1 hunks)
  • app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderSetupButtons.vue (5 hunks)
  • app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/game-lobby-header-setup-buttons.types.ts (1 hunks)
  • app/components/pages/game-lobby/GameLobbyHeader/game-lobby-header.types.ts (1 hunks)
  • app/components/pages/game-lobby/GameLobbyPositionCoordinator/GameLobbyPositionCoordinator.vue (1 hunks)
  • app/pages/game-lobby.vue (2 hunks)
  • app/plugins/vue-font-awesome-icon/vue-font-awesome-icon.ts (2 hunks)
  • modules/i18n/locales/en.json (1 hunks)
  • modules/i18n/locales/fr.json (1 hunks)
  • tests/unit/specs/components/pages/game-lobby/GameLobbyFooter/GameLobbyRandomCompositionButton/GameLobbyRandomCompositionButton.nuxt.spec.ts (0 hunks)
  • tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeader.nuxt.spec.ts (1 hunks)
  • tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/GameLobbyHeaderGroupOrganizerButton.nuxt.spec.ts (1 hunks)
  • tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderSetupButtons.nuxt.spec.ts (3 hunks)
  • tests/unit/utils/factories/composables/api/game/dto/create-game/create-game-player/create-game-player.dto.factory.ts (1 hunks)
Files not reviewed due to no reviewable changes (2)
  • app/components/pages/game-lobby/GameLobbyFooter/GameLobbyRandomCompositionButton/GameLobbyRandomCompositionButton.vue
  • tests/unit/specs/components/pages/game-lobby/GameLobbyFooter/GameLobbyRandomCompositionButton/GameLobbyRandomCompositionButton.nuxt.spec.ts
Files skipped from review due to trivial changes (5)
  • app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/game-lobby-header-group-organizer-button.types.ts
  • app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderPositionCoordinatorButton/GameLobbyHeaderPositionCoordinatorButton.vue
  • app/components/pages/game-lobby/GameLobbyPositionCoordinator/GameLobbyPositionCoordinator.vue
  • modules/i18n/locales/fr.json
  • tests/unit/utils/factories/composables/api/game/dto/create-game/create-game-player/create-game-player.dto.factory.ts
Additional context used
GitHub Check: Lint 🔍
app/pages/game-lobby.vue

[failure] 122-122:
Unexpected console statement

Additional comments not posted (24)
app/components/pages/game-lobby/GameLobbyHeader/game-lobby-header.types.ts (1)

5-5: LGTM!

The addition of the groupOrganizerButtonClick event type to the GameLobbyHeaderEmits interface is a clear and concise way to define the new event that the GameLobbyHeader component can emit. This change aligns with the PR objectives and title, which indicate the introduction of a new "player group organizer" feature.

Ensure that:

  1. The corresponding button is added to the component's template.
  2. The event is emitted correctly when the button is clicked.
  3. The necessary event handlers are implemented to handle the emitted event and update the relevant state or trigger the appropriate actions.

Overall, this change sets the foundation for the new feature and suggests an enhancement to the user experience and engagement within the game lobby.

app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/game-lobby-header-setup-buttons.types.ts (1)

5-5: LGTM!

The new event type groupOrganizerButtonClick is correctly added to the GameLobbyHeaderSetupButtonsEmits type, following the existing naming convention.

Please ensure that:

  1. The corresponding event handler is correctly implemented to handle this new event.
  2. The actual implementation of the group organizer button is correctly added to the component template and emits this event when clicked.
app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/GameLobbyHeaderGroupOrganizerButton.vue (3)

1-28: LGTM!

The template section of the component is well-structured and follows best practices:

  • The usage of the PrimeVue button component with custom props and event is correct.
  • The FontAwesome icons are used appropriately for visual feedback.
  • The conditional rendering of the button text based on screen size is a good practice for responsive design.
  • The warning icon is correctly shown based on a computed property.

30-47: LGTM!

The script section of the component is well-structured and follows best practices:

  • The imports are correctly used.
  • The usage of defineEmits is correct for defining the component emits.
  • The usage of Pinia store for state management is a good practice.
  • The computed property for validation is correctly defined.
  • The method to emit the custom event is correctly defined.

1-47: Skipped reviewing the style section.

The component does not have any custom styles defined. This is acceptable as the component is using PrimeVue and FontAwesome libraries for styling.

app/plugins/vue-font-awesome-icon/vue-font-awesome-icon.ts (2)

79-79: LGTM!

The import statement for the new icon faGroupArrowsRotate is correct.


166-166: LGTM!

The newly imported icon faGroupArrowsRotate has been correctly added to the icon library.

tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderGroupOrganizerButton/GameLobbyHeaderGroupOrganizerButton.nuxt.spec.ts (5)

45-48: LGTM!

The snapshot test case is well-written and ensures that the component's structure doesn't change unexpectedly.


51-55: LGTM!

The test case correctly verifies that the warning icon is displayed when player groups are not set.


57-69: LGTM!

The test case correctly verifies that the warning icon is not displayed when player groups are set.


71-75: LGTM!

The test case correctly verifies that the button text is translated as expected.


77-82: LGTM!

The test case correctly verifies that the groupOrganizerButtonClick event is emitted when the button is clicked.

app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeader.vue (2)

31-31: LGTM!

The event handler is correctly bound to the method following the component's naming convention.


89-91: LGTM!

The method implementation is correct and follows the component's event emission pattern and naming convention.

app/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderSetupButtons.vue (3)

32-39: LGTM!

The GameLobbyHeaderGroupOrganizerButton component is correctly integrated into the template. The conditional rendering using the isGroupOrganizerVisible computed property and the event emission using @group-organizer-button-click follow the existing patterns and conventions in the component.


49-49: LGTM!

The GameLobbyHeaderGroupOrganizerButton component is correctly imported and used in the template.


58-58: LGTM!

The isGroupOrganizerVisible computed property correctly determines the visibility of the group organizer button based on the presence of players with the "prejudiced-manipulator" role. The onGroupOrganizerButtonClickFromGameGroupOrganizerButton method follows the component's conventions and correctly emits the groupOrganizerButtonClick event.

Also applies to: 75-76, 89-92

app/pages/game-lobby.vue (1)

8-8: LGTM!

The event handler is correctly bound to the onGroupOrganizerButtonClickFromGameLobbyHeader function.

tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeaderSetupButtons/GameLobbyHeaderSetupButtons.nuxt.spec.ts (4)

12-12: LGTM!

The import statement for the GameLobbyHeaderGroupOrganizerButton component is correct and necessary for the new tests.


35-35: LGTM!

Adding a player with the "prejudiced-manipulator" role to the default game setup is necessary for testing the group organizer button's rendering conditions.


39-42: Verify the impact of setting stubActions to false.

Setting stubActions to false in the testing Pinia store means that Pinia actions will not be stubbed during tests. This change may affect how actions are handled in the test suite.

Please ensure that this change does not introduce any unintended side effects or break existing tests.


154-173: LGTM!

The new test cases for the "Group Organizer" button are well-written and cover important scenarios:

  1. Verifying that the button is not rendered when the "prejudiced-manipulator" player is absent.
  2. Checking that the button emits the correct event when clicked.

These tests ensure that the button behaves as expected based on the game state and user interactions.

tests/unit/specs/components/pages/game-lobby/GameLobbyHeader/GameLobbyHeader.nuxt.spec.ts (1)

216-222: LGTM!

The test case follows the established pattern and correctly verifies the emission of the groupOrganizerButtonClick event when the corresponding button is clicked. It enhances the test coverage and robustness of the component.

modules/i18n/locales/en.json (1)

1614-1615: LGTM!

The addition of the "groupOrganizer" key-value pair in the "GameLobbyHeaderGroupOrganizerButton" section follows the existing JSON structure and provides the necessary English translation for the "Group organizer" button.

Comment on lines +121 to +123
function onGroupOrganizerButtonClickFromGameLobbyHeader(): void {
console.log("coucou");
}
Copy link

Choose a reason for hiding this comment

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

Remove the console statement and implement the actual functionality.

The console statement is likely a placeholder for the actual implementation. Please remove it and implement the intended functionality for the onGroupOrganizerButtonClickFromGameLobbyHeader function.

Do you want me to open a GitHub issue to track this task or provide suggestions for the implementation?

Tools
GitHub Check: Lint 🔍

[failure] 122-122:
Unexpected console statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant