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): confirm before leaving #738

Merged
merged 3 commits into from
Aug 12, 2024

Conversation

antoinezanardi
Copy link
Owner

@antoinezanardi antoinezanardi commented Aug 12, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a confirmation dialog when users attempt to leave a game, enhancing the user experience.
    • Added new sections to the README with examples for gameplay scenarios.
    • Updated the layout of the game interface for improved responsiveness.
  • Bug Fixes

    • Added localization entries for English and French to provide appropriate prompts during the game.
  • Documentation

    • Expanded the README to include new gameplay examples.
  • Tests

    • Created acceptance and unit tests for the new confirmation dialog functionality.

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

coderabbitai bot commented Aug 12, 2024

Walkthrough

The update enhances the game-playing experience by introducing a confirmation dialog that prompts users before they leave a game in progress. This change improves user interaction with clearer messaging, supported by localization in both English and French. Additionally, adjustments in styling and layout create a more responsive interface, while comprehensive unit tests ensure the robustness of the new features.

Changes

Files Change Summary
.run/Game Playing.run.xml Introduced a configuration for Cucumber.js tests related to game playing, specifying execution parameters.
README.md Added documentation for the "Stuttering Judge Requests Another Vote" scenario with an image link.
app/components/pages/game/GamePlaying.vue Modified layout for responsiveness; added a confirmation dialog component for when users attempt to leave a game.
app/components/pages/game/GamePlayingBeforeLeaveConfirmDialog.vue Created a dialog component prompting users to confirm before leaving a game, utilizing PrimeVue functionality.
modules/i18n/locales/en.json Included new localization entries for confirmation dialog prompts in English.
modules/i18n/locales/fr.json Added French translations for confirmation dialog prompts.
tests/acceptance/features/game/features/game-playing/game-playing.feature Introduced acceptance criteria for user confirmation when leaving a game in progress.
tests/unit/specs/components/pages/game/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.nuxt.spec.ts New test suite for the confirmation dialog component, covering interaction and callback logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GamePlaying
    participant ConfirmDialog

    User->>GamePlaying: Attempts to leave game
    GamePlaying->>ConfirmDialog: Open confirmation dialog
    ConfirmDialog->>User: Show confirmation options (Leave/Stay)
    User->>ConfirmDialog: Selects Leave
    ConfirmDialog->>GamePlaying: Confirm leaving
    GamePlaying->>User: Exit game
Loading

🌟 In the land of games where players play,
A dialog now asks, "Will you stay?"
With a hop and a skip, choices to make,
"Leave or stay, for friendship's sake!"
So here's to the change, so bright and new,
A joyful leap, for all of you! 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

Outside diff range, codebase verification and nitpick comments (2)
app/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.vue (2)

14-16: Consider initializing reactive variables with default values.

The reactive variables desiredDestinationFullPath and doesConfirmToLeave are initialized without default values. Consider setting default values for clarity and to avoid potential undefined behavior.

- const desiredDestinationFullPath = ref<string>("");
- const doesConfirmToLeave = ref<boolean>(false);
+ const desiredDestinationFullPath = ref<string>("");
+ const doesConfirmToLeave = ref<boolean>(false);

27-41: Localization keys are missing in the localization files.

The localization keys used in the confirmRequire call are not found in the localization files. Ensure that these keys are defined to prevent potential runtime errors:

  • components.GamePlayingBeforeLeaveConfirmDialog.gameIsStillPlaying
  • components.GamePlayingBeforeLeaveConfirmDialog.doYouWantToLeaveGame
  • components.GamePlayingBeforeLeaveConfirmDialog.iWantToLeave
  • components.GamePlayingBeforeLeaveConfirmDialog.stayInGame
Analysis chain

Verify localization keys exist.

Ensure that the localization keys used in the confirmRequire call exist in the localization files to prevent runtime errors.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of localization keys in the localization files.

# Test: Search for localization keys in the localization files. Expect: Keys to be defined.
rg --type json $'components.GamePlayingBeforeLeaveConfirmDialog.gameIsStillPlaying'
rg --type json $'components.GamePlayingBeforeLeaveConfirmDialog.doYouWantToLeaveGame'
rg --type json $'components.GamePlayingBeforeLeaveConfirmDialog.iWantToLeave'
rg --type json $'components.GamePlayingBeforeLeaveConfirmDialog.stayInGame'

Length of output: 96939

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6840ebd and 8d2321b.

