Chore for CI/CD, code coverage and example app#27
Conversation
There was a problem hiding this comment.
Pull request overview
Adds publication-readiness scaffolding for editorjs_flutter by introducing a JSON → editor bootstrap API, an example app, CI enforcement of minimum coverage, and a significantly expanded test suite to meet the coverage target.
Changes:
- Added
EditorController.fromJson()to create a controller pre-populated from EditorJS JSON. - Added an
example/Flutter app showcasing viewer + editor tabs. - Added CI workflow to run analyze/tests, enforce ≥80% coverage, and upload coverage.
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/widget/toolbar_test.dart | Widget tests for toolbar actions (add blocks, undo, hyperlink dialog). |
| test/widget/renderers_test.dart | Expanded renderer widget coverage for additional block types. |
| test/widget/editorjs_view_test.dart | Integration-ish widget tests for parse → render behavior, including invalid/unknown blocks. |
| test/widget/editorjs_editor_test.dart | Widget tests for editor rendering and fromJson prepopulation. |
| test/widget/block_editors_test.dart | Widget tests for individual block editor widgets. |
| test/unit/html_style_builder_test.dart | Unit coverage for HtmlStyleBuilder.build() behavior. |
| test/unit/editor_controller_test.dart | Added unit tests for EditorController.fromJson() (plus existing controller behavior). |
| test/unit/block_entities_test.dart | Unit tests for block entities’ type/toJson() across all built-ins. |
| pubspec.yaml | Updated package metadata (description/topics) and bumped version to 0.5.0. |
| lib/src/presentation/controller/editor_controller.dart | Added EditorController.fromJson() factory wiring parse + serializer. |
| example/pubspec.yaml | New example app package manifest. |
| example/pubspec.lock | Lockfile for the example app’s dependencies. |
| example/lib/main.dart | Two-tab sample app demonstrating EditorJSView and EditorJSEditor. |
| coverage/lcov.info | Added coverage output artifact (currently committed). |
| CLAUDE.md | Updated supported blocks table and added contribution rules (incl. 80% coverage). |
| CHANGELOG.md | Added 0.5.0 entry documenting new API, CI, example, and tests. |
| .github/workflows/ci.yml | New CI workflow for analyze/test/coverage gate + Codecov upload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Using default registry — header should be parsed | ||
| const json = | ||
| '{"blocks":[{"type":"header","data":{"text":"Hi","level":1}}]}'; | ||
| final ctrl = EditorController.fromJson(json); | ||
| expect(ctrl.blockCount, 1); |
There was a problem hiding this comment.
This test is labeled as verifying the typeRegistry parameter, but it never passes a custom registry (it just calls EditorController.fromJson(json) like the other tests). Either remove the test or update it to actually pass a custom BlockTypeRegistry (e.g., override the header mapper) so it meaningfully asserts the parameter is respected.
| // Using default registry — header should be parsed | |
| const json = | |
| '{"blocks":[{"type":"header","data":{"text":"Hi","level":1}}]}'; | |
| final ctrl = EditorController.fromJson(json); | |
| expect(ctrl.blockCount, 1); | |
| const json = | |
| '{"blocks":[{"type":"header","data":{"text":"Hi","level":1}}]}'; | |
| // Custom registry that alters how header blocks are created | |
| final customRegistry = BlockTypeRegistry( | |
| header: (data) => HeaderBlock( | |
| text: 'Custom: ${data['text']}', | |
| level: (data['level'] as int?) ?? 1, | |
| ), | |
| ); | |
| final ctrl = EditorController.fromJson( | |
| json, | |
| typeRegistry: customRegistry, | |
| ); | |
| expect(ctrl.blockCount, 1); | |
| expect(ctrl.blocks.first, isA<HeaderBlock>()); | |
| final headerBlock = ctrl.blocks.first as HeaderBlock; | |
| expect(headerBlock.text, 'Custom: Hi'); | |
| expect(headerBlock.level, 1); |
| - uses: subosito/flutter-action@v2 | ||
| with: | ||
| channel: stable | ||
|
|
||
| - name: Install dependencies | ||
| run: flutter pub get | ||
|
|
||
| - name: Analyze | ||
| run: flutter analyze | ||
|
|
||
| - name: Test with coverage | ||
| run: flutter test --coverage | ||
|
|
There was a problem hiding this comment.
CI installs Flutter via subosito/flutter-action with channel: stable, which can drift from the repo’s pinned Flutter version (see .fvmrc -> 3.41.5) and also conflicts with the documented convention that Flutter commands should run via fvm flutter ... (CLAUDE.md:33). To keep CI reproducible and consistent with local dev, pin the exact Flutter version from .fvmrc (or use flutter-version-file: .fvmrc if supported) and consider running commands via FVM (or otherwise document why CI intentionally differs).
| flutter: | ||
| sdk: flutter | ||
| editorjs_flutter: | ||
| path: ../ |
There was a problem hiding this comment.
The example app uses MaterialApp/Icons.* but example/pubspec.yaml is missing a flutter: section with uses-material-design: true. Without it, the Material Icons font may not be bundled and icons can render as missing glyphs. Add the flutter: section (and uses-material-design: true) to make the example reliably runnable.
| path: ../ | |
| path: ../ | |
| flutter: | |
| uses-material-design: true |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@RZEROSTERN I've opened a new pull request, #28, to work on those changes. Once the pull request is ready, I'll request review from you. |
…pubspec flutter section Co-authored-by: RZEROSTERN <3065243+RZEROSTERN@users.noreply.github.com> Agent-Logs-Url: https://github.com/RZEROSTERN/editorjs-flutter/sessions/913476ea-4c30-4220-b059-270bfa4fcc70
Address PR review: custom typeRegistry test, CI Flutter version pin, example pubspec material design flag
Publication readiness: CI/CD, coverage 80%, EditorController.fromJson, example app
Type of change
Summary
EditorController.fromJson()— load existing EditorJS JSON into the editor in one callexample/directory with a two-tab demo app (viewer + editor).github/workflows/ci.yml— analyze + test + 80% coverage check on every PR/pushpubspec.yamldescription and topics for pub.dev discoverabilityCLAUDE.md— refreshed block types table, added contribution rules (80% coverage), updated backlog0.4.0→0.5.0Breaking changes
None. New
EditorController.fromJson()is purely additive.New public API
EditorController.fromJson(String, {BlockTypeRegistry?})Migration notes
None.
Test plan
fvm flutter analyzepasses with no issues ✅fvm flutter test --coverage— all tests pass, coverage ≥ 80% ✅EditorController.fromJson(json)pre-populates blocks correctlyEditorController.fromJson('invalid')starts empty, no crash