Skip to content

Make running test app easier #117

@johnboxall

Description

@johnboxall

commerce-sdk-isomorphic ships with a neat little test app based on [email protected]

It is challenging to get the app working.

  • The app is served over HTTPS, but certificate used with it is self signed and not trusted by browsers. I think it comes from an older version of webpack dev server. To get past browser warnings about this, in Chrome you can type thisisunsafe.
  • The default proxy configuration needs to be modified in package.json, providing a valid shortcode.
  • The default config in src/config.js needs to be updated with valid values.
  • The SLAS client you're using needs to be updated to have https://localhost:3000/callback be a valid redirect URI.
  • Next you'll hit an issue with 404s, because in a browser, the redirect from authorize will be followed, and CRA doesn't know how to render /callback:
    // url is a read only property we unfortunately cannot mock out using nock
    // meaning redirectUrl will not have a falsy value for unit tests
    /* istanbul ignore next */
    if (response.status >= 400 || searchParams.error) {
    throw new ResponseError(response);
    }
  • Finally, you'll need to make sure the default search query actually load a product, because there seems to be some subtle bug with the text input if no search results are returned.

It is possible to jump through these hoops, but challenging:

Screenshot 2023-03-16 at 3 41 23 PM

A few ideas:

  1. Consider not running the test app using HTTPS:
    "start": "HTTPS=true react-scripts start",
  2. Consider updating the authorize helper to be more forgiving. We do care if the initial call to authorizeCustomer failed, but in the event that we're running in a browser, we actually do not care if we followed a redirect and the redirect failed to load, as we can still get the usid/code out of the URL, regardless of the status code of loading redirect_uri.
  3. Commit valid configuration for the test app to this repo. We have public settings that we can use.
  4. Chase down whatever the zero results bug in the app is!

Metadata

Metadata

Assignees

No one assigned

    Labels

    ackAcknowledged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions