Uploaded image for project: 'OCMUI - OpenShift Cluster Manager UI'
  1. OCMUI - OpenShift Cluster Manager UI
  2. OCMUI-596

[OCM UI] Unit tests: Fix PropType violations

    • Icon: Task Task
    • Resolution: Done
    • Icon: Normal Normal
    • None
    • None
    • Core UI
    • False
    • Hide

      None

      Show
      None
    • False
    • OCMUI Core Sprint 256, OCMUI Core Sprint 257, OCMUI Core Sprint 258

      As discovered in !4497, we have a ton of PropType violations in unit tests.

      There is no static analysis for PropTypes, and long-term we should move to TypeScript.
      React at best does console.error(); we had code in src/setupTests.ts to intercept that in unit tests and throw exceptions on violations, so they would fail tests.
      At some point we were down to <5 test files with violations, but the error matching logic got broken and many console.errors were not printing at all, so over a hundred violations in ~36 test files crept in...

      At present stage, I'm making them print out but not fail tests => this card is to clean them up.

      Acceptance criteria

      • Re-enable throw() for PropType errors in src/setupTests.ts and CI passes.
      • grep the full CI output — no type-related console.error messages anywhere.
        (ideally these 2 bullets are equivalent, but I'm seeing some printed without corresponding test failure?)

      Tips: Ways to fix an error

      • Note that some errors reflect issue in the type declaration and not usage e.g.:
        • Warning: UpgradeAcknowledgeModal: type specification of prop `modalData` is invalid; the type checker function must return `null` or an `Error` but returned a function. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).
        • Invalid prop `fromVersion` of type `string` supplied to `UpgradeAcknowledgeWarning`, expected `function`
      • Most errors are isRequired props that tests omit.  Either pass in test or decide it's not really isRequired...
      • It's also fine to convert to TypeScript, if you want

              emingora Enrique Mingorance Cano
              bpaskinc@redhat.com Beni Paskin-Cherniavsky (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: