-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add email verification in user list [DHIS2-18613] #1520
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useConfig } from '@dhis2/app-runtime' | ||
|
||
export const useFeatureToggle = () => { | ||
const config = useConfig() | ||
const minorVersion = config?.serverVersion?.minor | ||
const emailConfigured = config?.systemInfo?.emailConfigured | ||
return { | ||
displayEmailVerifiedStatus: Boolean( | ||
emailConfigured && Number(minorVersion) >= 42 | ||
), | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useConfig } from '@dhis2/app-runtime' | ||
import { renderHook } from '@testing-library/react-hooks' | ||
import { useFeatureToggle } from './useFeatureToggle.js' | ||
|
||
jest.mock('@dhis2/app-runtime', () => ({ | ||
...jest.requireActual('@dhis2/app-runtime'), | ||
useConfig: jest.fn(), | ||
})) | ||
|
||
describe('useFeatureToggle', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
it('has displayEmailVerifiedStatus:false if email is not configured', () => { | ||
useConfig.mockReturnValue({ | ||
serverVersion: { minor: '42' }, | ||
systemInfo: { emailConfigured: false }, | ||
}) | ||
const { result } = renderHook(() => useFeatureToggle()) | ||
expect(result.current.displayEmailVerifiedStatus).toBe(false) | ||
}) | ||
|
||
it('has displayEmailVerifiedStatus:false if api version is 41 or earlier ', () => { | ||
useConfig.mockReturnValue({ | ||
serverVersion: { minor: '41' }, | ||
systemInfo: { emailConfigured: true }, | ||
}) | ||
const { result } = renderHook(() => useFeatureToggle()) | ||
expect(result.current.displayEmailVerifiedStatus).toBe(false) | ||
}) | ||
|
||
it('has displayEmailVerifiedStatus:false if api version is 42 or greater and email is configured ', () => { | ||
useConfig.mockReturnValue({ | ||
serverVersion: { minor: '42' }, | ||
systemInfo: { emailConfigured: true }, | ||
}) | ||
const { result } = renderHook(() => useFeatureToggle()) | ||
expect(result.current.displayEmailVerifiedStatus).toBe(true) | ||
}) | ||
|
||
it('has displayEmailVerifiedStatus:false if config is missing information', () => { | ||
useConfig.mockReturnValue({}) | ||
const { result } = renderHook(() => useFeatureToggle()) | ||
expect(result.current.displayEmailVerifiedStatus).toBe(false) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated, but turning these back on because the issue with them is now resolved on the backend