Add unit tests for mushaf layout JSON export (follow-up to #620)#622
Open
hammadxcm wants to merge 1 commit into
Open
Add unit tests for mushaf layout JSON export (follow-up to #620)#622hammadxcm wants to merge 1 commit into
hammadxcm wants to merge 1 commit into
Conversation
Locks in the JSON layout shape introduced in TarteelAI#620 (info.json metadata file, one <page>.json per page, ayah/surah_name/basmallah line types, centered/justified alignment, first/last word index range, and word text resolved via Mushaf#text_type_method) using standalone Minitest with PORO stubs for the ActiveRecord models, matching the convention already established in test/services/resources/. Run with: ruby -Itest test/lib/exporter/export_mushaf_layout_test.rb Related to TarteelAI#257
Contributor
Author
|
@naveed-ahmad Follow Up PR on unit tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds unit tests for
Exporter::ExportMushafLayout#export_json(the JSON layout export shipped in #620, closing #257). When that PR was opened the codebase had no exporter tests and I couldn't run anything end-to-end, so the original implementation went in with only static checks. This locks the JSON shape down with a real Minitest spec.Coverage (9 cases / 31 assertions):
export_jsonreturns the JSON directory path it wrote to.info.jsoncarries the mushaf metadata (name,number_of_pages,lines_per_page,font_name).<page_number>.jsonfile is written per page.surah_nameline carriessurah_number, type, and centered alignment (and omits ayah-only keys).basmallahline is centered with no word data.ayahline carriesdata(word text),first_word_id/last_word_id, and justified alignment.ayahfalls back to justified when noMushafLineAlignmentrow exists for the line.Mushaf#text_type_method— switching the method tocode_v1swaps the exported text to the glyph codes.word_indexeven when the underlying records are out of order.Test style
Follows the convention already established by
test/services/resources/— standalone Minitest, PORO/Struct stubs for the ActiveRecord models (Mushaf,MushafPage,MushafLineAlignment, plus fake page/word/alignment records), no Rails boot, no database. Stubs are guarded withunless Object.const_defined?(...)so they don't clobber real constants if Rails were loaded.Related Issue
Follow-up to #257 (closed by #620, which shipped the feature without tests).
Motivation and Context
The JSON export is now consumed by downstream apps — pinning its shape with tests prevents accidental regressions (e.g., a stray rename of a key or a change to the line-type vocabulary). The same fake-AR pattern can be reused for the SQLite export and other exporter tests in the future.
How Has This Been Tested?
Also
ruby -cclean and RuboCop (Layout/Lint) clean.Screenshots (if appropriate):
N/A — test-only change.