|
@@ -1,6 +1,5 @@
|
|
|
import { Folder } from '../../../../../types/folder'
|
|
import { Folder } from '../../../../../types/folder'
|
|
|
import { docId, mockDocContent } from '../helpers/mock-doc'
|
|
import { docId, mockDocContent } from '../helpers/mock-doc'
|
|
|
-import { Metadata } from '../../../../../types/metadata'
|
|
|
|
|
import { mockScope } from '../helpers/mock-scope'
|
|
import { mockScope } from '../helpers/mock-scope'
|
|
|
import { EditorProviders } from '../../../helpers/editor-providers'
|
|
import { EditorProviders } from '../../../helpers/editor-providers'
|
|
|
import CodeMirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor'
|
|
import CodeMirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor'
|
|
@@ -62,42 +61,13 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
- const metadataManager: { metadata: { state: Metadata } } = {
|
|
|
|
|
- metadata: {
|
|
|
|
|
- state: {
|
|
|
|
|
- documents: {
|
|
|
|
|
- [docId]: {
|
|
|
|
|
- labels: ['fig:frog'],
|
|
|
|
|
- // TODO: add tests for packages and referencesKeys autocompletions
|
|
|
|
|
- packages: {
|
|
|
|
|
- foo: [
|
|
|
|
|
- {
|
|
|
|
|
- caption: 'a caption',
|
|
|
|
|
- meta: 'foo-cmd',
|
|
|
|
|
- score: 0.1,
|
|
|
|
|
- snippet: 'a caption{$1}',
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- references: [],
|
|
|
|
|
- fileTreeData: rootFolder[0],
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
const scope = mockScope()
|
|
const scope = mockScope()
|
|
|
scope.$root._references.keys = ['foo']
|
|
scope.$root._references.keys = ['foo']
|
|
|
scope.project.rootFolder = rootFolder
|
|
scope.project.rootFolder = rootFolder
|
|
|
|
|
|
|
|
cy.mount(
|
|
cy.mount(
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
- <EditorProviders
|
|
|
|
|
- scope={scope}
|
|
|
|
|
- metadataManager={metadataManager}
|
|
|
|
|
- rootFolder={rootFolder as any}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <EditorProviders scope={scope} rootFolder={rootFolder as any}>
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
|
</EditorProviders>
|
|
</EditorProviders>
|
|
|
</TestContainer>
|
|
</TestContainer>
|
|
@@ -238,41 +208,12 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
- const metadataManager: { metadata: { state: Metadata } } = {
|
|
|
|
|
- metadata: {
|
|
|
|
|
- state: {
|
|
|
|
|
- documents: {
|
|
|
|
|
- [docId]: {
|
|
|
|
|
- labels: ['fig:frog'],
|
|
|
|
|
- // TODO: add tests for packages and referencesKeys autocompletions
|
|
|
|
|
- packages: {
|
|
|
|
|
- foo: [
|
|
|
|
|
- {
|
|
|
|
|
- caption: 'a caption',
|
|
|
|
|
- meta: 'foo-cmd',
|
|
|
|
|
- score: 0.1,
|
|
|
|
|
- snippet: 'a caption{$1}',
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- references: [],
|
|
|
|
|
- fileTreeData: rootFolder[0],
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
const scope = mockScope()
|
|
const scope = mockScope()
|
|
|
scope.$root._references.keys = ['foo']
|
|
scope.$root._references.keys = ['foo']
|
|
|
|
|
|
|
|
cy.mount(
|
|
cy.mount(
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
- <EditorProviders
|
|
|
|
|
- scope={scope}
|
|
|
|
|
- metadataManager={metadataManager}
|
|
|
|
|
- rootFolder={rootFolder as any}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <EditorProviders scope={scope} rootFolder={rootFolder as any}>
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
|
</EditorProviders>
|
|
</EditorProviders>
|
|
|
</TestContainer>
|
|
</TestContainer>
|
|
@@ -358,33 +299,15 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
+ const metadata = {
|
|
|
|
|
+ commands: [],
|
|
|
|
|
+ labels: new Set<string>(),
|
|
|
|
|
+ packageNames: new Set(['foo']),
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const MetadataProvider: FC = ({ children }) => {
|
|
const MetadataProvider: FC = ({ children }) => {
|
|
|
return (
|
|
return (
|
|
|
- <MetadataContext.Provider
|
|
|
|
|
- value={{
|
|
|
|
|
- metadata: {
|
|
|
|
|
- state: {
|
|
|
|
|
- documents: {
|
|
|
|
|
- [docId]: {
|
|
|
|
|
- labels: [],
|
|
|
|
|
- packages: {
|
|
|
|
|
- foo: [
|
|
|
|
|
- {
|
|
|
|
|
- caption: 'a caption',
|
|
|
|
|
- meta: 'foo-cmd',
|
|
|
|
|
- score: 0.1,
|
|
|
|
|
- snippet: 'a caption{$1}',
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- getAllLabels: () => [],
|
|
|
|
|
- getAllPackages: () => ({ foo: {} }),
|
|
|
|
|
- },
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <MetadataContext.Provider value={metadata}>
|
|
|
{children}
|
|
{children}
|
|
|
</MetadataContext.Provider>
|
|
</MetadataContext.Provider>
|
|
|
)
|
|
)
|
|
@@ -452,36 +375,9 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
|
|
const scope = mockScope()
|
|
const scope = mockScope()
|
|
|
scope.$root._references.keys = ['ref-1', 'ref-2', 'ref-3']
|
|
scope.$root._references.keys = ['ref-1', 'ref-2', 'ref-3']
|
|
|
|
|
|
|
|
- const MetadataProvider: FC = ({ children }) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <MetadataContext.Provider
|
|
|
|
|
- value={{
|
|
|
|
|
- metadata: {
|
|
|
|
|
- state: {
|
|
|
|
|
- documents: {
|
|
|
|
|
- [docId]: {
|
|
|
|
|
- labels: [],
|
|
|
|
|
- packages: {},
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- getAllLabels: () => [],
|
|
|
|
|
- getAllPackages: () => ({}),
|
|
|
|
|
- },
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- {children}
|
|
|
|
|
- </MetadataContext.Provider>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
cy.mount(
|
|
cy.mount(
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
- <EditorProviders
|
|
|
|
|
- scope={scope}
|
|
|
|
|
- providers={MetadataProvider}
|
|
|
|
|
- rootFolder={rootFolder as any}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <EditorProviders scope={scope} rootFolder={rootFolder as any}>
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
|
</EditorProviders>
|
|
</EditorProviders>
|
|
|
</TestContainer>
|
|
</TestContainer>
|
|
@@ -535,31 +431,9 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
|
|
scope.$root._references.keys = ['foo']
|
|
scope.$root._references.keys = ['foo']
|
|
|
scope.project.rootFolder = rootFolder
|
|
scope.project.rootFolder = rootFolder
|
|
|
|
|
|
|
|
- const MetadataProvider: FC = ({ children }) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <MetadataContext.Provider
|
|
|
|
|
- value={{
|
|
|
|
|
- metadata: {
|
|
|
|
|
- state: {
|
|
|
|
|
- documents: {},
|
|
|
|
|
- },
|
|
|
|
|
- getAllLabels: () => [],
|
|
|
|
|
- getAllPackages: () => ({}),
|
|
|
|
|
- },
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- {children}
|
|
|
|
|
- </MetadataContext.Provider>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
cy.mount(
|
|
cy.mount(
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
- <EditorProviders
|
|
|
|
|
- scope={scope}
|
|
|
|
|
- rootFolder={rootFolder as any}
|
|
|
|
|
- providers={MetadataProvider}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <EditorProviders scope={scope} rootFolder={rootFolder as any}>
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
|
</EditorProviders>
|
|
</EditorProviders>
|
|
|
</TestContainer>
|
|
</TestContainer>
|
|
@@ -824,33 +698,22 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
|
|
it('displays unique completions for commands', function () {
|
|
it('displays unique completions for commands', function () {
|
|
|
const scope = mockScope()
|
|
const scope = mockScope()
|
|
|
|
|
|
|
|
|
|
+ const metadata = {
|
|
|
|
|
+ commands: [
|
|
|
|
|
+ {
|
|
|
|
|
+ caption: '\\label{}', // label{} is also included in top-hundred-snippets
|
|
|
|
|
+ meta: 'amsmath-cmd',
|
|
|
|
|
+ score: 1,
|
|
|
|
|
+ snippet: '\\label{$1}',
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ labels: new Set<string>(),
|
|
|
|
|
+ packageNames: new Set<string>('amsmath'),
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const MetadataProvider: FC = ({ children }) => {
|
|
const MetadataProvider: FC = ({ children }) => {
|
|
|
return (
|
|
return (
|
|
|
- <MetadataContext.Provider
|
|
|
|
|
- value={{
|
|
|
|
|
- metadata: {
|
|
|
|
|
- state: {
|
|
|
|
|
- documents: {
|
|
|
|
|
- [docId]: {
|
|
|
|
|
- labels: [],
|
|
|
|
|
- packages: {
|
|
|
|
|
- amsmath: [
|
|
|
|
|
- {
|
|
|
|
|
- caption: '\\label{}',
|
|
|
|
|
- meta: 'amsmath-cmd',
|
|
|
|
|
- score: 1,
|
|
|
|
|
- snippet: '\\label{$1}',
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- getAllLabels: () => [],
|
|
|
|
|
- getAllPackages: () => ({}),
|
|
|
|
|
- },
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <MetadataContext.Provider value={metadata}>
|
|
|
{children}
|
|
{children}
|
|
|
</MetadataContext.Provider>
|
|
</MetadataContext.Provider>
|
|
|
)
|
|
)
|
|
@@ -1033,31 +896,9 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
|
|
scope.$root._references.keys = ['foo']
|
|
scope.$root._references.keys = ['foo']
|
|
|
scope.project.rootFolder = rootFolder
|
|
scope.project.rootFolder = rootFolder
|
|
|
|
|
|
|
|
- const MetadataProvider: FC = ({ children }) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <MetadataContext.Provider
|
|
|
|
|
- value={{
|
|
|
|
|
- metadata: {
|
|
|
|
|
- state: {
|
|
|
|
|
- documents: {},
|
|
|
|
|
- },
|
|
|
|
|
- getAllLabels: () => [],
|
|
|
|
|
- getAllPackages: () => ({}),
|
|
|
|
|
- },
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- {children}
|
|
|
|
|
- </MetadataContext.Provider>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
cy.mount(
|
|
cy.mount(
|
|
|
<TestContainer>
|
|
<TestContainer>
|
|
|
- <EditorProviders
|
|
|
|
|
- scope={scope}
|
|
|
|
|
- providers={MetadataProvider}
|
|
|
|
|
- rootFolder={rootFolder as any}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <EditorProviders scope={scope} rootFolder={rootFolder as any}>
|
|
|
<CodeMirrorEditor />
|
|
<CodeMirrorEditor />
|
|
|
</EditorProviders>
|
|
</EditorProviders>
|
|
|
</TestContainer>
|
|
</TestContainer>
|