Skip to content

DEV: rewrites artifact spec with capybara waiters #1347

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

Merged
merged 1 commit into from
May 19, 2025
Merged

Conversation

jjaffeux
Copy link
Contributor

Generally speaking we never want to do:

expect(element.text).to eq("foo")

As these are rspec matchers and do not add further Capybara-style waiting specifically for the text content to become present.

Generally speaking we never want to do:

```
expect(element.text).to eq("foo")
```

As these are rspec matchers and do not add further Capybara-style waiting specifically for the text content to become present.

expect(page).to have_css(iframe_selector)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are doing a find at tnetx step so I don't think that's necessary, we will fail on the find if it doesn’t exist

expect(iframe_element["data-custom-message"]).to eq("hello-from-post")
expect(iframe_element["data-post-author-id"]).to eq(author.id.to_s)
expect(artifact_element).to have_css("iframe[data-custom-message='hello-from-post']")
expect(artifact_element).to have_css("iframe[data-post-author-id='#{author.id}']")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can't check data attributes on the element itself in capybara, so the best way is to do this.

Comment on lines +62 to +64
expect(page).to have_selector(data_selector, text: /.+/)
expect(page).to have_no_selector(data_selector, text: "Waiting for data...")
expect(page).to have_no_selector(data_selector, text: "Error:")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't want to use rspec matcher on dom elements, they are not waiting correctly

@SamSaffron SamSaffron merged commit 296aa24 into main May 19, 2025
6 checks passed
@SamSaffron SamSaffron deleted the idiomatic-spec-1 branch May 19, 2025 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants