Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2430 from ec-europa/ISAICP-6449
Browse files Browse the repository at this point in the history
ISAICP-6449: Revert 3b077c5
  • Loading branch information
idimopoulos authored Mar 24, 2021
2 parents ad46114 + 38fd911 commit 2496953
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ label: 'Publication date'
description: ''
required: false
translatable: false
default_value: { }
default_value:
-
default_date_type: now
default_date: now
default_value_callback: ''
settings: { }
field_type: datetime
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ status: true
dependencies:
module:
- datetime
- field_permissions
- node
third_party_settings:
field_permissions:
permission_type: public
_core:
default_config_hash: GZlK0SBCOEfMaprdtmTdeKKrhh_gI6XBChrBkVxi9xQ
id: node.field_document_publication_date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ Feature: "Add document" visibility options.
When I go to the homepage of the "Hunter in the Swords" collection
Then I should see the link "An amazing document"

# Check that the publication date field is prefilled with the current time.
When I go to the homepage of the "Hunter in the Swords" collection
And I click "Add document" in the plus button menu
Then I see "Publication date" filled with the current time

# Regression test to ensure that no critical errors are thrown when a new
# revision is created for a document that has a remote file attached.
# @see https://citnet.tech.ec.europa.eu/CITnet/jira/browse/ISAICP-3670
Expand Down
31 changes: 31 additions & 0 deletions tests/src/Context/JoinupContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,37 @@ public function clearDateRangeField($field, $component, $date = NULL) {
$element->setValue('');
}

/**
* Asserts that a date/time field is prefilled with the current time.
*
* @param string $field
* The date/time field name.
*
* @throws \Exception
* When the field is not found.
*
* @Then I see :field filled with the current time
*/
public function assertDateTimeFieldValue(string $field): void {
$now = new \DateTimeImmutable();

$date_part = $this->findDateRangeComponent($field, 'date')->getAttribute('value');
$time_part = $this->findDateRangeComponent($field, 'time')->getAttribute('value');
if (empty($date_part) || empty($time_part)) {
throw new ExpectationFailedException("The '{$field}' date/time field is not filled with the current time.");
}

$date = new \DateTimeImmutable("{$date_part} {$time_part}");

$interval = $now->diff($date);
// Given that such a test cannot do an exact assertion, because of the
// testing environment latency, we consider 3 seconds as an acceptable
// fuzziness.
if ($interval->f > 3000) {
throw new ExpectationFailedException("The '{$field}' date/time field is not filled with the current time.");
}
}

/**
* Finds a datetime field.
*
Expand Down

0 comments on commit 2496953

Please sign in to comment.