From 45cef1c60a9bbe4f6cf8fa264f4e89fdf7e533ea Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Wed, 8 Jul 2026 15:44:11 +0200 Subject: [PATCH] New welcome screen --- __tests__/termsParser.test.ts | 147 ++++++++ src/i18n_messages/en.json | 33 +- src/i18n_messages/es.json | 33 +- src/i18n_messages/pt.json | 33 +- src/i18n_messages/sk.json | 33 +- src/screens/WelcomeScreen.tsx | 640 +++++++++++++++++++++++----------- src/utils/htmlToBlocks.ts | 123 +++++++ 7 files changed, 762 insertions(+), 280 deletions(-) create mode 100644 __tests__/termsParser.test.ts create mode 100644 src/utils/htmlToBlocks.ts diff --git a/__tests__/termsParser.test.ts b/__tests__/termsParser.test.ts new file mode 100644 index 0000000..3cd034a --- /dev/null +++ b/__tests__/termsParser.test.ts @@ -0,0 +1,147 @@ +/** + * Tests for the Terms/Privacy HTML parser used by WelcomeScreen. + * + * Two layers: + * 1. Deterministic unit tests over a fixed fixture — lock the parser's + * behaviour (block segmentation, inline formatting, entity decoding). + * 2. A live guard test that fetches https://minibits.cash/terms and asserts + * structural invariants. This is what catches an *unexpected* change to + * the live Terms markup (e.g. a new element type the parser can't handle, + * which would otherwise leak raw HTML into the app). Requires network. + */ + +import { htmlToBlocks, extractArticle, Block } from '../src/utils/htmlToBlocks' + +const TERMS_URL = 'https://minibits.cash/terms' + +const SAMPLE = `
ignored
+

Terms and Conditions

+

Bitango & friends said "hello" 'again'

+
+

Part 0 — General Terms

+

0.1 About

+

Read the Privacy Policy and the fine print.

+
    +
  • First item
  • +
  • Second item
  • +
+
+

IMPORTANT

+

Read carefully.

+
+
` + +const textOf = (block: Block): string => + block.type === 'hr' ? '' : block.segments.map(s => s.text).join('') + +describe('htmlToBlocks (fixture)', () => { + const blocks = htmlToBlocks(SAMPLE) + + test('extractArticle returns only the article inner HTML', () => { + const inner = extractArticle(SAMPLE) + expect(inner).toContain('

Terms and Conditions

') + expect(inner).not.toContain('
') + expect(inner).not.toContain('