add diaposine
This commit is contained in:
@@ -4,6 +4,7 @@ import { AppRoutes } from '@/app/routes'
|
||||
import { NotificationStack } from '@/shared/ui/NotificationStack'
|
||||
import { ErrorBoundary } from '@/shared/ui/ErrorBoundary'
|
||||
import { NoiseOverlay } from '@/shared/ui/NoiseOverlay'
|
||||
import { DemoOverlay } from '@/shared/ui/DemoOverlay'
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
@@ -14,6 +15,7 @@ export function App() {
|
||||
</ErrorBoundary>
|
||||
<NotificationStack />
|
||||
<NoiseOverlay />
|
||||
<DemoOverlay />
|
||||
</BrowserRouter>
|
||||
</AppProviders>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import Box from '@mui/material/Box'
|
||||
import { useTheme } from '@mui/material/styles'
|
||||
import { IS_DEMO_MODE } from '@/shared/config'
|
||||
|
||||
export function DemoOverlay() {
|
||||
const theme = useTheme()
|
||||
const isDark = theme.palette.mode === 'dark'
|
||||
|
||||
if (!IS_DEMO_MODE) return null
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
aria-hidden="true"
|
||||
sx={{
|
||||
position: 'fixed',
|
||||
inset: 0,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
pointerEvents: 'none',
|
||||
zIndex: 9990,
|
||||
fontSize: '10vw',
|
||||
fontWeight: 900,
|
||||
color: isDark ? 'rgba(255,255,255,0.04)' : 'rgba(0,0,0,0.04)',
|
||||
transform: 'rotate(-30deg)',
|
||||
userSelect: 'none',
|
||||
}}
|
||||
>
|
||||
ДЕМО
|
||||
</Box>
|
||||
|
||||
<Box
|
||||
aria-hidden="true"
|
||||
sx={{
|
||||
position: 'fixed',
|
||||
bottom: 16,
|
||||
right: 16,
|
||||
pointerEvents: 'none',
|
||||
zIndex: 9991,
|
||||
px: 2,
|
||||
py: 0.75,
|
||||
borderRadius: 1,
|
||||
fontSize: 12,
|
||||
fontWeight: 600,
|
||||
letterSpacing: '0.04em',
|
||||
color: isDark ? 'rgba(255,255,255,0.6)' : '#fff',
|
||||
bgcolor: isDark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.6)',
|
||||
userSelect: 'none',
|
||||
}}
|
||||
>
|
||||
ДЕМО-РЕЖИМ
|
||||
</Box>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { render } from '@testing-library/react'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
let mockDemoMode = true
|
||||
|
||||
vi.mock('@/shared/config', async () => {
|
||||
const actual = await vi.importActual<typeof import('@/shared/config')>('@/shared/config')
|
||||
return {
|
||||
...actual,
|
||||
get IS_DEMO_MODE() {
|
||||
return mockDemoMode
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
import { DemoOverlay } from '../DemoOverlay'
|
||||
|
||||
describe('DemoOverlay', () => {
|
||||
it('рендерит водяной знак и плашку когда демо включён', () => {
|
||||
mockDemoMode = true
|
||||
const { container } = render(<DemoOverlay />)
|
||||
|
||||
const text = container.textContent
|
||||
expect(text).toContain('ДЕМО')
|
||||
expect(text).toContain('ДЕМО-РЕЖИМ')
|
||||
|
||||
const allBoxes = container.querySelectorAll('.MuiBox-root')
|
||||
expect(allBoxes.length).toBeGreaterThanOrEqual(2)
|
||||
|
||||
const [watermark, badge] = allBoxes
|
||||
|
||||
expect(watermark.getAttribute('aria-hidden')).toBe('true')
|
||||
expect(watermark.textContent).toBe('ДЕМО')
|
||||
|
||||
expect(badge.getAttribute('aria-hidden')).toBe('true')
|
||||
expect(badge.textContent).toBe('ДЕМО-РЕЖИМ')
|
||||
})
|
||||
|
||||
it('не рендерит ничего когда демо выключен', () => {
|
||||
mockDemoMode = false
|
||||
const { container } = render(<DemoOverlay />)
|
||||
expect(container.textContent).toBe('')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user