Files ignored due to path filters (2)
  • tests/unit/specs/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/__snapshots__/GamePlayingBeforeLeaveConfirmDialog.nuxt.spec.ts.snap is excluded by !**/*.snap
  • tests/unit/specs/components/pages/game/GamePlaying/__snapshots__/GamePlaying.nuxt.spec.ts.snap is excluded by !**/*.snap
Files selected for processing (9)
  • .run/Game Playing.run.xml (1 hunks)
  • README.md (1 hunks)
  • app/components/pages/game/GamePlaying/GamePlaying.vue (3 hunks)
  • app/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.vue (1 hunks)
  • config/tailwind/tailwind.config.ts (1 hunks)
  • modules/i18n/locales/en.json (1 hunks)
  • modules/i18n/locales/fr.json (1 hunks)
  • tests/acceptance/features/game/features/game-playing/game-playing.feature (1 hunks)
  • tests/unit/specs/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.nuxt.spec.ts (1 hunks)
Additional context used
Markdownlint
README.md

202-202: null
Multiple spaces after blockquote symbol

(MD027, no-multiple-space-blockquote)


204-204: null
Multiple spaces after blockquote symbol

(MD027, no-multiple-space-blockquote)


205-205: null
Multiple spaces after blockquote symbol

(MD027, no-multiple-space-blockquote)


206-206: null
Multiple spaces after blockquote symbol

(MD027, no-multiple-space-blockquote)

Additional comments not posted (18)
.run/Game Playing.run.xml (1)

1-12: Configuration looks good.

The run configuration for Cucumber.js is set up correctly with appropriate options and environment variables.

config/tailwind/tailwind.config.ts (1)

22-22: Spacing addition approved.

The new "2/3" spacing value is a useful addition for more flexible layout options.

tests/acceptance/features/game/features/game-playing/game-playing.feature (1)

1-26: Feature file is well-structured.

The scenario effectively covers the user interaction for confirming game exit, ensuring clarity and completeness.

app/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.vue (2)

2-5: Ensure the dialog ID and group are unique and descriptive.

The id and group attributes for the PrimeVueConfirmDialog should be unique and descriptive to prevent conflicts with other dialogs.

Verification successful

The dialog ID and group are unique and descriptive.

The id and group attributes for the PrimeVueConfirmDialog are unique within the codebase, addressing the concern about potential conflicts with other dialogs. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the uniqueness of the dialog ID and group across the codebase.

# Test: Search for the dialog ID and group usage. Expect: No duplicate occurrences.
rg --type vue $'id="game-playing-before-leave-confirm-dialog"'
rg --type vue $'group="game-playing-before-leave-confirm-dialog"'

Length of output: 186


Script:

#!/bin/bash
# Description: Verify the uniqueness of the dialog ID and group across the codebase.

# Test: Search for the dialog ID and group usage in Vue files. Expect: No duplicate occurrences.
rg 'id="game-playing-before-leave-confirm-dialog"' --glob '*.vue'
rg 'group="game-playing-before-leave-confirm-dialog"' --glob '*.vue'

Length of output: 469


43-53: Ensure onBeforeRouteLeave is correctly set up.

Verify that onBeforeRouteLeave is correctly set up and that any potential side effects of blocking navigation are handled appropriately.

Verification successful

onBeforeRouteLeave is correctly set up and side effects are managed.

The implementation of onBeforeRouteLeave in both GameLobbyBeforeLeaveConfirmDialog.vue and GamePlayingBeforeLeaveConfirmDialog.vue files includes logic to handle navigation blocking through confirmation dialogs. The potential side effects are managed by storing the desired destination and prompting the user to confirm before proceeding. This setup appears to be appropriate.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the setup of `onBeforeRouteLeave` and check for potential side effects.

# Test: Search for `onBeforeRouteLeave` setup and usage. Expect: Proper setup without side effects.
rg --type vue $'onBeforeRouteLeave'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify the setup of `onBeforeRouteLeave` and check for potential side effects.

# Test: Search for `onBeforeRouteLeave` setup and usage in .vue files.
rg 'onBeforeRouteLeave' --glob '*.vue' -A 5

Length of output: 594


Script:

#!/bin/bash
# Description: Check for handling of side effects related to blocking navigation in the relevant Vue files.

# Test: Search for handling of side effects or additional logic in GameLobbyBeforeLeaveConfirmDialog.vue and GamePlayingBeforeLeaveConfirmDialog.vue.
rg 'desiredDestinationFullPath|open|doesConfirmToLeave' app/components/pages/game-lobby/GameLobbyBeforeLeaveConfirmDialog/GameLobbyBeforeLeaveConfirmDialog.vue -A 5
rg 'desiredDestinationFullPath|open|doesConfirmToLeave' app/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.vue -A 5

