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

Fix ClouderyView tests that timeout and reactivate them #753

Open
Ldoppea opened this issue Apr 20, 2023 · 0 comments
Open

Fix ClouderyView tests that timeout and reactivate them #753

Ldoppea opened this issue Apr 20, 2023 · 0 comments

Comments

@Ldoppea
Copy link
Member

Ldoppea commented Apr 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant