keep icon indicating copy to clipboard operation
keep copied to clipboard

fix: test_providers_page_is_accessible: force click

Open Kiryous opened this issue 1 year ago • 4 comments

📑 Description

Test test_providers_page_is_accessible is failing. It seems happens due to toast and button are intercepting pointer events.

Logs

poetry run coverage run --branch -m pytest -s tests/e2e_tests/test_end_to_end.py -k test_providers_page_is_accessible
======================================================================== test session starts ========================================================================
platform darwin -- Python 3.11.5, pytest-7.4.4, pluggy-1.5.0
rootdir: /Users/kirillchernakov/projects/keep
plugins: docker-2.2.0, anyio-4.4.0, mock-3.14.0
collected 3 items / 2 deselected / 1 selected                                                                                                                       

tests/e2e_tests/test_end_to_end.py F

============================================================================= FAILURES ==============================================================================
_________________________________________________________________ test_providers_page_is_accessible _________________________________________________________________

browser = <Page url='http://localhost:3000/providers'>

    def test_providers_page_is_accessible(browser):
        """
        Test to check if the providers page is accessible
    
        """
        try:
            browser.goto(
                "http://localhost:3000/signin?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2Fproviders"
            )
            browser.goto("http://localhost:3000/providers")
            # get the GCP Monitoring provider
            browser.locator("div").filter(
                has_text=re.compile(r"^GCP Monitoring alertConnect$")
            ).first.click()
            browser.get_by_role("button", name="Cancel").click()
            # connect resend provider
            browser.locator("div").filter(
                has_text=re.compile(r"^resend messagingConnect$")
            ).first.click()
            browser.get_by_placeholder("Enter provider name").click()
            random_provider_name = "".join(
                [random.choice(string.ascii_letters) for i in range(10)]
            )
            browser.get_by_placeholder("Enter provider name").fill(random_provider_name)
            browser.get_by_placeholder("Enter provider name").press("Tab")
            browser.get_by_placeholder("Enter api_key").fill("bla")
            browser.get_by_role("button", name="Connect").click()
            # wait a bit
            browser.wait_for_selector("text=Connected", timeout=15000)
            # make sure the provider is connected
            # forcing the click to avoid subtree interception pointer events
>           browser.get_by_text(f"resend id: {random_provider_name}").click()

