1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Chore: Fix CI (#11281)

This commit is contained in:
Henry Heino 2024-10-28 15:07:49 -07:00 committed by GitHub
parent f4ee4a178e
commit cce6898d83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 7 deletions

View File

@ -34,11 +34,11 @@ describe('renderMarkup', () => {
{
const note = await Note.save({ });
await shim.attachFileToNote(note, testImagePath, null, { resizeLargeImages: 'never' });
await shim.attachFileToNote(note, testImagePath, { resizeLargeImages: 'never' });
const resource = (await Resource.all())[0];
const noteBody = (await Note.load(note.id)).body;
const renderedNote = await await command.execute(null, MarkupLanguage.Markdown, noteBody);
expect(renderedNote.html).toContain(`<div id="rendered-md"><p><img data-from-md data-resource-id="${resource.id}" src="joplin-content://note-viewer//Users/laurent/src/joplin/packages/lib/testing/../../app-cli/tests/test data/`);
expect(renderedNote.html).toContain(`<div id="rendered-md"><p><img data-from-md data-resource-id="${resource.id}" src="joplin-content://note-viewer/`);
expect(renderedNote.html).toContain(`/resources-1/${resource.id}.jpg?t=`);
expect(renderedNote.html).toContain('" title alt="photo.jpg" /></p>');
}

View File

@ -416,11 +416,10 @@ function shimInit(options: ShimInitOptions = null) {
return newBody.join('\n\n');
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
shim.attachFileToNote = async function(note, filePath, position: number = null, options: any = null) {
shim.attachFileToNote = async function(note, filePath, options = {}) {
if (!options) options = {};
if (note.markup_language) options.markupLanguage = note.markup_language;
const newBody = await shim.attachFileToNoteBody(note.body, filePath, position, options);
const newBody = await shim.attachFileToNoteBody(note.body, filePath, options.position ?? 0, options);
if (!newBody) return null;
const newNote = { ...note, body: newBody };

View File

@ -3,6 +3,7 @@ import { NoteEntity, ResourceEntity } from './services/database/types';
import type FsDriverBase from './fs-driver-base';
import type FileApiDriverLocal from './file-api-driver-local';
import { Crypto } from './services/e2ee/types';
import { MarkupLanguage } from '@joplin/renderer';
export interface CreateResourceFromPathOptions {
resizeLargeImages?: 'always' | 'never' | 'ask';
@ -33,6 +34,12 @@ interface FetchOptions {
agent?: unknown;
}
interface AttachFileToNoteOptions {
resizeLargeImages?: 'always'|'never';
position?: number;
markupLanguage?: MarkupLanguage;
}
let isTestingEnv_ = false;
// We need to ensure that there's only one instance of React being used by all
@ -308,8 +315,7 @@ const shim = {
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
detectAndSetLocale: null as Function,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
attachFileToNote: async (_note: any, _filePath: string, _position: number, _options: any): Promise<NoteEntity> => {
attachFileToNote: async (_note: NoteEntity, _filePath: string, _options?: AttachFileToNoteOptions): Promise<NoteEntity> => {
throw new Error('Not implemented: attachFileToNote');
},