feat: Upgrade editor (#1227)
* WIP * document migration * fix: Handle clashing keyboard events * fix: convert getSummary * fix: parseDocumentIds * lint * fix: Remove unused plugin * Move editor version to header Add editor version check for API endpoints * fix: Editor update auto-reload Bump RME * test * bump rme * Remove slate flow types, improve themeing, bump rme * bump rme * fix: parseDocumentIds returning duplicate ID's, improved regression tests * test * fix: Missing code styles * lint * chore: Upgrade v2 migration to use AST * Bump RME * Update welcome doc * add highlight to keyboard shortcuts ref * theming improvements * fix: Code comments show as headings, closes #1255 * loop * fix: TOC highlighting * lint * add: Automated backup of docs before migration * Update embeds to new format * fix: React warning * bump to final editor version 10.0.0 * test
This commit is contained in:
@@ -6,6 +6,155 @@ import { buildDocument, buildCollection, buildTeam } from '../test/factories';
|
||||
beforeEach(flushdb);
|
||||
beforeEach(jest.resetAllMocks);
|
||||
|
||||
describe('#getSummary', () => {
|
||||
test('should strip markdown', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `*paragraph*
|
||||
|
||||
paragraph 2`,
|
||||
});
|
||||
|
||||
expect(document.getSummary()).toBe('paragraph');
|
||||
});
|
||||
|
||||
test('should strip title when no version', async () => {
|
||||
const document = await buildDocument({
|
||||
version: null,
|
||||
text: `# Heading
|
||||
|
||||
*paragraph*`,
|
||||
});
|
||||
|
||||
expect(document.getSummary()).toBe('paragraph');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#migrateVersion', () => {
|
||||
test('should maintain empty paragraph under headings', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `# Heading
|
||||
|
||||
paragraph`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`# Heading
|
||||
|
||||
paragraph`);
|
||||
});
|
||||
|
||||
test('should add breaks under headings with extra paragraphs', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `# Heading
|
||||
|
||||
|
||||
paragraph`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`# Heading
|
||||
|
||||
|
||||
\\
|
||||
paragraph`);
|
||||
});
|
||||
|
||||
test('should add breaks between paragraphs', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `paragraph
|
||||
|
||||
paragraph`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`paragraph
|
||||
|
||||
\\
|
||||
paragraph`);
|
||||
});
|
||||
|
||||
test('should add breaks for multiple empty paragraphs', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `paragraph
|
||||
|
||||
|
||||
paragraph`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`paragraph
|
||||
|
||||
\\
|
||||
\\
|
||||
paragraph`);
|
||||
});
|
||||
|
||||
test('should add breaks with non-latin characters', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `除。
|
||||
|
||||
通`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`除。
|
||||
|
||||
\\
|
||||
通`);
|
||||
});
|
||||
|
||||
test('should update task list formatting', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `[ ] list item
|
||||
`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`- [ ] list item
|
||||
`);
|
||||
});
|
||||
|
||||
test('should update task list with multiple items', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `[ ] list item
|
||||
[ ] list item 2
|
||||
`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`- [ ] list item
|
||||
- [ ] list item 2
|
||||
`);
|
||||
});
|
||||
|
||||
test('should update checked task list formatting', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `[x] list item
|
||||
`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`- [x] list item
|
||||
`);
|
||||
});
|
||||
|
||||
test('should update nested task list formatting', async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `[x] list item
|
||||
[ ] list item
|
||||
[x] list item
|
||||
`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`- [x] list item
|
||||
- [ ] list item
|
||||
- [x] list item
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#searchForTeam', () => {
|
||||
test('should return search results from public collections', async () => {
|
||||
const team = await buildTeam();
|
||||
|
||||
Reference in New Issue
Block a user