Pin phone sheets to the visible viewport, and let people correct login and organizer errors.
This commit is contained in:
1 parent
27d74e510c
commit
39807ef452
17 files changed
+236
-16
No files matched your search
@@ -1,14 +1,23 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { screen, fireEvent, waitFor } from "@testing-library/react";
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { renderWithProviders } from "../utils/test-utils";
|
||||
import Login from "../../app/components/modals/Login";
|
||||
|
||||
describe("Login", () => {
|
||||
const originalViewport = window.visualViewport;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
Object.defineProperty(window, "visualViewport", {
|
||||
configurable: true,
|
||||
value: originalViewport,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses blurredYellow backdrop by default (header overlay)", async () => {
|
||||
renderWithProviders(
|
||||
<Login isOpen onClose={vi.fn()} ariaLabelledBy="login-modal-heading">
|
||||
@@ -172,4 +181,30 @@ describe("Login", () => {
|
||||
expect(screen.getByLabelText("Close")).toBeInTheDocument();
|
||||
expect(screen.queryByLabelText("More options")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("pins the overlay to the visual viewport offset", async () => {
|
||||
Object.defineProperty(window, "visualViewport", {
|
||||
configurable: true,
|
||||
value: {
|
||||
height: 500,
|
||||
offsetTop: 80,
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
},
|
||||
});
|
||||
renderWithProviders(
|
||||
<Login isOpen onClose={vi.fn()} ariaLabelledBy="login-modal-heading">
|
||||
<p id="login-modal-heading">Login content</p>
|
||||
</Login>,
|
||||
);
|
||||
const backdrop = await waitFor(() => {
|
||||
const dialog = screen.getByRole("dialog");
|
||||
expect(dialog.parentElement).toHaveStyle({
|
||||
top: "80px",
|
||||
height: "500px",
|
||||
});
|
||||
return dialog.parentElement;
|
||||
});
|
||||
expect(backdrop).toHaveStyle({ bottom: "auto" });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user