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

Flaky spec: Residence Verify booth Unable to find visible css "#officing-booth" #1351

Conversation

iagirre
Copy link

@iagirre iagirre commented Mar 9, 2018

References

Objectives

Explain why the test is flaky, or under which conditions/scenario it fails randomly

(The explanation is the same as in #1342, #1343 and #1349 PRs because the problem is exactly the same).

What happened here was that, at the moment the test tries to reach the residence verification page, the message that it's supposed to appear (announcing the booth choosen for that officer) is not there. In this case, because there is only one booth created, the test should not pass through the page to choose it (and it doesn't pass, in fact), so the booth should be choosen automatically. The problem is that the date of each officer assignment is different from Date.current, so, for the app, there aren't any booths for today and there is no message, what generates the test to fail.

I realized that the problem could be in the moment of creating the officer assignments. If they are created at 23:59:59 and the rest of the test is executed after 00:00:00, the dates for the objects and the Date.current (used to check if there are any shifts today) won't be the same, because the shift will be for, lets say, 07/03/2018 and Date.current will be 08/03/2018.

To prove that, I forced in the factory the dates of the officer_assignments to an earlier date, and it failed in the exact same way as the reported ones.

Explain why your PR fixes it

I stubbed the Date and Time clases to force them to give me a date I can controll. I set that date (01/01/2018) to the objects that depend on it. This way, it doesn't matter when the test is executed, for him it will always be the same date.

Visual Changes (if any)

There aren't, is a flaky.

Notes

  • In this case, I only stubbed them in the failing scenario, because is the only one that depends on dates.

booth = create(:poll_booth)
poll = create(:poll)

ba = create(:poll_booth_assignment, poll: poll, booth: booth)
oa = create(:poll_officer_assignment, officer: officer, booth_assignment: ba)
create(:poll_shift, officer: officer, booth: booth, date: Date.current)
oa = create(:poll_officer_assignment,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good practice to name the variables as descriptive as possible...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the names to a more descriptive ones, and also changed the hardcoded '2018-01-01' date to a Date.current, because it's mocked before.

Copy link

@MariaCheca MariaCheca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I just left a comment regarding naming practices...

… a conflict when running tests at certain hours.
@iagirre iagirre force-pushed the 1210-flaky-unable-to-find-visible-css-officing-booth branch from 6eb442c to b551535 Compare March 14, 2018 07:25
@MariaCheca MariaCheca merged commit 2b9c679 into AyuntamientoMadrid:master Mar 14, 2018
@aitbw aitbw deleted the 1210-flaky-unable-to-find-visible-css-officing-booth branch April 5, 2018 15:16
@raul-fuentes
Copy link

This code can't be backported, the related test not exists on consul

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

Successfully merging this pull request may close these issues.

3 participants