-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(audio): audio settings in local storage (#831)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced audio settings management with persistent mute state across sessions. - Added acceptance tests to validate audio functionality and user interactions. - Enhanced the Mute Button component with improved animation logic. - **Bug Fixes** - Ensured audio settings are correctly restored after a page reload. - **Tests** - Expanded test coverage for audio-related functionalities, including new test cases for the audio store and Mute Button interactions. - **Documentation** - Updated feature files to include scenarios for audio control interactions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
1 parent
1357529
commit cd8a2cb
Showing
13 changed files
with
66,623 additions
and
65,158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Audio" type="cucumber.js" factoryName="Cucumber.js" folderName="Tags"> | ||
<option name="myFilePath" value="$PROJECT_DIR$/tests/acceptance" /> | ||
<option name="myNameFilter" value="" /> | ||
<option name="cucumberJsArguments" value="--config config/cucumber/cucumber.json --parallel 1 --tags @audio" /> | ||
<option name="workingDirectory" value="$PROJECT_DIR$" /> | ||
<envs> | ||
<env name="NODE_OPTIONS" value="--import tsx/esm" /> | ||
</envs> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import type { TupleToUnion } from "type-fest"; | ||
import type { BACKGROUND_AUDIO_NAMES, SOUND_EFFECT_NAMES } from "~/stores/audio/constants/audio.constants"; | ||
|
||
type AudioSettings = { | ||
isMuted: boolean; | ||
}; | ||
|
||
type SoundEffectName = TupleToUnion<typeof SOUND_EFFECT_NAMES>; | ||
|
||
type BackgroundAudioName = TupleToUnion<typeof BACKGROUND_AUDIO_NAMES>; | ||
|
||
export type { | ||
AudioSettings, | ||
SoundEffectName, | ||
BackgroundAudioName, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
enum LocalStorageKeys { | ||
GAME_OPTIONS = "gameOptions", | ||
AUDIO_SETTINGS = "audioSettings", | ||
} | ||
|
||
export { LocalStorageKeys }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@audio | ||
@shard-3 | ||
Feature: 🔊 Audio | ||
|
||
Scenario: 🔊 Audio is playing by default in game and can be disabled | ||
Given the user creates a game with the players with name and role | ||
| name | role | | ||
| Antoine | Seer | | ||
| Bob | Werewolf | | ||
| Charlie | Idiot | | ||
| David | Villager | | ||
|
||
When the user hovers the button with name "Mute" | ||
Then the tooltip with text "Mute" should be visible | ||
|
||
When the user mutes the audio in navigation bar | ||
And the user moves his mouse away | ||
And the user hovers the button with name "Unmute" | ||
Then the tooltip with text "Unmute" should be visible | ||
|
||
Scenario: 🔊 Audio settings are saved and restored from local storage | ||
Given the user creates a game with the players with name and role | ||
| name | role | | ||
| Antoine | Seer | | ||
| Bob | Werewolf | | ||
| Charlie | Idiot | | ||
| David | Villager | | ||
And the user mutes the audio in navigation bar | ||
|
||
When the user reloads the page | ||
And the user hovers the button with name "Unmute" | ||
Then the tooltip with text "Unmute" should be visible |
11 changes: 11 additions & 0 deletions
11
tests/acceptance/features/audio/step-definitions/audio.when-steps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { When } from "@cucumber/cucumber"; | ||
import { clickOnRoleWithText } from "@tests/acceptance/features/playwright/helpers/roles/playwright-roles.when-steps-helpers"; | ||
import type { CustomWorld } from "@tests/acceptance/shared/types/word.types"; | ||
|
||
When(/^the user mutes the audio in navigation bar$/u, async function(this: CustomWorld): Promise<void> { | ||
await clickOnRoleWithText(this, "button", "Mute", true); | ||
}); | ||
|
||
When(/^the user unmutes the audio in navigation bar$/u, async function(this: CustomWorld): Promise<void> { | ||
await clickOnRoleWithText(this, "button", "Unmute", true); | ||
}); |
Oops, something went wrong.