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

'Date only' date type field is not being created while running behat tests #200

Open
amitsharmadoj opened this issue Nov 1, 2018 · 5 comments · May be fixed by #229
Open

'Date only' date type field is not being created while running behat tests #200

amitsharmadoj opened this issue Nov 1, 2018 · 5 comments · May be fixed by #229

Comments

@amitsharmadoj
Copy link

After upgrading drupal core from 8.3.9 to 8.6.1, behat from 3.1.0 to 3.3.1 and drupal-driver from 1.2.x-dev to 2.0.x-dev, behat tests are failing for dates of 'Date only' date type. D8 has two date types 'Date and time' and 'Date only' for 'Date' field. There is no issue with 'Date and time' date type. It looks drupal-driver is not able to create dates of 'Date only' date type. I have tried different date formats but none is working.
I can create pages with 'Date only' dates and they appear correctly on the page in the desired format, it is just the behat test which is failing to generate it on the page. It looks DatetimeHandler class in not handling 'Date only' date type.

My test.feature looks like (field_publication_date is 'Date only' date)
@api
Feature: I can see publication data on publication page.
Background:
Given I am an anonymous user
And "publication" content:
| title | moderation_state | field_publication_author | field_publication_date |
| test-title | published | test-author | 2016-09-01 |

Scenario: I can see the correct publication data
Given I am on "/test-title"
And I should see the text "test-author"
And I should see the text "September 2016"

Error:
001 Scenario: I can see publication data on publication page # features/publication.feature:35 And I should see the text "September 2016" # features/publication.feature:44 The text "September 2016" was not found anywhere in the text of the current page. (Behat\Mink\Exception\ResponseTextException)

Format tried:
2016-09-01, 2016/09/01, 01/09/2016, 01-09-2016, 2016-09-01T05:00:00, 2016-09-01 12:12:12, 1 minutes ago etc.
As I said it doesn't looks like format issue. Behat is not able to create date of 'Date only' type. I have also tried putting break just before date test statement to see if date is being created in different format other than expected but date field along with its label is not at all present on the page.

Versions used:

behat/behat:    v3.3.1 
behat/gherkin:    v4.5.1 
behat/mink:    v1.7.1 
drupal/drupal-driver:   2.0.x-dev
drupal/core:    8.6.1

--

@amitsharmadoj
Copy link
Author

Patch created and it resolved my issue
https://patch-diff.githubusercontent.com/raw/jhedstrom/DrupalDriver/pull/201.patch

@bkosborne
Copy link

Yeah I just ran into this as well. I upgraded from 1.4.0 to 2.1.0. It was broken with this PR #126 and this commit: e778cb8

I'm not sure that patch is appropriate though. It seems like it would always ignore time if it was provided? Seems like instead we need to detect if a time was provided or not some other way.

@bkosborne
Copy link

Okay, I submitted my own PR that fixes this by checking if the date field is configured as a date-only or datetime field: #229

@drishu
Copy link

drishu commented May 10, 2021

#229 doesn't work, the scenario described above failed with the date in behat printed 1 day behind.
I improved the old one, conflicts resolved #235

@BramDriesen
Copy link

Just tested #235 and it is working fine for me now! Thanks for the effort.

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 a pull request may close this issue.

4 participants