From 88577496b09f8a9cf60206358ea4e435b2ac876b Mon Sep 17 00:00:00 2001 From: eric-kingu Date: Mon, 12 Aug 2024 21:10:53 -0300 Subject: [PATCH 1/2] Fix Time Format --- tracknow/web/src/components/User/UserAddLaptimes.tsx | 2 +- tracknow/web/src/test-utils.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tracknow/web/src/components/User/UserAddLaptimes.tsx b/tracknow/web/src/components/User/UserAddLaptimes.tsx index 12fc484..b192f3b 100644 --- a/tracknow/web/src/components/User/UserAddLaptimes.tsx +++ b/tracknow/web/src/components/User/UserAddLaptimes.tsx @@ -87,7 +87,7 @@ const UserAddLaptimes = () => { // regex const youtubeRegex = /http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?‌​[\w\?‌​=]*)?/; - const timeRegex = /^(\d{1,2})?(\.(\d{2}))?(\.(\d{2}))?(\.(\d{1,3}))?$/; + const timeRegex = /^(\d{1,2})?(\:([0-5]\d))?(\:([0-5]\d))?(\.(\d{1,3}))?$/; return ( <> diff --git a/tracknow/web/src/test-utils.tsx b/tracknow/web/src/test-utils.tsx index d7ef121..2c1654c 100644 --- a/tracknow/web/src/test-utils.tsx +++ b/tracknow/web/src/test-utils.tsx @@ -5,7 +5,13 @@ import { ChakraProvider, theme } from "@chakra-ui/react" const AllProviders = ({ children }: { children?: React.ReactNode }) => ( {children} ) - +/* +describe('Time format', () => { + test('Time format is 00:00:00.000', () => { + expect(UserAddLaptimes("00:00:00.000")).toBe("00:00:00.000") + }) +}) +*/ const customRender = (ui: React.ReactElement, options?: RenderOptions) => render(ui, { wrapper: AllProviders, ...options }) From 67097dbc8f6ae1d4b97f9a56dc858b5c8bc93e5b Mon Sep 17 00:00:00 2001 From: eric-kingu Date: Mon, 12 Aug 2024 22:39:32 -0300 Subject: [PATCH 2/2] Updated time placeholder and time error message --- tracknow/web/src/components/User/UserAddLaptimes.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracknow/web/src/components/User/UserAddLaptimes.tsx b/tracknow/web/src/components/User/UserAddLaptimes.tsx index b192f3b..f48534c 100644 --- a/tracknow/web/src/components/User/UserAddLaptimes.tsx +++ b/tracknow/web/src/components/User/UserAddLaptimes.tsx @@ -211,11 +211,11 @@ const UserAddLaptimes = () => { setTime(e.target.value)} maxLength={10} /> {time && !timeRegex.test(time) && ( - Please enter a valid laptime (minutes.seconds.milliseconds) + Please enter a valid laptime (hours:minutes:seconds.milliseconds) )}