test: add test case for blocksuite editor (#1528)

This commit is contained in:
Himself65
2023-03-10 17:45:10 -06:00
committed by GitHub
parent 1c89841d6f
commit a795000363
19 changed files with 495 additions and 488 deletions
@@ -1,5 +0,0 @@
import { Editor, EditorProps } from '@blocksuite/react/editor';
export type BlockSuiteEditorProps = EditorProps;
export const BlockSuiteEditor = (props: BlockSuiteEditorProps) => {
return <Editor {...props} />;
};
@@ -1,59 +0,0 @@
import { MigrationError } from '@blocksuite/global/error';
import React, { Component, ErrorInfo } from 'react';
export type BlockSuiteErrorBoundaryProps = React.PropsWithChildren;
type BlockSuiteError = MigrationError | Error;
interface BlockSuiteErrorBoundaryState {
error: BlockSuiteError | null;
}
export class BlockSuiteErrorBoundary extends Component<
BlockSuiteErrorBoundaryProps,
BlockSuiteErrorBoundaryState
> {
public state: BlockSuiteErrorBoundaryState = {
error: null,
};
public static getDerivedStateFromError(
error: BlockSuiteError
): BlockSuiteErrorBoundaryState {
return { error };
}
public componentDidCatch(error: BlockSuiteError, errorInfo: ErrorInfo) {
console.error('Uncaught error:', error, errorInfo);
}
public render() {
if (this.state.error) {
const isMigrationError = this.state.error instanceof MigrationError;
return (
<>
<h1>Sorry.. there was an error</h1>
{isMigrationError ? (
<>
<span> Migration error </span>
<span>
{' '}
Please open a ticket in{' '}
<a
target="_blank"
href="https://github.com/toeverything/blocksuite/issues"
rel="noreferrer"
>
BlockSuite Github Issue
</a>
</span>
</>
) : null}
</>
);
}
return this.props.children;
}
}