Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor options to const #1044

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft

Refactor options to const #1044

wants to merge 41 commits into from

Commits on Sep 21, 2023

  1. Add a WaitForEventOptions type

    This is where the options or predicate function will be parsed. This
    aligns with how we're parsing options in other APIs.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    f62d724 View commit details
    Browse the repository at this point in the history
  2. Add the implementation to parse the options

    This copies the parsing logic from the existing browserContext.waitFor
    Event() into the new WaitForEventOptions type's parse method. It also
    modifies it so that the data that is parsed is updated in the type and
    during parsing it will return an error instead of panicking.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    7221b56 View commit details
    Browse the repository at this point in the history
  3. Refactor WaitForEvent to work with its parser

    This commit refactors the code so that it works with the new
    WaitForEventOptions type.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    29aa69e View commit details
    Browse the repository at this point in the history
  4. Fix browserContext.waitForEvent's timeout

    This now defaults to the browserContext's default timeout. This should
    fix the confusion of mixing seconds and milliseconds when working with
    the timeouts in this API.
    
    NOTE though that there is a default timeout of 30 seconds now, whereas
    in PW there is no timeout unless one is set explicitly in
    browserContext using SetDefaultTimeout.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    8c734f4 View commit details
    Browse the repository at this point in the history
  5. Update waitForEvent to clarify page support

    At the moment we only support working with the new page creation event
    (i.e. "page" event) when waitForEvent is used. This commit helps
    clarify this to users.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    1314be4 View commit details
    Browse the repository at this point in the history
  6. Update messaging around the other cases

    When working with waitForEvent we now notify the user if the timeout
    was reached, or whether the context is closed (i.e. the test iteration
    has ended).
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    ff2b281 View commit details
    Browse the repository at this point in the history
  7. Refactor waitForEvent to work with errors

    Instead of panicking when an error occurs, this commit refactors
    waitForEvent to return an error back to the mapping layer where it can
    do what it needs with the error.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    1020eef View commit details
    Browse the repository at this point in the history
  8. Fix parsing of waitForEvent options

    This new way of working allows us to test the code with integration
    tests, and it still works as expected when we run the API through a
    test script. Before it seemed overly complex to try to create a goja
    object that required reflection.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    fb354e4 View commit details
    Browse the repository at this point in the history
  9. Update to allow nil predicate function

    It's valid for a user not to pass anything but the event. A change
    needed to be made to allow for a nil predicate to allow for this.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    e8fec53 View commit details
    Browse the repository at this point in the history
  10. Refactor duplicate code into defer

    When a return occurs from runWaitForEventHandler it needs to perform
    the same steps for all returns out of the method. This refactors those
    duplicate steps into a defer function.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    3c37f9f View commit details
    Browse the repository at this point in the history
  11. Update mapping to promisify waitForEvent

    waitForEvent is useless without it being promisified. This changes
    that so that waitForEvent returns a promise, allowing the user to set
    a waitForEvent and then call further APIs which will unblock the
    waitForEvent when possible (only for new page creations and if the
    predicate function is set and returns a truthy value).
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    2e2e063 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    aa5952b View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    c00acd5 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    0be19f3 View commit details
    Browse the repository at this point in the history
  15. Add a new waitForEventType type

    This helps make things more maintainable and reduces the risk of typos
    when working with the event types for waitForEvent.
    
    Co-authored-by: İnanç Gümüş <inanc.gumus@grafana.com>
    ankur22 and inancgumus committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    4c096de View commit details
    Browse the repository at this point in the history
  16. Refactor error message for incorrect event

    Co-authored-by: İnanç Gümüş <inanc.gumus@grafana.com>
    ankur22 and inancgumus committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    d741d45 View commit details
    Browse the repository at this point in the history
  17. Update log message with correct method name

    Co-authored-by: İnanç Gümüş <inanc.gumus@grafana.com>
    ankur22 and inancgumus committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    af81e9a View commit details
    Browse the repository at this point in the history
  18. Refactor for early return

    This helps tidy up the code and keeps the happy path more left aligned.
    
    Co-authored-by: İnanç Gümüş <inanc.gumus@grafana.com>
    ankur22 and inancgumus committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    bbfe8df View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    232422c View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    4f0b44a View commit details
    Browse the repository at this point in the history
  21. Refactor to early exit if opts doesn't exist

    Co-authored-by: İnanç Gümüş <inanc.gumus@grafana.com>
    ankur22 and inancgumus committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    3d1f558 View commit details
    Browse the repository at this point in the history
  22. Refactor comments to align with 80 chars line len

    This just helps make the line lengths of comments consistent.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    855850a View commit details
    Browse the repository at this point in the history
  23. Refactor test names to be less verbose

    This not only use a more concise naming convention it also adds '_' to
    the names, which makes it easier to find tests if they fail.
    
    Co-authored-by: İnanç Gümüş <inanc.gumus@grafana.com>
    ankur22 and inancgumus committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    b2d2503 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    8fd96c5 View commit details
    Browse the repository at this point in the history
  25. Add a const for the timeout option

    This will help avoid typo issues and make the code more maintainable.
    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    d8c52f9 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    4b8d60d View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    5e72dc1 View commit details
    Browse the repository at this point in the history
  28. Add const for force option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    5485c29 View commit details
    Browse the repository at this point in the history
  29. Add const for delay option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    7fa2466 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    6c8b776 View commit details
    Browse the repository at this point in the history
  31. Add const for type option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    0a46fac View commit details
    Browse the repository at this point in the history
  32. Add const for quality option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    9d037f3 View commit details
    Browse the repository at this point in the history
  33. Add const for path option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    e51fbcf View commit details
    Browse the repository at this point in the history
  34. Add const for strict option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    e597d69 View commit details
    Browse the repository at this point in the history
  35. Add const for referer option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    7f8673e View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    53d63ea View commit details
    Browse the repository at this point in the history
  37. Add const for polling option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    57467a7 View commit details
    Browse the repository at this point in the history
  38. Add const for url option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    50791d6 View commit details
    Browse the repository at this point in the history
  39. Add const for button option

    ankur22 committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    71178ef View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    f06d53a View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    90b47b3 View commit details
    Browse the repository at this point in the history