SPB Git

Repository Public

V1FixtureGenerator.swift.txt 2.6 KB 36 lines text

1// Author: Simon-Pierre Boucher — contact@spboucher.ai2// File: Tests/AppTests/V1FixtureGenerator.swift3// Description: Writes a data directory with the SHIPPED 1.0.2 code path (app 085a850 + SPNotesCore b06b1ed): the fixture of the 2.0 store-migration test.4import XCTest5import SPNotesDocument6import SPNotesStore7@testable import SPNotes89final class V1FixtureGenerator: XCTestCase {10    @MainActor func testWriteFixture() async throws {11        let out = URL(fileURLWithPath: ProcessInfo.processInfo.environment["SPNOTES_V1_OUT"] ?? NSTemporaryDirectory() + "/spnotes-v1-fixture", isDirectory: true)12        try? FileManager.default.removeItem(at: out)13        let b = await Bench(server: false, dir: out)14        let lib = b.env.library15        let folder = try must(await lib.newNote(title: "Projets", asFolder: true))16        let a = try must(await lib.newNote(title: "Recette de pain", parentId: folder, tags: ["cuisine", "important"]))17        let s = await b.session(a)18        b.type(s, "# Ingrédients\n- farine\n- eau\n- levain\n\n[] acheter du sel\n\nPétrir **longuement** puis cuire.")19        await s.saveNow(reason: "Enregistrement manuel")20        b.end(s); b.type(s, " Laisser reposer une nuit."); try await Task.sleep(for: .milliseconds(700))21        let c = try must(await lib.newNote(title: "Idées de thèse"))22        let sc = await b.session(c); b.type(sc, "Hypothèse : la volatilité intrajournalière prédit les révisions.\n> citation importante\n\n```swift\nlet x = 1"); await sc.saveNow(reason: nil)23        await lib.setFavorite(c, true); await lib.setPinned(c, true)24        let img = NSImage(size: NSSize(width: 40, height: 30)); img.lockFocus(); NSColor.systemBlue.setFill(); NSRect(x: 0, y: 0, width: 40, height: 30).fill(); img.unlockFocus()25        let att = try await AttachmentService(env: b.env).importImage(img, pageId: c)26        sc.editor.textView.insertImage(src: att.src, alt: att.name); await sc.saveNow(reason: nil)27        let d = try must(await lib.newNote(title: "À jeter")); let sd = await b.session(d); b.type(sd, "brouillon"); await sd.saveNow(reason: nil); await lib.trash([d])28        let e = try must(await lib.newNote(title: "Archive 2025")); await lib.setArchived(e, true)29        let q = QuickNoteModel(env: b.env); q.text = "Note rapide\nidée capturée au vol"; await q.finish()30        _ = try must(await lib.newNote(title: ""))   // an untitled, empty note31        await b.env.flushAll(); try await b.env.store.checkpoint(); await b.env.store.close()32        let count = try FileManager.default.contentsOfDirectory(atPath: out.path)33        print("V1 FIXTURE WRITTEN", out.path, count)34    }35}36
Files main
Menu

Theme