Add better onboard testing (#4007)
This commit is contained in:
parent
fd704bfd44
commit
107760d551
3 changed files with 71 additions and 1 deletions
|
@ -130,6 +130,28 @@ export function useGate(): (gateName: Gate) => boolean {
|
|||
return gate
|
||||
}
|
||||
|
||||
/**
|
||||
* Debugging tool to override a gate. USE ONLY IN E2E TESTS!
|
||||
*/
|
||||
export function useDangerousSetGate(): (
|
||||
gateName: Gate,
|
||||
value: boolean,
|
||||
) => void {
|
||||
const cache = React.useContext(GateCache)
|
||||
if (!cache) {
|
||||
throw Error(
|
||||
'useDangerousSetGate() cannot be called outside StatsigProvider.',
|
||||
)
|
||||
}
|
||||
const dangerousSetGate = React.useCallback(
|
||||
(gateName: Gate, value: boolean) => {
|
||||
cache.set(gateName, value)
|
||||
},
|
||||
[cache],
|
||||
)
|
||||
return dangerousSetGate
|
||||
}
|
||||
|
||||
function toStatsigUser(did: string | undefined): StatsigUser {
|
||||
let userID: string | undefined
|
||||
if (did) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue