[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:
Jakob Ackermann
2025-10-24 08:05:42 +00:00
committed by Copybot
parent d0d360c1bd
commit f3f6a8a8e0
23 changed files with 576 additions and 19 deletions
@@ -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')
})
})
})
@@ -72,7 +72,7 @@ const defaultUserSettings = {
}
export type EditorProvidersProps = {
user?: { id: string; email: string }
user?: { id: string; email: string; signUpDate?: string }
projectId?: string
projectName?: string
projectOwner?: ProjectMetadata['owner']
@@ -147,7 +147,11 @@ const layoutContextDefault = {
} satisfies Partial<LayoutContextValue>
export function EditorProviders({
user = { id: USER_ID, email: USER_EMAIL },
user = {
id: USER_ID,
email: USER_EMAIL,
signUpDate: '2025-10-10T10:10:10Z',
},
projectId = projectDefaults._id,
projectName = projectDefaults.name,
projectOwner = projectDefaults.owner,