-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into hotfix/thkids
- Loading branch information
Showing
13 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Docker-compose definition for development | ||
# docker compose definition for development | ||
|
||
version: '2.4' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
frontend/src/hooks/useDisableIOSPinchZoomOnTouchDevices.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { vi, describe, test, expect, afterEach } from "vitest"; | ||
import { renderHook } from "@testing-library/react-hooks"; | ||
import { waitFor } from "@testing-library/react"; | ||
import useDisableIOSPinchZoomOnTouchDevices from "./useDisableIOSPinchZoomOnTouchDevices"; | ||
|
||
describe("useDisableIOSPinchZoomOnTouchDevices", () => { | ||
afterEach(() => { | ||
vi.unstubAllGlobals(); | ||
}); | ||
|
||
test("should prevent gesturestart on touch devices", async () => { | ||
vi.stubGlobal("ontouchstart", true); | ||
|
||
const mockEvent = new Event('gesturestart'); | ||
mockEvent.preventDefault = vi.fn(); | ||
|
||
const spy = vi.spyOn(mockEvent, 'preventDefault').mockImplementation(() => { }); | ||
|
||
renderHook(() => useDisableIOSPinchZoomOnTouchDevices()); | ||
|
||
await waitFor(() => document.dispatchEvent(mockEvent)); | ||
await waitFor(() => expect(spy).toHaveBeenCalledTimes(1)); | ||
}); | ||
|
||
test("should not prevent gesturestart on non-touch devices", () => { | ||
const mockEvent = new Event('gesturestart'); | ||
mockEvent.preventDefault = vi.fn(); | ||
|
||
const spy = vi.spyOn(mockEvent, 'preventDefault').mockImplementation(() => { }); | ||
|
||
renderHook(() => useDisableIOSPinchZoomOnTouchDevices()); | ||
|
||
document.dispatchEvent(mockEvent); | ||
expect(spy).not.toHaveBeenCalled(); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
frontend/src/hooks/useDisableIOSPinchZoomOnTouchDevices.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useEffect } from 'react'; | ||
|
||
const useDisableIOSPinchZoomOnTouchDevices = () => useEffect(() => { | ||
const isTouchDevice = () => !!('ontouchstart' in window || !!(navigator.maxTouchPoints)); | ||
|
||
const handlePinchZoom = (event: Event) => { | ||
if (isTouchDevice()) { | ||
event.preventDefault(); | ||
} | ||
}; | ||
|
||
document.addEventListener('gesturestart', handlePinchZoom); | ||
|
||
return () => { | ||
document.removeEventListener('gesturestart', handlePinchZoom); | ||
}; | ||
}, []); | ||
|
||
|
||
export default useDisableIOSPinchZoomOnTouchDevices; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#!/bin/bash | ||
docker compose run --rm client yarn build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#!/bin/bash | ||
docker compose run --rm server bash -c "python manage.py test $@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#!/bin/bash | ||
docker compose run --rm server bash -c "coverage run manage.py test && coverage report --show-missing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#!/bin/bash | ||
docker compose run --rm client yarn test --watch=false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#!/bin/bash | ||
docker compose run --rm client yarn test --watch=true | ||
|