Skip to content

Commit f9c43aa

Browse files
lifeartclaude
andcommitted
Tighten maybeIdlePause comment and add user-pause regression test
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2489e85 commit f9c43aa

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

frontend/app/services/studying-timer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export default class StudyingTimerService extends Service {
6666
}
6767
@action
6868
maybeIdlePause() {
69-
// Don't pause while audio is playing: exercises play audio without
70-
// requiring mouse movement, and pausing here cascades into audio.stop().
69+
// Pause cascades into audio.stop() via task-player.onPauseStateChanged,
70+
// which would interrupt exercises whenever the user stops moving the mouse.
7171
if (this.audio.isPlaying) {
7272
return;
7373
}

frontend/tests/unit/services/studying-timer-test.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,29 @@ module('Unit | Service | studying-timer', function (hooks) {
1111
});
1212

1313
module('maybeIdlePause', function () {
14+
function withAudio(owner, playing) {
15+
owner.register('service:audio', class extends Service { isPlaying = playing; });
16+
return owner.lookup('service:studying-timer');
17+
}
18+
1419
test('pauses when audio is not playing', function (assert) {
15-
this.owner.register(
16-
'service:audio',
17-
class extends Service { isPlaying = false; },
18-
);
19-
const timer = this.owner.lookup('service:studying-timer');
20+
const timer = withAudio(this.owner, false);
2021
timer.maybeIdlePause();
21-
assert.true(timer.isPaused, 'isPaused set to true');
22+
assert.true(timer.isPaused);
2223
});
2324

2425
test('does not pause when audio is playing', function (assert) {
25-
this.owner.register(
26-
'service:audio',
27-
class extends Service { isPlaying = true; },
28-
);
29-
const timer = this.owner.lookup('service:studying-timer');
26+
const timer = withAudio(this.owner, true);
3027
timer.maybeIdlePause();
31-
assert.false(timer.isPaused, 'isPaused stays false during playback');
28+
assert.false(timer.isPaused);
29+
});
30+
31+
test('user pause still works while audio plays', function (assert) {
32+
// Regression guard: only maybeIdlePause should defer to audio state;
33+
// direct pause() (timer button click) must remain unconditional.
34+
const timer = withAudio(this.owner, true);
35+
timer.pause();
36+
assert.true(timer.isPaused);
3237
});
3338
});
3439
});

0 commit comments

Comments
 (0)