Length of output: 2005

app/components/pages/game/GamePlaying/GamePlaying.vue (3)

43-43: Import statement is correct.

The import statement for GamePlayingBeforeLeaveConfirmDialog is correct and ensures the component is available for use in the template.


12-12: Enhance layout responsiveness.

The addition of !max-w-2/3 improves layout responsiveness. Ensure this change aligns with the overall design and does not introduce layout issues on different screen sizes.


35-35: Ensure component integration.

The GamePlayingBeforeLeaveConfirmDialog component is integrated into the template. Verify its functionality and interaction with other components.

Verification successful

Component Integration Verified

The GamePlayingBeforeLeaveConfirmDialog component is correctly imported and used in the GamePlaying.vue file. The integration appears proper in terms of both import and template usage.

  • Import Statement: The component is imported from its expected path, confirming its integration.
  • Template Usage: The component is used within the template, indicating it is part of the component's structure.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration and interaction of `GamePlayingBeforeLeaveConfirmDialog`.

# Test: Search for the component usage and ensure it functions correctly.
rg --type vue $'<GamePlayingBeforeLeaveConfirmDialog'

Length of output: 82


Script:

#!/bin/bash
# Search for the import statement of `GamePlayingBeforeLeaveConfirmDialog` in Vue files
ast-grep --lang vue --pattern 'import GamePlayingBeforeLeaveConfirmDialog from $_' 

# Search for the usage of `GamePlayingBeforeLeaveConfirmDialog` in Vue files
rg '<GamePlayingBeforeLeaveConfirmDialog' --glob '*.vue' -A 5

Length of output: 706


Script:

#!/bin/bash
# Search for the import statement of `GamePlayingBeforeLeaveConfirmDialog` in the GamePlaying.vue file
rg 'import GamePlayingBeforeLeaveConfirmDialog' app/components/pages/game/GamePlaying/GamePlaying.vue -A 5

Length of output: 569

tests/unit/specs/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.nuxt.spec.ts (5)

1-11: Ensure all dependencies are correctly imported.

The necessary dependencies are imported for testing the component. Ensure all mocks and utilities are correctly set up.


52-55: Snapshot test is correctly implemented.

The snapshot test ensures the component renders as expected. Verify that the snapshot is up-to-date and reflects the current component state.


57-89: Comprehensive route leaving tests.

The tests for route leaving logic are comprehensive and cover different scenarios. Ensure that all edge cases are considered.


92-127: Confirmation dialog tests are thorough.

The tests for the confirmation dialog interactions are thorough and validate the expected behavior. Ensure that all dialog options and callbacks are tested.


20-27: Verify mock setup for useRouter.

The mock setup for useRouter should correctly simulate the router behavior. Ensure that the mock functions are used as expected in the tests.

Verification successful

Mock setup for useRouter is correctly implemented and verified.

The test cases in GamePlayingBeforeLeaveConfirmDialog.nuxt.spec.ts effectively utilize the useRouter mock, particularly verifying the push method's behavior. This confirms that the mock setup simulates the router behavior as expected in the tests.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the mock setup for `useRouter`.

# Test: Search for `useRouter` mock usage and ensure it aligns with the expected behavior.
rg --type ts $'useRouter'

Length of output: 2282


Script:

#!/bin/bash
# Description: Search for test cases in GamePlayingBeforeLeaveConfirmDialog.nuxt.spec.ts to verify the usage of the useRouter mock.

# Test: Extract test cases to check how useRouter is being used and asserted in the tests.
rg --type ts -A 10 'describe|it' tests/unit/specs/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.nuxt.spec.ts

Length of output: 5512

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

1509-1513: New localization entries are clear and consistent.

The added entries for "GamePlayingBeforeLeaveConfirmDialog" are well-structured and align with the existing localization format.

modules/i18n/locales/fr.json (4)

1510-1510: Translation Approved: "gameIsStillPlaying".

The translation "La partie est toujours en cours" accurately conveys the intended message.


1511-1511: Translation Approved: "doYouWantToLeaveGame".

The translation "Êtes-vous sûr de vouloir quitter le jeu ?" is accurate and clear.


1512-1512: Translation Approved: "iWantToLeave".

The translation "Oui, je veux partir" is accurate and appropriate for the context.


1513-1513: Translation Approved: "stayInGame".

The translation "Rester dans le jeu" accurately reflects the intended meaning.

Copy link

sonarcloud bot commented Aug 12, 2024

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8d2321b and ecadd88.

