diff --git a/packages/lib/services/interop/InteropService_Importer_OneNote.test.ts b/packages/lib/services/interop/InteropService_Importer_OneNote.test.ts index a85e461eb3..0240ab43d4 100644 --- a/packages/lib/services/interop/InteropService_Importer_OneNote.test.ts +++ b/packages/lib/services/interop/InteropService_Importer_OneNote.test.ts @@ -9,6 +9,7 @@ import InteropService from './InteropService'; import InteropService_Importer_OneNote from './InteropService_Importer_OneNote'; import { JSDOM } from 'jsdom'; import { ImportModuleOutputFormat } from './types'; +import HtmlToMd from '../../HtmlToMd'; const instructionMessage = ` -------------------------------------- @@ -26,6 +27,21 @@ const removeItemIds = (body: string) => { return body.replace(/:\/[a-z0-9]{32}/g, ':/id-here'); }; +const removeDefaultCss = (body: string) => { + const defaultCssStart = body.indexOf('/*** Start default CSS ***/'); + const endMarker = '/*** End default CSS ***/'; + const defaultCssEnd = body.indexOf(endMarker); + if (defaultCssEnd === -1 || defaultCssStart === -1) return body; + + const before = body.substring(0, defaultCssStart); + const after = body.substring(defaultCssEnd + endMarker.length); + return [before, '/* (For testing: Removed default CSS) */', after].join('\n'); +}; + +const normalizeNoteForSnapshot = (body: string) => { + return removeItemIds(removeDefaultCss(body)); +}; + // This file is ignored if not running in CI. Look at onenote-converter/README.md and jest.config.js for more information describe('InteropService_Importer_OneNote', () => { let tempDir: string; @@ -68,7 +84,7 @@ describe('InteropService_Importer_OneNote', () => { expectWithInstructions(mainNote.title).toBe('Page title'); expectWithInstructions(mainNote.markup_language).toBe(MarkupToHtml.MARKUP_LANGUAGE_HTML); - expectWithInstructions(mainNote.body).toMatchSnapshot(mainNote.title); + expectWithInstructions(normalizeNoteForSnapshot(mainNote.body)).toMatchSnapshot(mainNote.title); }); it('should preserve indentation of subpages in Section page', async () => { @@ -121,7 +137,7 @@ describe('InteropService_Importer_OneNote', () => { expectWithInstructions(notes.filter(n => n.parent_id === parentSection.id).length).toBe(6); for (const note of notes) { - expectWithInstructions(note.body).toMatchSnapshot(note.title); + expectWithInstructions(normalizeNoteForSnapshot(note.body)).toMatchSnapshot(note.title); } BaseModel.setIdGenerator(originalIdGenerator); }); @@ -186,7 +202,9 @@ describe('InteropService_Importer_OneNote', () => { const originalIdGenerator = BaseModel.setIdGenerator(() => String(idx++)); const notes = await importNote(`${supportDir}/onenote/bug_broken_character.zip`); - expectWithInstructions(notes.find(n => n.title === 'Action research - Wikipedia').body).toMatchSnapshot(); + expectWithInstructions( + normalizeNoteForSnapshot(notes.find(n => n.title === 'Action research - Wikipedia').body), + ).toMatchSnapshot(); BaseModel.setIdGenerator(originalIdGenerator); }); @@ -197,7 +215,7 @@ describe('InteropService_Importer_OneNote', () => { const notes = await importNote(`${supportDir}/onenote/remove_hyperlink_on_title.zip`); for (const note of notes) { - expectWithInstructions(note.body).toMatchSnapshot(note.title); + expectWithInstructions(normalizeNoteForSnapshot(note.body)).toMatchSnapshot(note.title); } BaseModel.setIdGenerator(originalIdGenerator); }); @@ -217,7 +235,7 @@ describe('InteropService_Importer_OneNote', () => { const notes = await importNote(`${supportDir}/onenote/hyperlink_marker_as_first_character.zip`); for (const note of notes) { - expectWithInstructions(note.body).toMatchSnapshot(note.title); + expectWithInstructions(normalizeNoteForSnapshot(note.body)).toMatchSnapshot(note.title); } BaseModel.setIdGenerator(originalIdGenerator); }); @@ -230,7 +248,7 @@ describe('InteropService_Importer_OneNote', () => { expectWithInstructions(notes.length).toBe(2); for (const note of notes) { - expectWithInstructions(note.body).toMatchSnapshot(note.title); + expectWithInstructions(normalizeNoteForSnapshot(note.body)).toMatchSnapshot(note.title); } BaseModel.setIdGenerator(originalIdGenerator); }); @@ -243,7 +261,7 @@ describe('InteropService_Importer_OneNote', () => { expectWithInstructions(notes.length).toBe(2); for (const note of notes) { - expectWithInstructions(note.body).toMatchSnapshot(note.title); + expectWithInstructions(normalizeNoteForSnapshot(note.body)).toMatchSnapshot(note.title); } BaseModel.setIdGenerator(originalIdGenerator); }); @@ -253,11 +271,11 @@ describe('InteropService_Importer_OneNote', () => { // InkBias bug const note1Content = notes.find(n => n.title === 'Marketing Funnel & Training').body; - expect(removeItemIds(note1Content)).toMatchSnapshot(); + expect(normalizeNoteForSnapshot(note1Content)).toMatchSnapshot(); // EntityGuid const note2Content = notes.find(n => n.title === 'Decrease support costs').body; - expect(removeItemIds(note2Content)).toMatchSnapshot(); + expect(normalizeNoteForSnapshot(note2Content)).toMatchSnapshot(); }); it('should support directly importing .one files', async () => { @@ -277,7 +295,16 @@ describe('InteropService_Importer_OneNote', () => { it('should support importing .one files that contain checkboxes', async () => { const notes = await importNote(`${supportDir}/onenote/checkboxes_and_unicode.one`); expectWithInstructions( - removeItemIds(notes.find(n => n.title.startsWith('Test Todo')).body), + normalizeNoteForSnapshot(notes.find(n => n.title.startsWith('Test Todo')).body), ).toMatchSnapshot(); }); + + it('should correctly convert imported notes to Markdown', async () => { + const notes = await importNote(`${supportDir}/onenote/checkboxes_and_unicode.one`); + const checklistNote = notes.find(n => n.title.startsWith('Test Todo')); + const converter = new HtmlToMd(); + const markdown = converter.parse(checklistNote.body); + + expect(markdown).toMatchSnapshot('Test Todo: As Markdown'); + }); }); diff --git a/packages/lib/services/interop/__snapshots__/InteropService_Importer_OneNote.test.js.snap b/packages/lib/services/interop/__snapshots__/InteropService_Importer_OneNote.test.js.snap index ad264e9cd0..6193da8fc6 100644 --- a/packages/lib/services/interop/__snapshots__/InteropService_Importer_OneNote.test.js.snap +++ b/packages/lib/services/interop/__snapshots__/InteropService_Importer_OneNote.test.js.snap @@ -104,19 +104,9 @@ exports[`InteropService_Importer_OneNote should be able to create notes from cor title @@ -138,25 +128,41 @@ exports[`InteropService_Importer_OneNote should be able to create notes from cor " `; +exports[`InteropService_Importer_OneNote should correctly convert imported notes to Markdown: Test Todo: As Markdown 1`] = ` +" Test Todo : cases à cocher lien vers doc sur partage + +Test Todo : cases à cocher lien vers doc sur partage + +jeudi 23 octobre 2025 + +09:24 + +## Todo HBA + +- [x] Rédiger carnet MS-OneNote jeu d'essai (case cochée) +- [ ] Transmettre aux dev Joplin (case non cochée) + - [x] Exporter le carnet en \\*.packageone (case cochée) + - [ ] Exporter des page en \\*.one (case non cochée) + +  + +## Todo Team appli + +- [ ] Rédiger compte-rendu réunion de service +- [ ] Rédiger présentation service Joplin et fonctionnalités complémentaires associée à JBS + la doc sur le partage : [\\\\\\\\mondomaine.local\\\\partage\\\\DSI\\\\Projets Techniques 2025\\\\Remplacement Office\\\\JOPLIN_Alternatives_OneNote\\\\formation](file:///\\\\mondomaine.local\\partage\\DSI\\Projets%20Techniques%202025\\Remplacement%20Office\\JOPLIN_Alternatives_OneNote\\formation) + - [x] Documenter configuration synchro JBS saml pour un utilisateur (case cochée)" +`; + exports[`InteropService_Importer_OneNote should expect notes to be rendered the same: A page can have any width it wants 1`] = ` " A page can have any width it wants? @@ -186,19 +192,9 @@ exports[`InteropService_Importer_OneNote should expect notes to be rendered the A page with a lot of svgs @@ -226,19 +222,9 @@ exports[`InteropService_Importer_OneNote should expect notes to be rendered the A page with text and drawing above it @@ -272,19 +258,9 @@ exports[`InteropService_Importer_OneNote should expect notes to be rendered the A simple filename @@ -312,19 +288,9 @@ exports[`InteropService_Importer_OneNote should expect notes to be rendered the Page with more than one font size @@ -462,19 +428,9 @@ exports[`InteropService_Importer_OneNote should expect notes to be rendered the text @@ -814,19 +770,9 @@ exports[`InteropService_Importer_OneNote should ignore broken characters at the Action research - Wikipedia @@ -1031,19 +967,9 @@ exports[`InteropService_Importer_OneNote should remove hyperlink from title: Tip Tips from a Pro: Using Trees for Dramatic Landscape Photography @@ -1072,19 +998,9 @@ exports[`InteropService_Importer_OneNote should remove hyperlink from title: wik wikipedia link @@ -1113,19 +1029,9 @@ exports[`InteropService_Importer_OneNote should remove hyperlink from title: 风 风景 (Web view) @@ -1154,19 +1060,9 @@ exports[`InteropService_Importer_OneNote should remove hyperlink from title: 风 风景 @@ -1194,19 +1090,9 @@ exports[`InteropService_Importer_OneNote should render audio as links to resourc My title @@ -1337,19 +1223,9 @@ exports[`InteropService_Importer_OneNote should render links properly by ignorin Is Mexico safe for shooting Street Photography? @@ -1476,27 +1352,17 @@ exports[`InteropService_Importer_OneNote should support importing .one files tha Test Todo : cases à cocher lien vers doc sur partage @@ -1506,23 +1372,23 @@ exports[`InteropService_Importer_OneNote should support importing .one files tha
jeudi 23 octobre 2025
09:24

Todo HBA

-

Checked -Rédiger carnet MS-OneNote jeu d'essai (case cochée)

-

Unchecked -Transmettre aux dev Joplin (case non cochée)

Checked -Exporter le carnet en *.packageone (case cochée)

-

Unchecked -Exporter des page en *.one (case non cochée)

- -

 

+

 

Todo Team appli

-

Unchecked -Rédiger compte-rendu réunion de service

-

Unchecked -Rédiger présentation service Joplin et fonctionnalités complémentaires associée à JBS
la doc sur le partage : \\\\mondomaine.local\\partage\\DSI\\Projets Techniques 2025\\Remplacement Office\\JOPLIN_Alternatives_OneNote\\formation

Checked -Documenter configuration synchro JBS saml pour un utilisateur (case cochée)

- -
+