Skip to content

Chore for CI/CD, code coverage and example app#27

Merged
RZEROSTERN merged 4 commits intomasterfrom
chore/publication-readiness
Mar 25, 2026
Merged

Chore for CI/CD, code coverage and example app#27
RZEROSTERN merged 4 commits intomasterfrom
chore/publication-readiness

Conversation

@RZEROSTERN
Copy link
Collaborator

Publication readiness: CI/CD, coverage 80%, EditorController.fromJson, example app

Type of change

  • New feature
  • Bug fix
  • Refactor
  • Chore / dependency update

Summary

  • Added EditorController.fromJson() — load existing EditorJS JSON into the editor in one call
  • Added example/ directory with a two-tab demo app (viewer + editor)
  • Added .github/workflows/ci.yml — analyze + test + 80% coverage check on every PR/push
  • Updated pubspec.yaml description and topics for pub.dev discoverability
  • Updated CLAUDE.md — refreshed block types table, added contribution rules (80% coverage), updated backlog
  • Expanded test suite to reach ≥ 80% line coverage
  • Bumped version 0.4.00.5.0

Breaking changes

None. New EditorController.fromJson() is purely additive.

New public API

Symbol Description
EditorController.fromJson(String, {BlockTypeRegistry?}) Creates controller pre-populated from EditorJS JSON

Migration notes

None.

Test plan

  • fvm flutter analyze passes with no issues ✅
  • fvm flutter test --coverage — all tests pass, coverage ≥ 80% ✅
  • EditorController.fromJson(json) pre-populates blocks correctly
  • EditorController.fromJson('invalid') starts empty, no crash
  • Example app runs on at least one platform and both tabs work
  • CI workflow triggers on a test PR and passes

Copilot AI review requested due to automatic review settings March 25, 2026 21:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +256 to +260
// 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);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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);

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +28
- 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

Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
flutter:
sdk: flutter
editorjs_flutter:
path: ../
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
path: ../
path: ../
flutter:
uses-material-design: true

Copilot uses AI. Check for mistakes.
@RZEROSTERN
Copy link
Collaborator Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Mar 25, 2026

@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.

Copilot AI and others added 2 commits March 25, 2026 21:19
…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
@RZEROSTERN RZEROSTERN merged commit 2ce140c into master Mar 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants