Skip to content

Add TOML config regression tests#6940

Merged
ryancbahan merged 3 commits intomainfrom
03-05-rcb_e2e-toml-testing
Mar 11, 2026
Merged

Add TOML config regression tests#6940
ryancbahan merged 3 commits intomainfrom
03-05-rcb_e2e-toml-testing

Conversation

@ryancbahan
Copy link
Contributor

@ryancbahan ryancbahan commented Mar 5, 2026

WHY are these changes introduced?

We want to catch regressions in shopify.app.toml parsing and validation. The CLI should accept all documented config options and reject invalid configurations with clear errors.

WHAT is this pull request doing?

Static test data in data/:

  • data/valid-app/shopify.app.toml — comprehensive toml with all documented sections (access_scopes, webhooks, app_proxy, pos, build, auth, app_preferences, access.admin)
  • data/valid-app/package.json — minimal package.json
  • data/invalid-tomls/ — 5 invalid toml files (bad syntax, wrong types, unknown section, missing webhook uri, invalid app_proxy prefix)

New fixture:

  • setup/toml-app.ts — copies data/valid-app/ to a temp dir, injects client_id from env

Tests:

  • toml-config.spec.ts:
    • Deploy succeeds with fully populated toml
    • Dev starts with fully populated toml (waits for ready, presses q to quit)
  • toml-config-invalid.spec.ts:
    • Auto-discovers all .toml files in data/invalid-tomls/
    • Asserts app deploy --force fails for each with non-zero exit code
    • Logs full CLI output for diagnostics
cd packages/e2e && npx playwright test tests/toml-config.spec.ts tests/toml-config-invalid.spec.ts

How to test your changes?

cd packages/e2e && npx playwright test tests/toml-config.spec.ts

Measuring impact

n/a - test infrastructure

@ryancbahan ryancbahan changed the title add toml regression tests Add toml file regression tests Mar 5, 2026
Copy link
Contributor Author

ryancbahan commented Mar 5, 2026

@ryancbahan ryancbahan marked this pull request as ready for review March 5, 2026 17:52
@ryancbahan ryancbahan requested a review from a team as a code owner March 5, 2026 17:52
@binks-code-reviewer
Copy link

binks-code-reviewer bot commented Mar 5, 2026

🤖 Code Review · #projects-dev-ai for questions
React with 👍/👎 or reply — all feedback helps improve the agent.

Complete - No issues

📋 History

✅ No issues → ✅ No issues

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 79.23% 14599/18426
🟡 Branches 73.49% 7249/9864
🟡 Functions 79.37% 3717/4683
🟡 Lines 79.56% 13795/17339

Test suite run success

3822 tests passing in 1464 suites.

Report generated by 🧪jest coverage report action from 9097f3f

@ryancbahan ryancbahan force-pushed the 03-05-rcb_e2e-toml-testing branch from f84e801 to 9cac1cf Compare March 5, 2026 18:16
@ryancbahan ryancbahan force-pushed the 03-05-rcb_e2e-toml-testing branch 3 times, most recently from fdbbe21 to eaa13bc Compare March 5, 2026 18:40
@ryancbahan ryancbahan changed the title Add toml file regression tests Add TOML config regression tests Mar 5, 2026
@ryancbahan ryancbahan force-pushed the 03-05-rcb_e2e-toml-testing branch from eaa13bc to bec1a97 Compare March 5, 2026 19:11
@ryancbahan ryancbahan force-pushed the 03-05-rcb_e2e-toml-testing branch from bec1a97 to 8a98157 Compare March 11, 2026 15:30
Copy link
Contributor

@dmerand dmerand left a comment

Choose a reason for hiding this comment

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

AI pair review found a few assertion weaknesses that are addressable.


Review assisted by pair-review

[app_proxy]
url = "https://example.com/proxy"
subpath = "test"
prefix = "not-a-valid-prefix"
Copy link
Contributor

Choose a reason for hiding this comment

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

invalid-prefix.toml reads like a local config-validation case, but the CLI does not currently validate app_proxy.prefix beyond “must be a string” packages/app/src/cli/models/extensions/specifications/app_config_app_proxy.ts:12-21. The deploy path forwards the prefix unchanged into the remote app proxy config packages/app/src/cli/models/extensions/specifications/app_config_app_proxy.ts:30-45, and manifest tests show arbitrary prefix strings are preserved packages/app/src/cli/models/app/app.test.ts:890-900. So if this fixture fails, it is likely exercising downstream/server-side validation rather than the CLI rejecting an invalid TOML value. Useful integration coverage maybe. But the current naming and grouping imply stronger client-side validation coverage than the test actually provides.

