2023-04-27 14:45:13 -04:00
|
|
|
import Toolbar from '../../../../../frontend/js/features/history/components/diff-view/toolbar/toolbar'
|
|
|
|
import { HistoryProvider } from '../../../../../frontend/js/features/history/context/history-context'
|
2023-04-20 11:41:44 -04:00
|
|
|
import { HistoryContextValue } from '../../../../../frontend/js/features/history/context/types/history-context-value'
|
|
|
|
import { Diff } from '../../../../../frontend/js/features/history/services/types/doc'
|
2023-04-27 14:45:13 -04:00
|
|
|
import { EditorProviders } from '../../../helpers/editor-providers'
|
2023-04-20 11:41:44 -04:00
|
|
|
|
|
|
|
describe('history toolbar', function () {
|
2023-04-27 14:45:13 -04:00
|
|
|
const editorProvidersScope = {
|
|
|
|
ui: { view: 'history', pdfLayout: 'sideBySide', chatOpen: true },
|
|
|
|
}
|
|
|
|
|
2023-04-20 11:41:44 -04:00
|
|
|
const diff: Diff = {
|
|
|
|
binary: false,
|
|
|
|
docDiff: {
|
|
|
|
highlights: [
|
|
|
|
{
|
|
|
|
range: {
|
|
|
|
from: 0,
|
|
|
|
to: 3,
|
|
|
|
},
|
|
|
|
hue: 1,
|
|
|
|
type: 'addition',
|
|
|
|
label: 'label',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
doc: 'doc',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
it('renders viewing mode', function () {
|
|
|
|
const selection: HistoryContextValue['selection'] = {
|
|
|
|
updateRange: {
|
|
|
|
fromV: 3,
|
|
|
|
toV: 6,
|
|
|
|
fromVTimestamp: 1681413775958,
|
|
|
|
toVTimestamp: 1681413775958,
|
|
|
|
},
|
|
|
|
comparing: false,
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
pathname: 'main.tex',
|
|
|
|
operation: 'edited',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pathname: 'sample.bib',
|
2023-05-25 06:20:57 -04:00
|
|
|
editable: true,
|
2023-04-20 11:41:44 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
pathname: 'frog.jpg',
|
2023-05-25 06:20:57 -04:00
|
|
|
editable: false,
|
2023-04-20 11:41:44 -04:00
|
|
|
},
|
|
|
|
],
|
2023-04-27 14:45:13 -04:00
|
|
|
selectedFile: {
|
|
|
|
pathname: 'main.tex',
|
2023-05-25 06:20:57 -04:00
|
|
|
editable: true,
|
2023-04-27 14:45:13 -04:00
|
|
|
},
|
2023-04-20 11:41:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
cy.mount(
|
2023-04-27 14:45:13 -04:00
|
|
|
<EditorProviders scope={editorProvidersScope}>
|
|
|
|
<HistoryProvider>
|
|
|
|
<div className="history-react">
|
|
|
|
<Toolbar diff={diff} selection={selection} />
|
|
|
|
</div>
|
|
|
|
</HistoryProvider>
|
|
|
|
</EditorProviders>
|
2023-04-20 11:41:44 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
cy.get('.history-react-toolbar').within(() => {
|
|
|
|
cy.get('div:first-child').contains('Viewing 13th April')
|
|
|
|
})
|
|
|
|
|
2023-04-27 14:45:13 -04:00
|
|
|
cy.get('.history-react-toolbar-file-info').contains('1 change in main.tex')
|
2023-04-20 11:41:44 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('renders comparing mode', function () {
|
|
|
|
const selection: HistoryContextValue['selection'] = {
|
|
|
|
updateRange: {
|
|
|
|
fromV: 0,
|
|
|
|
toV: 6,
|
|
|
|
fromVTimestamp: 1681313775958,
|
|
|
|
toVTimestamp: 1681413775958,
|
|
|
|
},
|
|
|
|
comparing: true,
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
pathname: 'main.tex',
|
|
|
|
operation: 'added',
|
2023-05-25 06:20:57 -04:00
|
|
|
editable: true,
|
2023-04-20 11:41:44 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
pathname: 'sample.bib',
|
|
|
|
operation: 'added',
|
2023-05-25 06:20:57 -04:00
|
|
|
editable: true,
|
2023-04-20 11:41:44 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
pathname: 'frog.jpg',
|
|
|
|
operation: 'added',
|
2023-05-25 06:20:57 -04:00
|
|
|
editable: false,
|
2023-04-20 11:41:44 -04:00
|
|
|
},
|
|
|
|
],
|
2023-04-27 14:45:13 -04:00
|
|
|
selectedFile: {
|
|
|
|
pathname: 'main.tex',
|
2023-05-25 06:20:57 -04:00
|
|
|
editable: true,
|
2023-04-27 14:45:13 -04:00
|
|
|
},
|
2023-04-20 11:41:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
cy.mount(
|
2023-04-27 14:45:13 -04:00
|
|
|
<EditorProviders scope={editorProvidersScope}>
|
|
|
|
<HistoryProvider>
|
|
|
|
<div className="history-react">
|
|
|
|
<Toolbar diff={diff} selection={selection} />
|
|
|
|
</div>
|
|
|
|
</HistoryProvider>
|
|
|
|
</EditorProviders>
|
2023-04-20 11:41:44 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
cy.get('.history-react-toolbar').within(() => {
|
2023-05-22 06:11:21 -04:00
|
|
|
cy.get('div:first-child').contains('Comparing from 12th April')
|
2023-04-20 11:41:44 -04:00
|
|
|
|
|
|
|
cy.get('div:first-child').contains('to 13th April')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|