|
@@ -90,6 +90,10 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
window.metaAttributesCache.set('ol-splitTestVariants', {
|
|
window.metaAttributesCache.set('ol-splitTestVariants', {
|
|
|
'editor-context-menu': 'enabled',
|
|
'editor-context-menu': 'enabled',
|
|
|
})
|
|
})
|
|
|
|
|
+ cy.intercept('POST', '/project/*/track_changes', {
|
|
|
|
|
+ statusCode: 200,
|
|
|
|
|
+ body: {},
|
|
|
|
|
+ }).as('trackChanges')
|
|
|
cy.interceptEvents()
|
|
cy.interceptEvents()
|
|
|
cy.interceptMetadata()
|
|
cy.interceptMetadata()
|
|
|
})
|
|
})
|
|
@@ -184,7 +188,10 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
|
|
|
|
|
cy.mount(
|
|
cy.mount(
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
- <EditorProviders scope={scope}>
|
|
|
|
|
|
|
+ <EditorProviders
|
|
|
|
|
+ scope={scope}
|
|
|
|
|
+ features={{ trackChangesVisible: true }}
|
|
|
|
|
+ >
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
|
</EditorProviders>
|
|
</EditorProviders>
|
|
|
</TestContainer>
|
|
</TestContainer>
|
|
@@ -224,7 +231,10 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
|
|
|
|
|
cy.mount(
|
|
cy.mount(
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
- <EditorProviders scope={scope}>
|
|
|
|
|
|
|
+ <EditorProviders
|
|
|
|
|
+ scope={scope}
|
|
|
|
|
+ features={{ trackChangesVisible: true }}
|
|
|
|
|
+ >
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
|
</EditorProviders>
|
|
</EditorProviders>
|
|
|
</TestContainer>
|
|
</TestContainer>
|
|
@@ -369,7 +379,7 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- describe('track changes toggle', function () {
|
|
|
|
|
|
|
+ describe('when clicking the track changes buttons', function () {
|
|
|
let toggleTrackChangesListener: Cypress.Agent<sinon.SinonStub>
|
|
let toggleTrackChangesListener: Cypress.Agent<sinon.SinonStub>
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
@@ -394,11 +404,19 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
<EditorProviders
|
|
<EditorProviders
|
|
|
scope={scope}
|
|
scope={scope}
|
|
|
- projectFeatures={{ trackChanges: true }}
|
|
|
|
|
providers={{
|
|
providers={{
|
|
|
EditorPropertiesProvider: makeEditorPropertiesProvider({
|
|
EditorPropertiesProvider: makeEditorPropertiesProvider({
|
|
|
wantTrackChanges: false,
|
|
wantTrackChanges: false,
|
|
|
}),
|
|
}),
|
|
|
|
|
+ ProjectProvider: makeProjectProvider(
|
|
|
|
|
+ mockProject({
|
|
|
|
|
+ trackChangesState: false,
|
|
|
|
|
+ projectFeatures: {
|
|
|
|
|
+ trackChanges: true,
|
|
|
|
|
+ trackChangesVisible: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ ),
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
@@ -432,11 +450,17 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
<EditorProviders
|
|
<EditorProviders
|
|
|
scope={scope}
|
|
scope={scope}
|
|
|
- projectFeatures={{ trackChanges: true }}
|
|
|
|
|
providers={{
|
|
providers={{
|
|
|
- EditorPropertiesProvider: makeEditorPropertiesProvider({
|
|
|
|
|
- wantTrackChanges: true,
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ ProjectProvider: makeProjectProvider(
|
|
|
|
|
+ mockProject({
|
|
|
|
|
+ // Re-assigns `withTrackChanges` value in the `track-changes-state-context` useEffect hook
|
|
|
|
|
+ trackChangesState: true,
|
|
|
|
|
+ projectFeatures: {
|
|
|
|
|
+ trackChanges: true,
|
|
|
|
|
+ trackChangesVisible: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ ),
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
@@ -463,14 +487,40 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
cy.get('@toggleTrackChanges').should('have.been.calledOnce')
|
|
cy.get('@toggleTrackChanges').should('have.been.calledOnce')
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('should disable suggest edits when project does not support track changes', function () {
|
|
|
|
|
|
|
+ it('should open upgrade modal when user does not support track changes', function () {
|
|
|
|
|
+ const scope = mockScope()
|
|
|
|
|
+
|
|
|
|
|
+ cy.mount(
|
|
|
|
|
+ <TestContainer>
|
|
|
|
|
+ <EditorProviders
|
|
|
|
|
+ scope={scope}
|
|
|
|
|
+ features={{ trackChangesVisible: true, trackChanges: false }}
|
|
|
|
|
+ >
|
|
|
|
|
+ <CodeMirrorEditor />
|
|
|
|
|
+ </EditorProviders>
|
|
|
|
|
+ </TestContainer>
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ cy.get('.cm-line').eq(10).rightclick()
|
|
|
|
|
+
|
|
|
|
|
+ cy.findByRole('menu').within(() => {
|
|
|
|
|
+ cy.findByRole('menuitem', { name: /suggest edits/i }).click()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ cy.findByRole('dialog').should('be.visible')
|
|
|
|
|
+ cy.findByRole('dialog').should('contain.text', 'Upgrade to Review')
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('when trackChangesVisible feature is disabled', function () {
|
|
|
|
|
+ it('should hide the track changes button', function () {
|
|
|
const scope = mockScope()
|
|
const scope = mockScope()
|
|
|
|
|
|
|
|
cy.mount(
|
|
cy.mount(
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
<EditorProviders
|
|
<EditorProviders
|
|
|
scope={scope}
|
|
scope={scope}
|
|
|
- projectFeatures={{ trackChanges: false }}
|
|
|
|
|
|
|
+ features={{ trackChangesVisible: false }}
|
|
|
>
|
|
>
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
|
</EditorProviders>
|
|
</EditorProviders>
|
|
@@ -481,9 +531,10 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
|
|
|
|
|
cy.findByRole('menu').within(() => {
|
|
cy.findByRole('menu').within(() => {
|
|
|
cy.findByRole('menuitem', { name: /suggest edits/i }).should(
|
|
cy.findByRole('menuitem', { name: /suggest edits/i }).should(
|
|
|
- 'have.attr',
|
|
|
|
|
- 'aria-disabled',
|
|
|
|
|
- 'true'
|
|
|
|
|
|
|
+ 'not.exist'
|
|
|
|
|
+ )
|
|
|
|
|
+ cy.findByRole('menuitem', { name: /back to editing/i }).should(
|
|
|
|
|
+ 'not.exist'
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -559,6 +610,9 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
cy.findByRole('menuitem', { name: /suggest edits/i }).should(
|
|
cy.findByRole('menuitem', { name: /suggest edits/i }).should(
|
|
|
'not.exist'
|
|
'not.exist'
|
|
|
)
|
|
)
|
|
|
|
|
+ cy.findByRole('menuitem', { name: /back to editing/i }).should(
|
|
|
|
|
+ 'not.exist'
|
|
|
|
|
+ )
|
|
|
cy.findByRole('menuitem', { name: /comment/i }).should('be.enabled')
|
|
cy.findByRole('menuitem', { name: /comment/i }).should('be.enabled')
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -821,7 +875,6 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
<EditorProviders
|
|
<EditorProviders
|
|
|
scope={scope}
|
|
scope={scope}
|
|
|
- projectFeatures={{ trackChangesVisible: true }}
|
|
|
|
|
features={{ trackChangesVisible: true }}
|
|
features={{ trackChangesVisible: true }}
|
|
|
>
|
|
>
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
@@ -964,7 +1017,10 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
|
|
|
|
|
|
|
cy.mount(
|
|
cy.mount(
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
- <EditorProviders scope={scope}>
|
|
|
|
|
|
|
+ <EditorProviders
|
|
|
|
|
+ scope={scope}
|
|
|
|
|
+ features={{ trackChangesVisible: true }}
|
|
|
|
|
+ >
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
|
</EditorProviders>
|
|
</EditorProviders>
|
|
|
</TestContainer>
|
|
</TestContainer>
|