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

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

Merged
merged 11 commits into from
Oct 11, 2018

Conversation

sergepavle
Copy link
Member

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

  • Added:
  • Changed:
  • Deprecated:
  • Removed:
  • Fixed:
  • Security:

@sergepavle sergepavle changed the title Openeuropa 660 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 Oct 9, 2018
*
* @Given I am visiting the :content_type_name create node page
*/
public function iAmVisitingTheCreateNodePage(string $content_type_name): void {
Copy link
Member

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"

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -201,4 +202,64 @@ protected function getLanguageIdByName(string $name): string {
throw new \InvalidArgumentException("Language '{$name}' not found.");
}

/**
* Redirect user on Node creation page.
Copy link
Member

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."

*
* @Then I should not see selectbox with label :label
*/
public function iShouldNotSeeSelectboxWithLabel(string $label): void {
Copy link
Member

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

}

/**
* Check that selectbox with node language selector is hidden.
Copy link
Member

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)

->getPage()
->findField($label);
if ($element) {
throw new \RuntimeException("Selectbox for selecting initial language still visible.");
Copy link
Member

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.

* @param string $title
* Title of node.
*
* @Then I have to be sure that :title node translation only in site default language.
Copy link
Member

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"

* @Then I have to be sure that :title node translation only in site default language.
*/
public function assertOnlyDefaultLanguageTranslationExist(string $title) {
$title_element = $this->getSession()
Copy link
Member

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?

imanoleguskiza
imanoleguskiza previously approved these changes Oct 10, 2018
@@ -0,0 +1,17 @@
@api
Feature: Content initial language.
In order to be create content
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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

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)) {
Copy link
Member

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()

}

$node_translation_languages = $node->getTranslationLanguages();
if (!is_array($node_translation_languages) || count($node_translation_languages) !== 1) {
Copy link
Member

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.

* @param string $content_type_name
* Content type name.
*
* @Given I am visiting the :content_type_name creation page
Copy link
Member

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


$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.");
Copy link
Member

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.

nagyad
nagyad previously approved these changes Oct 11, 2018
imanoleguskiza
imanoleguskiza previously approved these changes Oct 11, 2018
@sergepavle sergepavle dismissed stale reviews from imanoleguskiza and nagyad via ec0fa14 October 11, 2018 11:20
@upchuk upchuk merged commit ec4fec5 into master Oct 11, 2018
@upchuk upchuk deleted the OPENEUROPA-660 branch October 11, 2018 14:37
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.

4 participants