application_url = "https://example.com"
embedded = true

[completely_made_up_section]
Copy link
Contributor

Choose a reason for hiding this comment

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

unknown-section.toml does not look invalid in the code path app deploy actually uses. Linked apps are loaded with getAppVersionedSchema(specifications), which defaults to .passthrough(), so unknown top-level sections are accepted instead of rejected packages/app/src/cli/models/app/app.ts:172-183, packages/app/src/cli/models/app/loader.ts:999-1018. Then deploy sends a generated app manifest rather than the raw TOML packages/app/src/cli/models/app/app.ts:448-470, packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts:748-756, so completely_made_up_section may never be validated server-side either. That makes this fixture a likely false-negative/false-positive case: it may not fail for the reason the test name implies, and could even succeed.

Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Improvement: The test suite includes 5 invalid TOML cases but is missing several categories of validation issues that exist in the actual codebase. Additional valuable test cases could include: URL validation failures (invalid URLs in app_proxy.url, auth.redirect_urls), webhook API version validation, array vs string type mismatches, invalid enum values (e.g., access.admin.direct_api_mode accepts only 'online'/'offline'), and field length validations. More comprehensive coverage would provide stronger regression protection.

Suggestion: Consider adding test files for additional validation scenarios:

  • invalid-url.toml - malformed URL in application_url or redirect_urls
  • invalid-api-version.toml - invalid webhooks.api_version
  • invalid-direct-api-mode.toml - access.admin.direct_api_mode = "invalid"
  • wrong-array-type.toml - auth.redirect_urls as string instead of array

These would provide more comprehensive coverage of the validation rules implemented in the codebase.

})
const output = result.stdout + result.stderr
console.log(`[${label}] exit code: ${result.exitCode}\n[${label}] output:\n${output}`)
expect(result.exitCode, `expected deploy to fail for ${label}, but it succeeded:\n${output}`).not.toBe(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Improvement: The PR description states the CLI should 'reject invalid configurations with clear errors', but the test only validates that the command fails (non-zero exit code) without verifying that error messages are actually clear and helpful. The test captures output for diagnostics but doesn't assert anything about error message content or quality. The CLI could return unhelpful errors like 'Unknown error' and the test would still pass.

Suggestion: Add assertions to verify that error messages are present and meaningful:

expect(result.exitCode, `expected deploy to fail for ${label}, but it succeeded:\n${output}`).not.toBe(0)
expect(output.toLowerCase()).toMatch(/error|invalid|failed/)
expect(output).toContain('shopify.app.toml')

Or create specific assertions for each invalid case (e.g., verify 'bad-syntax' mentions syntax errors, 'invalid-webhook' mentions missing uri).

@ryancbahan ryancbahan changed the base branch from 02-27-add_cleanup to graphite-base/6940 March 11, 2026 19:59
Remove invalid-prefix.toml and unknown-section.toml fixtures that
don't actually test client-side validation (prefix isn't validated,
unknown sections pass through via .passthrough()). Add error message
assertion to invalid TOML tests, bump dev test timeout to 6 min,
and make quit-key assertion more specific.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan force-pushed the 03-05-rcb_e2e-toml-testing branch from 8a98157 to a1095cb Compare March 11, 2026 20:07
@ryancbahan ryancbahan changed the base branch from graphite-base/6940 to 02-27-add_cleanup March 11, 2026 20:07
The shortcut hint is rendered via terminal control sequences that
don't reliably appear in PTY-captured output. The test already
validates startup via waitForOutput and quit via sendKey + exit code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan requested a review from dmerand March 11, 2026 20:35
Copy link
Contributor Author

@dmerand i did an initial pass at narrowing, but overall i think this is something we'll want to iterate on a bit and the value for shipping this is high enough as-is. wdyt?

Base automatically changed from 02-27-add_cleanup to main March 11, 2026 20:40
@ryancbahan ryancbahan added this pull request to the merge queue Mar 11, 2026
Merged via the queue into main with commit a0e1685 Mar 11, 2026
43 of 44 checks passed
@ryancbahan ryancbahan deleted the 03-05-rcb_e2e-toml-testing branch March 11, 2026 20:56
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.

2 participants