Files ignored due to path filters (1)
  • tests/acceptance/screenshots/linux/Stuttering Judge Requests Another Vote Playground.png is excluded by !**/*.png
Files selected for processing (4)
  • app/components/pages/game-lobby/GameLobbyBeforeLeaveConfirmDialog/GameLobbyBeforeLeaveConfirmDialog.vue (2 hunks)
  • app/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.vue (1 hunks)
  • app/composables/prime-vue/constants/prime-vue.constants.ts (1 hunks)
  • tests/unit/specs/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.nuxt.spec.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.vue
  • tests/unit/specs/components/pages/game/GamePlaying/GamePlayingBeforeLeaveConfirmDialog/GamePlayingBeforeLeaveConfirmDialog.nuxt.spec.ts
Additional comments not posted (4)
app/composables/prime-vue/constants/prime-vue.constants.ts (2)

1-7: Good use of as const for immutability.

Marking DEFAULT_PRIME_VUE_TOAST_OPTIONS as const enhances type safety and ensures that the options remain immutable.


9-15: Centralized dialog options improve maintainability.

The introduction of DEFAULT_CONFIRM_DIALOG_OPTIONS centralizes the configuration for confirmation dialogs, making it easier to manage and update these settings across the application.

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

12-12: Importing default options enhances consistency.

Using DEFAULT_CONFIRM_DIALOG_OPTIONS ensures consistency across dialogs and makes future updates easier.


41-41: Efficient use of spread operator for dialog options.

The spread operator efficiently incorporates default options, improving maintainability and reducing redundancy in the open function.

@antoinezanardi antoinezanardi merged commit 3c71999 into develop Aug 12, 2024
15 checks passed
@antoinezanardi antoinezanardi deleted the feat/confirm-before-leaving-game branch August 12, 2024 15:26
antoinezanardi pushed a commit that referenced this pull request Aug 14, 2024
## [1.28.0](v1.27.0...v1.28.0) (2024-08-14)

### 🚀 Features

* **game-lobby:** additional cards placement in manager ([#733](#733)) ([dd08cf2](dd08cf2))
* **game-lobby:** confirm leaving lobby with players ([#736](#736)) ([dbad613](dbad613))
* **game:** confirm before leaving ([#738](#738)) ([3c71999](3c71999))
* **thief:** thief playground ([#723](#723)) ([953324f](953324f))
* **wild-child:** transformation event ([#740](#740)) ([ec1a20c](ec1a20c))

### ✅ Tests

* **angel:** acceptance tests ([#732](#732)) ([d7f5c8b](d7f5c8b))
* **stuttering-judge:** acceptance tests ([#737](#737)) ([6840ebd](6840ebd))

### 🧹 Chore

* **deps:** update dependency @cucumber/cucumber to ^10.9.0 ([#744](#744)) ([14339bd](14339bd))
* **deps:** update dependency @nuxt/test-utils to ^3.14.1 ([#743](#743)) ([e86d2be](e86d2be))
* **deps:** update dependency @stylistic/eslint-plugin to ^2.6.2 ([#731](#731)) ([467a0ff](467a0ff))
* **deps:** update dependency @vueuse/core to ^10.11.1 ([#729](#729)) ([efade62](efade62))
* **deps:** update dependency @vueuse/nuxt to ^10.11.1 ([#730](#730)) ([ee4389c](ee4389c))
* **deps:** update dependency eslint to ^9.9.0 ([#734](#734)) ([e0a15a8](e0a15a8))
* **deps:** update dependency lint-staged to ^15.2.9 ([#741](#741)) ([482a616](482a616))
* **deps:** update dependency tailwindcss to ^3.4.10 ([#745](#745)) ([7e9b755](7e9b755))
* **deps:** update dependency tailwindcss to ^3.4.9 ([#727](#727)) ([d4b2e2c](d4b2e2c))
* **deps:** update dependency tsx to ^4.17.0 ([#724](#724)) ([0536f2c](0536f2c))
* **deps:** update dependency type-fest to ^4.24.0 ([#726](#726)) ([9d025a7](9d025a7))
* **deps:** update dependency vue to ^3.4.37 ([#728](#728)) ([c9e29c2](c9e29c2))
* **deps:** update stryker-js monorepo to ^8.5.0 ([#735](#735)) ([f9e692c](f9e692c))
* **deps:** update typescript-eslint monorepo to ^8.1.0 ([#739](#739)) ([7630b11](7630b11))
* **font-awesome:** pass all icons to svg ([#742](#742)) ([ec4a660](ec4a660))
@antoinezanardi
Copy link
Owner Author

🎉 This PR is included in version 1.28.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

1 participant