Skip to content

feat: FM-967 QA Automation coverage for Replay level flow. (Playwrigh… - #2001

Open
ashwinnair-chimple wants to merge 1 commit into
developfrom
FM-967
Open

feat: FM-967 QA Automation coverage for Replay level flow. (Playwrigh…#2001
ashwinnair-chimple wants to merge 1 commit into
developfrom
FM-967

Conversation

@ashwinnair-chimple

@ashwinnair-chimple ashwinnair-chimple commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

…t+Claude)

Changes

  • Replay flow added to e2e Automation script

How to test

  • Run the automation scripts
  • After level completion on level end screen the e2e will trigger the replay functionality
  • Used SDD template to develop this feature @miguelccodev @janfb-codev @bernhardccodev (for spec file review)

Ref: FM-967

Summary by CodeRabbit

  • New Features

    • Added end-to-end coverage for replaying a completed level.
    • Replay now verifies that gameplay reloads with a fresh, interactive puzzle and remains on the correct level.
  • Tests

    • Expanded the full assessment flow to include the level replay scenario.
    • Improved timing around the Level End screen before selecting Replay.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The E2E assessment flow now runs through TC_017. TC_016 leaves the Level End screen open, and TC_017 replays Level 2, verifies fresh gameplay interaction, and confirms the level context.

Changes

Level replay E2E coverage

Layer / File(s) Summary
Replay timing and suite wiring
e2e/constants/timeouts.ts, e2e/tests/ftm-assessment-survey-flow.spec.ts
Adds a 2,000 ms replay settle delay and registers TC_017 in the serial assessment flow.
Level End handoff
e2e/tests/isolated/tc-016-level-completion.spec.ts
TC_016 no longer navigates to level selection. It leaves the Level End screen loaded.
Replay interaction validation
e2e/tests/isolated/tc-017-level-replay.spec.ts
TC_017 clicks Replay, waits for fresh gameplay, interacts with the puzzle, checks canvas content, and verifies Level 2 remains selected.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LevelEnd as Level End screen
  participant TC017 as TC_017 replay test
  participant Gameplay as Gameplay scene
  participant Canvas as Gameplay canvas
  participant GameState as Game state service
  LevelEnd->>TC017: Verify Level End screen
  TC017->>LevelEnd: Wait and click Replay
  LevelEnd->>Gameplay: Reload gameplay scene
  TC017->>Gameplay: Click monster hotspot
  Gameplay->>Canvas: Render fresh puzzle content
  TC017->>Canvas: Assert canvas content
  TC017->>GameState: Read selected level
  GameState-->>TC017: Return Level 2 context
Loading

Possibly related PRs

Suggested reviewers: bernhardccodev, miguelccodev, dz4va

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Tests & Lint & Coverage ⚠️ Warning TC_017 and flow updates add relevant E2E coverage, but no lint result or coverage artifact exists; Jest's coverage threshold is commented out. Run lint and test coverage in CI, publish the results, and enforce or report coverage of at least 70%.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows the naming convention, includes the FM-967 identifier, and clearly describes the Replay level-flow automation coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch FM-967

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/tests/isolated/tc-017-level-replay.spec.ts`:
- Around line 35-60: Ensure the Replay flow waits for the level-end overlay to
deactivate before reading hitbox state or clicking the fresh puzzle. Update the
“Gameplay scene reloads after Replay” step or the gameplay scene wait helper
used by waitForGameplayScene() to verify `#levelEnd` is inactive, while preserving
the existing canvas and pause-button readiness checks.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d462e589-e472-44d5-9486-a25999b67c48

📥 Commits

Reviewing files that changed from the base of the PR and between c8ed76e and 1523b6f.

⛔ Files ignored due to path filters (2)
  • e2e/tests/README.md is excluded by !**/*.md
  • spec/FM-967-replay-level-e2e-automation.md is excluded by !**/*.md
📒 Files selected for processing (4)
  • e2e/constants/timeouts.ts
  • e2e/tests/ftm-assessment-survey-flow.spec.ts
  • e2e/tests/isolated/tc-016-level-completion.spec.ts
  • e2e/tests/isolated/tc-017-level-replay.spec.ts

Comment on lines +35 to +60
await test.step('Wait for UI to settle before interacting with Replay', async () => {
await page.waitForTimeout(Timeouts.replaySettleDelay);
});

await test.step('Click Replay button', async () => {
await levelEndPage.clickRetryButton();
});

await test.step('Gameplay scene reloads after Replay', async () => {
await gameplayPage.waitForGameplayScene();
});

await test.step('Click the monster hotspot to trigger stones on the fresh puzzle', async () => {
await page.waitForFunction(
() => (window as any).__ftm?.gameStateService?.getHitBoxRanges?.() != null,
{ timeout: Timeouts.sceneTransition },
);
const hitboxCenter = await getHitboxCenter(page);
expect(hitboxCenter).not.toBeNull();
const canvasBB = await gameplayPage.mainCanvas.boundingBox();
expect(canvasBB).not.toBeNull();
await page.mouse.click(
canvasBB!.x + hitboxCenter!.x,
canvasBB!.y + hitboxCenter!.y,
);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

gameplay_files="$(fd -i -t f 'gameplay-page\.ts$' e2e || true)"
while IFS= read -r file; do
  [ -z "$file" ] && continue
  rg -n -A30 -B5 '\bwaitForGameplayScene\s*\(' "$file" || true
done <<< "$gameplay_files"

rg -n -A25 -B10 'levelend|clickRetryButton|retry-btn|Replay' e2e/pages e2e/helpers || true

Repository: curiouslearning/FeedTheMonsterJS

Length of output: 7158


🏁 Script executed:

#!/bin/bash
set -euo pipefail

test_file="e2e/tests/isolated/tc-017-level-replay.spec.ts"
if [ -f "${test_file}" ]; then
  sed -n '1,140p' "${test_file}" | cat -n
else
  echo "test file not found"
fi

playground_files="$(fd -i -t f 'playground|gameplay|level-end' e2e/src-e2e e2e pages 2>/dev/null || true)"
echo "PLAYGROUND_FILES=${playground_files}"

for file in $playground_files; do
  [ -z "$file" ] && continue
  base="$(basename "$file")"
  echo "--- ${file} (size $(wc -l < "$file")) ---"
  rg -n -A8 -B8 'getHitBoxRanges|hitBoxRanges|playground|canvas|levelEnd|gameStateService|Scene|setLevel|loadLevel|replay' "$file" || true
done

rg -n -A12 -B8 'getHitBoxRanges|hitBoxRanges|gameStateService' e2e || true

Repository: curiouslearning/FeedTheMonsterJS

Length of output: 50388


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "--- GameplayPage implementation ---"
sed -n '1,110p' e2e/pages/gameplay-page.ts | cat -n

echo "--- LevelEndPage retry implementation ---"
sed -n '80,115p' e2e/pages/level-end-page.ts | cat -n

echo "--- Reusable wait helpers around playable/gameplay state ---"
rg -n -A20 -B8 'playable|canPlay|isPlayable|isLevelPlayable|gamePlay.*loaded|gamePlay.*ready|loadLevel|reload|retry|GamePlay|gamePlayService|getHitBoxRanges|sceneHandler|currentScene' e2e e2e/src-e2e --glob '!e2e/tests/isolated/*' | head -n 240 || true

echo "--- Candidate source files containing retry/loadState/startPlayback ---"
rg -n 'retry|retryBtn|retry.*click|set.*Play|startPlayback|loadLevel|reset|reload|gameStateService.getHitBoxRanges|currentScene|activeScene' e2e/src-e2e e2e/pages e2e/includes --glob '!**/*.spec.ts' --glob '!**/*.test.ts' | head -n 240 || true

echo "--- Search for waitForStonesReady / getHitboxCenter wrappers beyond direct lines ---"
rg -n -A30 -B10 'waitForStonesReady|getHitboxCenter|gameStateService.*hitBoxRanges|hitBoxRanges' e2e e2e/src-e2e --glob '!e2e/tests/isolated/*' | head -n 260 || true

# Behavioral probe: model the current post-replay conditions and show stale-state risk.
node - <<'JS'
const conditions = {
  timeoutIsOnlyElapsed: true,
  waitForGameplaySceneOnlyChecks: ['`#canvas` visible', '`#pause-button` visible'],
  replayButtonSelectorUsed: '`#levelend-retry-btn`',
  hitboxPrecondition: 'window.__ftm?.gameStateService?.getHitBoxRanges() != null',
};

const staleScenario = {
  oldLevelEndStillOverlaying: true,
  oldGameplaySceneStillActive: true,
  uiButtonsVisibleButOverlayBlocked: true,
  gameHitBoxRangesAvailable: true,
};

console.log(
  JSON.stringify(
    {
      conditions,
      staleScenario,
      currentTestWillWaitFor: [...conditions.waitForGameplaySceneOnlyChecks, conditions.hitboxPrecondition],
      missingPostReplayConditions: [
        '`#levelEnd` hidden / inactive',
        'active gameplay scene not same as overlay before retry',
        'gamePlayData.puzzles reset or currentPuzzleIndex reset',
        'stoneHandler.stonesHasLoaded reset',
      ],
    },
    null,
    2
  )
);
JS

Repository: curiouslearning/FeedTheMonsterJS

Length of output: 30316


Wait for the replay scene to clear before reading game state.

waitForGameplayScene() only checks that #canvas and #pause-button are visible, while getHitboxCenter() reads whatever __ftm.gameStateService.getHitBoxRanges() returns. If #levelEnd is still active after Replay, this step can click the stale Level End hitbox. Add the level-end deactivation check before reading hitbox state, or update waitForGameplayScene() to enforce it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/tests/isolated/tc-017-level-replay.spec.ts` around lines 35 - 60, Ensure
the Replay flow waits for the level-end overlay to deactivate before reading
hitbox state or clicking the fresh puzzle. Update the “Gameplay scene reloads
after Replay” step or the gameplay scene wait helper used by
waitForGameplayScene() to verify `#levelEnd` is inactive, while preserving the
existing canvas and pause-button readiness checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant