mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
[web] add clsi-cache prompts (#29281)
* [web] add clsi-cache prompts * [web] add new editor variant to segmentation * [web] add tests for useNewEditorVariant * [web] adjust start of using clsi-cache in split-test GitOrigin-RevId: c9c5b1eff2ceefb65ef82516d9074cb971cb4c48
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import { expect } from 'chai'
|
||||
import { mockScope } from './scope'
|
||||
import { EditorProviders } from '../../helpers/editor-providers'
|
||||
import { renderHook } from '@testing-library/react'
|
||||
import { useNewEditorVariant } from '@/features/ide-redesign/utils/new-editor-utils'
|
||||
|
||||
describe('new-editor-utils', function () {
|
||||
describe('useNewEditorVariant', function () {
|
||||
const newEditorVariants = [
|
||||
'default',
|
||||
'new-editor',
|
||||
'new-editor-old-logs',
|
||||
'new-editor-new-logs-old-position',
|
||||
]
|
||||
for (const variant of newEditorVariants) {
|
||||
it(`forwards ?editor-redesign-new-users=${variant}`, function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'editor-redesign-new-users': variant,
|
||||
})
|
||||
|
||||
const scope = mockScope()
|
||||
|
||||
const { result } = renderHook(() => useNewEditorVariant(), {
|
||||
wrapper: ({ children }) => (
|
||||
<EditorProviders
|
||||
scope={scope}
|
||||
userSettings={{ enableNewEditor: true }}
|
||||
>
|
||||
{children}
|
||||
</EditorProviders>
|
||||
),
|
||||
})
|
||||
expect(result.current).to.equal(variant)
|
||||
})
|
||||
}
|
||||
for (const variant of newEditorVariants) {
|
||||
it(`ignores ?editor-redesign-new-users=${variant} when disabled by user`, function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'editor-redesign-new-users': variant,
|
||||
})
|
||||
|
||||
const scope = mockScope()
|
||||
|
||||
const { result } = renderHook(() => useNewEditorVariant(), {
|
||||
wrapper: ({ children }) => (
|
||||
<EditorProviders
|
||||
scope={scope}
|
||||
userSettings={{ enableNewEditor: false }}
|
||||
>
|
||||
{children}
|
||||
</EditorProviders>
|
||||
),
|
||||
})
|
||||
expect(result.current).to.equal('default')
|
||||
})
|
||||
}
|
||||
it(`handles ?editor-redesign=enabled`, function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'editor-redesign': 'enabled',
|
||||
})
|
||||
|
||||
const scope = mockScope()
|
||||
|
||||
const { result } = renderHook(() => useNewEditorVariant(), {
|
||||
wrapper: ({ children }) => (
|
||||
<EditorProviders
|
||||
scope={scope}
|
||||
userSettings={{ enableNewEditor: true }}
|
||||
>
|
||||
{children}
|
||||
</EditorProviders>
|
||||
),
|
||||
})
|
||||
expect(result.current).to.equal('new-editor')
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user