diff --git a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.spec.tsx
index b6a1b2da7f..fdc60755e8 100644
--- a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.spec.tsx
+++ b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.spec.tsx
@@ -1,4 +1,10 @@
-import { act, render, screen } from "@testing-library/react";
+import {
+ act,
+ createEvent,
+ fireEvent,
+ render,
+ screen
+} from "@testing-library/react";
import {
IFileIndexItem,
newIFileIndexItemArray
@@ -64,6 +70,58 @@ describe("archive-sidebar-selection-list", () => {
component.unmount();
});
+ it("toggleSelection keyboard keyDown it hits", () => {
+ const component = render(
+
+ );
+
+ const spy = jest.spyOn(URLPath.prototype, "toggleSelection");
+
+ const selectionList = screen.queryByTestId(
+ "sidebar-selection-list"
+ ) as HTMLElement;
+ const element = selectionList.children[0].querySelector(
+ ".close"
+ ) as HTMLElement;
+
+ act(() => {
+ const inputEvent = createEvent.keyDown(element, { key: "Enter" });
+ fireEvent(element, inputEvent);
+ });
+
+ expect(spy).toBeCalledTimes(1);
+
+ spy.mockClear();
+
+ component.unmount();
+ });
+
+ it("toggleSelection keyboard keyDown it ignores", () => {
+ const component = render(
+
+ );
+
+ const spy = jest.spyOn(URLPath.prototype, "toggleSelection");
+
+ const selectionList = screen.queryByTestId(
+ "sidebar-selection-list"
+ ) as HTMLElement;
+ const element = selectionList.children[0].querySelector(
+ ".close"
+ ) as HTMLElement;
+
+ act(() => {
+ const inputEvent = createEvent.keyDown(element, { key: "Tab" });
+ fireEvent(element, inputEvent);
+ });
+
+ expect(spy).toBeCalledTimes(0);
+
+ spy.mockClear();
+
+ component.unmount();
+ });
+
it("allSelection", () => {
const component = render(
diff --git a/starsky/starsky/clientapp/src/components/organisms/detail-view-media/detail-view-mp4.spec.tsx b/starsky/starsky/clientapp/src/components/organisms/detail-view-media/detail-view-mp4.spec.tsx
index 9a33505c16..019d557af7 100644
--- a/starsky/starsky/clientapp/src/components/organisms/detail-view-media/detail-view-mp4.spec.tsx
+++ b/starsky/starsky/clientapp/src/components/organisms/detail-view-media/detail-view-mp4.spec.tsx
@@ -1,4 +1,10 @@
-import { act, fireEvent, render, screen } from "@testing-library/react";
+import {
+ act,
+ createEvent,
+ fireEvent,
+ render,
+ screen
+} from "@testing-library/react";
import React from "react";
import { Root, createRoot } from "react-dom/client";
import { IDetailView } from "../../../interfaces/IDetailView";
@@ -36,6 +42,40 @@ describe("DetailViewMp4", () => {
component.unmount();
});
+ it("keyDown Tab ignore", () => {
+ const component = render();
+
+ const playSpy = jest
+ .spyOn(HTMLMediaElement.prototype, "play")
+ .mockReset()
+ .mockImplementationOnce(() => Promise.resolve());
+
+ const figure = screen.queryByTestId("video") as HTMLElement;
+ const inputEvent = createEvent.keyDown(figure, { key: "Tab" });
+ fireEvent(figure, inputEvent);
+
+ expect(playSpy).toBeCalledTimes(0);
+
+ component.unmount();
+ });
+
+ it("keyDown Enter video resolve", () => {
+ const component = render();
+
+ const playSpy = jest
+ .spyOn(HTMLMediaElement.prototype, "play")
+ .mockReset()
+ .mockImplementationOnce(() => Promise.resolve());
+
+ const figure = screen.queryByTestId("video") as HTMLElement;
+ const inputEvent = createEvent.keyDown(figure, { key: "Enter" });
+ fireEvent(figure, inputEvent);
+
+ expect(playSpy).toBeCalledTimes(1);
+
+ component.unmount();
+ });
+
it("click to play video rejected", async () => {
const component = render();
@@ -56,6 +96,7 @@ describe("DetailViewMp4", () => {
await component.unmount();
});
});
+
it("click to play video and timeupdate", () => {
const component = render();
@@ -79,6 +120,54 @@ describe("DetailViewMp4", () => {
component.unmount();
});
+ it("keyDown Enter to play video and timeupdate", () => {
+ const component = render();
+
+ const playSpy = jest
+ .spyOn(HTMLMediaElement.prototype, "play")
+ .mockReset()
+ .mockImplementationOnce(() => {
+ return Promise.resolve();
+ });
+
+ expect(screen.queryByTestId("video-time")?.textContent).toBe("");
+
+ const figure = screen.queryByTestId("video") as HTMLElement;
+ const inputEvent = createEvent.keyDown(figure, { key: "Enter" });
+ fireEvent(figure, inputEvent);
+
+ expect(screen.queryByTestId("video-time")?.textContent).toBe(
+ "0:00 / 0:00"
+ );
+
+ expect(playSpy).toBeCalled();
+
+ component.unmount();
+ });
+
+ it("keyDown Tab ignored", () => {
+ const component = render();
+
+ const playSpy = jest
+ .spyOn(HTMLMediaElement.prototype, "play")
+ .mockReset()
+ .mockImplementationOnce(() => {
+ return Promise.resolve();
+ });
+
+ expect(screen.queryByTestId("video-time")?.textContent).toBe("");
+
+ const figure = screen.queryByTestId("video") as HTMLElement;
+ const inputEvent = createEvent.keyDown(figure, { key: "Tab" });
+ fireEvent(figure, inputEvent);
+
+ expect(screen.queryByTestId("video-time")?.textContent).toBe("");
+
+ expect(playSpy).toBeCalledTimes(0);
+
+ component.unmount();
+ });
+
it("progress DOM", (done) => {
const component = document.createElement("div");
document.body.appendChild(component); // Append the component to the body