-
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.
- Loading branch information
1 parent
d879eaa
commit 6636e26
Showing
31 changed files
with
1,167 additions
and
203 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Toast } from 'primereact/toast'; | ||
import { createContext, useContext, useEffect, useRef, useState } from 'react'; | ||
|
||
const ToastContext = createContext<Toast | null>(null); | ||
|
||
export function useToast() { | ||
return useContext(ToastContext); | ||
} | ||
|
||
export function ToastProvider({ children }: { children: React.ReactNode }) { | ||
const ref = useRef<Toast>(null); | ||
const [toast, setToast] = useState<Toast | null>(null); | ||
|
||
// We have to wrap the ref in a state to force a re-render on initial mount, otherwise the context value will be null | ||
useEffect(() => { | ||
if (ref.current) setToast(ref.current); | ||
}, [ref.current]); | ||
|
||
return ( | ||
<> | ||
<Toast ref={ref} /> | ||
<ToastContext.Provider value={toast}>{children}</ToastContext.Provider> | ||
</> | ||
); | ||
} |
10 changes: 5 additions & 5 deletions
10
src/components/Contexts/Variables/Modals/SlewFlags.test.tsx
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,25 +1,25 @@ | ||
import { canEditAtom } from '@/components/atoms/auth'; | ||
import { slewVisibleAtom } from '@/components/atoms/slew'; | ||
import { renderWithContext } from '@gql/render'; | ||
import { screen, waitFor } from '@testing-library/react'; | ||
import { page } from '@vitest/browser/context'; | ||
import { SlewFlags } from './SlewFlags'; | ||
|
||
describe(SlewFlags.name, () => { | ||
it('should render', async () => { | ||
renderWithContext(<SlewFlags />, { initialValues: [[slewVisibleAtom, true]] }); | ||
|
||
expect(screen.getAllByRole<HTMLInputElement>('checkbox')).toHaveLength(16); | ||
await waitFor(async () => (await screen.findByLabelText<HTMLInputElement>('Zero Chop Throw')).disabled); | ||
await expect.element(page.getByText('Zero Chop Throw')).toBeEnabled(); | ||
expect(page.getByRole('checkbox').elements()).toHaveLength(16); | ||
}); | ||
|
||
it('should disable when canEdit=false', () => { | ||
it('should disable when canEdit=false', async () => { | ||
renderWithContext(<SlewFlags />, { | ||
initialValues: [ | ||
[slewVisibleAtom, true], | ||
[canEditAtom, false], | ||
], | ||
}); | ||
|
||
expect(screen.getByLabelText<HTMLInputElement>('Zero Chop Throw').disabled).to.be.true; | ||
await expect.element(page.getByLabelText('Zero Chop Throw')).toBeDisabled(); | ||
}); | ||
}); |
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
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
Oops, something went wrong.