tests/e2e_tests/test_end_to_end.py:110: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/playwright/sync_api/_generated.py:15093: in click
    self._sync(
../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/playwright/_impl/_locator.py:156: in click
    return await self._frame.click(self._selector, strict=True, **params)
../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/playwright/_impl/_frame.py:488: in click
    await self._channel.send("click", locals_to_params(locals()))
../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/playwright/_impl/_connection.py:59: in send
    return await self._connection.wrap_api_call(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <playwright._impl._connection.Connection object at 0x107e5c850>, cb = <function Channel.send.<locals>.<lambda> at 0x1084ed9e0>, is_internal = False

    async def wrap_api_call(
        self, cb: Callable[[], Any], is_internal: bool = False
    ) -> Any:
        if self._api_zone.get():
            return await cb()
        task = asyncio.current_task(self._loop)
        st: List[inspect.FrameInfo] = getattr(task, "__pw_stack__", inspect.stack())
        parsed_st = _extract_stack_trace_information_from_stack(st, is_internal)
        self._api_zone.set(parsed_st)
        try:
            return await cb()
        except Exception as error:
>           raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
E           playwright._impl._errors.TimeoutError: Locator.click: Timeout 5000ms exceeded.
E           Call log:
E           waiting for get_by_text("resend id: kuknnOLqFQ")
E             -   locator resolved to <div>…</div>
E             - attempting click action
E             -   waiting for element to be visible, enabled and stable
E             -   element is visible, enabled and stable
E             -   scrolling into view if needed
E             -   done scrolling
E             -   <div class="glass"></div> from <div>…</div> subtree intercepts pointer events
E             - retrying click action, attempt #1
E             -   waiting for element to be visible, enabled and stable
E             -   element is visible, enabled and stable
E             -   scrolling into view if needed
E             -   done scrolling
E             -   <div class="glass"></div> from <div>…</div> subtree intercepts pointer events
E             - retrying click action, attempt #2
E             -   waiting 20ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is visible, enabled and stable
E             -   scrolling into view if needed
E             -   done scrolling
E             -   <div class="sliding-panel-container  ">…</div> from <div>…</div> subtree intercepts pointer events
E             - retrying click action, attempt #3
E             -   waiting 100ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is visible, enabled and stable
E             -   scrolling into view if needed
E             -   done scrolling
E             -   <div>…</div> from <div class="Toastify">…</div> subtree intercepts pointer events
E             - retrying click action, attempt #4
E             -   waiting 100ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is visible, enabled and stable
E             -   scrolling into view if needed
E             -   done scrolling
E             -   <div>…</div> from <div class="Toastify">…</div> subtree intercepts pointer events
E             - retrying click action, attempt #5
E             -   waiting 500ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is visible, enabled and stable
E             -   scrolling into view if needed
E             -   done scrolling
E             -   performing click action
E             -   <span class="tremor-Button-text text-tremor-default whitespace-nowrap">Modify</span> from <button class="tremor-Button-root shrink-0 justify-center items-center group font-medium outline-none rounded-tremor-default border shadow-tremor-input dark:shadow-dark-tremor-input px-2.5 py-1.5 text-xs bg-transparent dark:bg-transparent border-orange-500 dark:border-orange-500 text-orange-500 dark:text-orange-500 hover:bg-orange-500 dark:hover:bg-orange-500 hover:bg-opacity-20 dark:hover:bg-opacity-20 hidden group-hover:block pd-2">…</button> subtree intercepts pointer events
E             - retrying click action, attempt #6
E             -   waiting 500ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is not visible
E             - retrying click action, attempt #7
E             -   waiting 500ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is not visible
E             - retrying click action, attempt #8
E             -   waiting 500ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is not visible
E             - retrying click action, attempt #9
E             -   waiting 500ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is not visible
E             - retrying click action, attempt #10
E             -   waiting 500ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is not visible
E             - retrying click action, attempt #11
E             -   waiting 500ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is not visible
E             - retrying click action, attempt #12
E             -   waiting 500ms
E             -   waiting for element to be visible, enabled and stable
E             -   element is not visible
E             - retrying click action, attempt #13
E             -   waiting 500ms

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/playwright/_impl/_connection.py:514: TimeoutError
========================================================================= warnings summary ==========================================================================
../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/opentelemetry/instrumentation/dependencies.py:4
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/opentelemetry/instrumentation/dependencies.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    from pkg_resources import (

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2825
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2825: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2825
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2825: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google.cloud')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2309
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2309: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(parent)

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/lark/utils.py:163
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/lark/utils.py:163: DeprecationWarning: module 'sre_parse' is deprecated
    import sre_parse

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/lark/utils.py:164
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/lark/utils.py:164: DeprecationWarning: module 'sre_constants' is deprecated
    import sre_constants

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
====================================================================== short test summary info ======================================================================
FAILED tests/e2e_tests/test_end_to_end.py::test_providers_page_is_accessible - playwright._impl._errors.TimeoutError: Locator.click: Timeout 5000ms exceeded.
=========================================================== 1 failed, 2 deselected, 6 warnings in 10.75s ============================================================

However, screenshot

Similar issues in other projects:

  • https://github.com/microsoft/playwright/issues/19187#issuecomment-1334563475
  • https://github.com/microsoft/playwright/issues/13576#issuecomment-1129587745

✅ Checks

  • [x] My pull request adheres to the code style of this project
  • [ ] My code requires changes to the documentation
  • [ ] I have updated the documentation as required
  • [x] All the tests have passed

ℹ Additional Information

Logs after forcing click

poetry run coverage run --branch -m pytest -s tests/e2e_tests/test_end_to_end.py -k test_providers_page_is_accessible
======================================================================== test session starts ========================================================================
platform darwin -- Python 3.11.5, pytest-7.4.4, pluggy-1.5.0
rootdir: /Users/kirillchernakov/projects/keep
plugins: docker-2.2.0, anyio-4.4.0, mock-3.14.0
collected 3 items / 2 deselected / 1 selected                                                                                                                       

tests/e2e_tests/test_end_to_end.py .

========================================================================= warnings summary ==========================================================================
../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/opentelemetry/instrumentation/dependencies.py:4
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/opentelemetry/instrumentation/dependencies.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    from pkg_resources import (

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2825
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2825: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2825
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2825: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google.cloud')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2309
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/pkg_resources/__init__.py:2309: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(parent)

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/lark/utils.py:163
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/lark/utils.py:163: DeprecationWarning: module 'sre_parse' is deprecated
    import sre_parse

../../Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/lark/utils.py:164
  /Users/kirillchernakov/Library/Caches/pypoetry/virtualenvs/keep-tOSqXWuX-py3.11/lib/python3.11/site-packages/lark/utils.py:164: DeprecationWarning: module 'sre_constants' is deprecated
    import sre_constants

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================ 1 passed, 2 deselected, 6 warnings in 5.44s ============================================================

Kiryous avatar Jul 31 '24 13:07 Kiryous

@Kiryous is attempting to deploy a commit to the KeepHQ Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jul 31 '24 13:07 vercel[bot]

No linked issues found. Please add the corresponding issues in the pull request description.
Use GitHub automation to close the issue when a PR is merged

github-actions[bot] avatar Aug 01 '24 09:08 github-actions[bot]

@Kiryous can you please elaborate on where do you see it failing?

talboren avatar Aug 04 '24 09:08 talboren

hey @talboren! it fails for me locally on main branch. also failed here in my #1491 PR' commit https://github.com/keephq/keep/actions/runs/10176119629/job/28144812347

Kiryous avatar Aug 04 '24 14:08 Kiryous

We don't do "force click" because using .click we're verifying if the div is on the screen. Not sure if it's the best way, open for suggestion :)

Matvey-Kuk avatar Aug 12 '24 08:08 Matvey-Kuk

Yeah, but it seems sucess-toasts could block div from clicking as screen in headless mode is small. Also, on hover you hide the provider info so div could be too small to click. Need to investigate more.On Aug 12, 2024 13:48, Matvey Kukuy @.***> wrote: We don't do "force click" because using .click we're verifying if the div is on the screen. Not sure if it's the best way, open for suggestion :)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

Kiryous avatar Aug 12 '24 09:08 Kiryous