-
Notifications
You must be signed in to change notification settings - Fork 3
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
OPENEUROPA-660: Make it impossible for a content editor to create an initial version of a content in any language other than the default language #29
Conversation
…ent only with site default language.
3f6e3e9
to
3b02486
Compare
ccd3cd9
to
983b98c
Compare
tests/Behat/DrupalContext.php
Outdated
* | ||
* @Given I am visiting the :content_type_name create node page | ||
*/ | ||
public function iAmVisitingTheCreateNodePage(string $content_type_name): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need this custom step. We could simply do "Given I am in the "node/add/oe_demo_translatable_page". The path is quite straightforward and easy to read, but that is my opinion. If we decide to keep the custom step I think it needs to be rewritten to something like "Given I am visiting the :content_type_name creation page"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/Behat/DrupalContext.php
Outdated
@@ -201,4 +202,64 @@ protected function getLanguageIdByName(string $name): string { | |||
throw new \InvalidArgumentException("Language '{$name}' not found."); | |||
} | |||
|
|||
/** | |||
* Redirect user on Node creation page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "Redirect user to the node creation page."
tests/Behat/DrupalContext.php
Outdated
* | ||
* @Then I should not see selectbox with label :label | ||
*/ | ||
public function iShouldNotSeeSelectboxWithLabel(string $label): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the method (and the step) is misleading, we are not checking for selectboxes but rather for a field. We should either rename the function (and the step) or make it so that it only checks for selectboxes
tests/Behat/DrupalContext.php
Outdated
} | ||
|
||
/** | ||
* Check that selectbox with node language selector is hidden. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function should allow to find any selectbox, so the comment should reflect that (and not point out to the language selector)
tests/Behat/DrupalContext.php
Outdated
->getPage() | ||
->findField($label); | ||
if ($element) { | ||
throw new \RuntimeException("Selectbox for selecting initial language still visible."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error should use the provided selectbox label variable.
tests/Behat/DrupalContext.php
Outdated
* @param string $title | ||
* Title of node. | ||
* | ||
* @Then I have to be sure that :title node translation only in site default language. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better way to word this is "@then the only available translation for :title is in the site's default language"
tests/Behat/DrupalContext.php
Outdated
* @Then I have to be sure that :title node translation only in site default language. | ||
*/ | ||
public function assertOnlyDefaultLanguageTranslationExist(string $title) { | ||
$title_element = $this->getSession() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of relying on the session for this step, wouldn't it be better to use Drupal API to gather the translations of the node we are trying to check?
cfd7960
to
ef5a068
Compare
@@ -0,0 +1,17 @@ | |||
@api | |||
Feature: Content initial language. | |||
In order to be create content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to create content
Feature: Content initial language. | ||
In order to be create content | ||
As a editor | ||
I want to make sure that it impossible for a content editor to create an initial version of a content in any language other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to make sure that it is not possible for a content editor to create a node's initial version in any language (line break here)
other than the site's default language
I want to make sure that it impossible for a content editor to create an initial version of a content in any language other | ||
than the site default language | ||
|
||
Scenario: Content editor try to create node without possibility select initial node language |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an editor, when I create a node I can not select the initial node language
src/MultilingualConfigOverride.php
Outdated
foreach ($names as $config_name) { | ||
// Force the default site's language as the default language and prevent | ||
// the users from changing it when creating a node. | ||
if (preg_match('/^language\.content_settings\.node\.(.*)$/', $config_name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make this line more readable if you would use strpos()
tests/Behat/DrupalContext.php
Outdated
} | ||
|
||
$node_translation_languages = $node->getTranslationLanguages(); | ||
if (!is_array($node_translation_languages) || count($node_translation_languages) !== 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$node->getTranslationLanguages(); always returns an array.
tests/Behat/DrupalContext.php
Outdated
* @param string $content_type_name | ||
* Content type name. | ||
* | ||
* @Given I am visiting the :content_type_name creation page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@given I visit the :content_type_name creation page
tests/Behat/DrupalContext.php
Outdated
|
||
$node_translation_languages = $node->getTranslationLanguages(); | ||
if (!is_array($node_translation_languages) || count($node_translation_languages) !== 1) { | ||
throw new \RuntimeException("We don't have the correct number of translations."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The node should have only one translation.
8bc1577
to
2168681
Compare
ec0fa14
ec0fa14
to
883083a
Compare
OPENEUROPA-660
Description
Our content translation strategy requires every piece of content to be first created in the site's default language (which will in most cases be English, but there might be exceptions). Once the English version has been created any desired translations can then be added.
We should make it impossible for a content editor to create an initial version of a content in any language other than the default language.
module: "oe_multilingual"
Change log