Skip to content

Fix ClouderyView tests that timeout and reactivate themΒ #753

@Ldoppea

Description

@Ldoppea

Some ClouderyView tests take too much time on the CI and then timeout. They have been deactivated but we should find a way to make them pass without timeout.

When done we should revert #750

The issue is that some tests take ~20x longer on CI than on local development environment.

For example the following test

import { Button as MockButton } from 'react-native'

const ClouderyView = ({ setInstanceData }) => {
  return (
    <>
      <MockButton
        testID="triggerStartLoadWithRequest"
        onPress={() => {
          console.timeEnd("🌈 ClickHandler")
          setInstanceData({
            instance: 'https://some_existing_instance.mycozy.cloud/',
            fqdn: 'some_existing_instance.mycozy.cloud'
          })
        }}
        title="WebView Button"
      />
    </>
  )
}

it('should listen for redirection and intercept login data for login view', async () => {
  console.time("🌈 EntireTest")

  console.time("🌈 RenderComponent")
  const { getByTestId } = render(<ClouderyView {...props} />)
  console.timeEnd("🌈 RenderComponent")

  console.time("🌈 Find & ClickButton")
  const button = getByTestId('triggerStartLoadWithRequest')
  console.timeEnd("🌈 Find & ClickButton")

  console.time("🌈 ClickHandler")
  
  console.time("🌈 WaitFor")
  await waitFor(() => fireEvent.press(button))
  console.timeEnd("🌈 WaitFor")

  // Then
  expect(props.setInstanceData).toHaveBeenCalledTimes(1)
  expect(props.setInstanceData).toHaveBeenCalledWith({
    instance: 'https://some_existing_instance.mycozy.cloud/',
    fqdn: 'some_existing_instance.mycozy.cloud'
  })

  console.timeEnd("🌈 EntireTest")
})

Would produce the following log when run on GH Action CI:

🌈 RenderComponent: 8857 ms

🌈 Find & ClickButton: 1 ms

🌈 ClickHandler: 936 ms

🌈 WaitFor: 946 ms

🌈 EntireTest: 9808 ms

On my computer the entire test would fit in less than 400ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions