fix(player): a layer that opens by itself takes no history entry
The auto-skip countdown and the up-next card pushed an entry without a user gesture (Chrome's Back button skips those), and one pushed under the open shortcuts sheet sat above it, so Back closed the hidden layer.
This commit is contained in:
@@ -308,6 +308,45 @@ describe("leaving an item that was played through", () => {
|
||||
act(() => void el.dispatchEvent(new Event("ended")));
|
||||
};
|
||||
|
||||
// A layer the player opens BY ITSELF — the auto-skip countdown, the up-next card — takes no history
|
||||
// entry. Chrome's Back button skips an entry pushed without a user gesture, and one pushed under an
|
||||
// open dialog (the shortcuts sheet) sat above it, so Back closed the hidden layer, not the dialog.
|
||||
const overlayPushes = (push: { mock: { calls: unknown[][] } }) =>
|
||||
push.mock.calls.filter(([state]) => (state as { _ov?: number } | null)?._ov != null);
|
||||
|
||||
it("gives the auto-skip countdown no history entry", async () => {
|
||||
prefs({ autoSkipIntro: true, autoSkipDelay: 5 });
|
||||
const withIntro = {
|
||||
...item("A"),
|
||||
markers: [{ type: "intro", start_s: 100, end_s: 160, final: false }],
|
||||
} as unknown as PlexItemDetail;
|
||||
mount({ details: { A: withIntro }, sessions: { A: () => Promise.resolve(direct("A")) } });
|
||||
await playingAt("/media/A", 50);
|
||||
await tick();
|
||||
const push = vi.spyOn(window.history, "pushState");
|
||||
await playingAt("/media/A", 110); // inside the intro: the countdown starts
|
||||
await waitFor(() => expect(screen.getByText("plex.player.skipIntro")).toBeTruthy());
|
||||
await tick();
|
||||
expect(overlayPushes(push)).toEqual([]);
|
||||
});
|
||||
|
||||
it("gives the up-next card no history entry", async () => {
|
||||
prefs({ upNext: true });
|
||||
mount({
|
||||
details: { A: item("A"), B: item("B") },
|
||||
sessions: { A: () => Promise.resolve(direct("A")), B: () => new Promise(() => {}) },
|
||||
queue: ["A", "B"],
|
||||
});
|
||||
vi.spyOn(api, "plexSetState").mockResolvedValue(undefined as never);
|
||||
await playingAt("/media/A", 2995);
|
||||
await tick();
|
||||
const push = vi.spyOn(window.history, "pushState");
|
||||
endMedia();
|
||||
await screen.findByText("Title B"); // the card names the next item
|
||||
await tick();
|
||||
expect(overlayPushes(push)).toEqual([]);
|
||||
});
|
||||
|
||||
it("settles it as watched when it ended, so Prev does not reopen it at its last seconds", async () => {
|
||||
prefs({ upNext: false });
|
||||
const { qc, progress } = mount({
|
||||
|
||||
Reference in New Issue
Block a user