Skip to content

chore(test): add coverage threshold, missing tests, and CI coverage summary #33

@nicomiguelino

Description

@nicomiguelino

Background

When the edge-apps-library was extracted from Screenly/Playground, several test and CI improvements developed in Playground PR #644 were never ported over. This issue tracks what still needs to be done.

Missing items

1. Coverage threshold in vitest.config.ts

vitest.config.ts has no coverage configuration. The thresholds below are set just above the current baseline (functions ~67%, lines ~21%) so they pass immediately and can be raised in follow-up PRs as coverage improves:

// vitest.config.ts
coverage: {
  provider: 'v8',
  thresholds: {
    functions: 65,
    lines: 20,
    branches: 75,
  },
  reporter: ['text', 'lcov'],
},

The intent is to ratchet these numbers up incrementally, not to hit a high target in one go.

2. fetchLogoImage and setupBranding tests missing from theme.test.ts

src/utils/theme.ts exports fetchLogoImage and setupBranding, but src/utils/theme.test.ts has no coverage for either. Cases to cover:

fetchLogoImage:

  • Fetches and base64-encodes SVG images
  • Returns the original URL for PNG and JPEG images (detected via magic bytes)
  • Throws on HTTP failure
  • Throws on unknown image type

setupBranding:

  • Sets up complete branding (colors + logo URL) when fetch succeeds
  • Converts empty logoUrl to undefined when all fetch attempts fail

3. corsProxyUrl parameter on createMockScreenly / setupScreenlyMock

cors_proxy_url is currently hardcoded as 'http://localhost:8080' in createMockScreenly. Tests for proxy-dependent code (e.g. setupBrandingLogo) need to supply a custom proxy URL. Proposed change to src/test/mock.ts:

export function createMockScreenly(
  metadata: Partial<ScreenlyMetadata> = {},
  settings: Partial<ScreenlySettings> = {},
  corsProxyUrl = 'http://localhost:8080',   // add this
): ScreenlyObject

export function setupScreenlyMock(
  metadata: Partial<ScreenlyMetadata> = {},
  settings: Partial<ScreenlySettings> = {},
  corsProxyUrl?: string,                    // add this
): ScreenlyObject

4. global.FileReader missing from test setup

src/test/index.ts sets up jsdom globals but does not expose FileReader. SVG-processing tests (which rely on Blob + FileReader) fail without it. Add to src/test/index.ts:

global.FileReader = window.FileReader

5. CI coverage summary in GitHub Actions

The CI workflow (.github/workflows/ci.yml) runs tests but does not report coverage output. Add a step that:

  • Cleans the coverage/ directory before the test run
  • Pipes test output through tee
  • Appends a Markdown coverage table to $GITHUB_STEP_SUMMARY after the run

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions