Problem/Motivation

Previously the source didn't tell the Jobitem if it successfully saved a translation.
That's why the source also needed to update the job item status.
As a result, things are a bit spread through source and jobitem.

Proposed resolution

With a clean API, this can be done consistently inside the JobItem.

API changes

Check API, possibly work with exceptions if saving failed.

Comments

miro_dietiker created an issue. See original summary.

edurenye’s picture

Status: Active » Needs review
StatusFileSize
new2.8 KB

Update jobItem status inside JobItem.

Status: Needs review » Needs work

The last submitted patch, 2: make-2569651-2.patch, failed testing.

The last submitted patch, 2: make-2569651-2.patch, failed testing.

juanse254’s picture

Issue tags: +Needs tests

We need test coverage for this.

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new5.06 KB
new2.26 KB

I think it's more about modify the actual tests, these there tests that where failing had no sense, If it's reviewed or are auto-reviewed, then should not be counted as Need review. Isn't it?

miro_dietiker’s picture

Status: Needs review » Needs work

Looks pretty fine.

  1. +++ b/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php
    @@ -104,28 +104,22 @@ class ConfigSourceUiTest extends EntityTestBase {
    -    // Allow auto-accept.
    -    $default_translator = Translator::load('test_translator');
    -    $default_translator
    -      ->setSetting('auto_accept', TRUE)
    -      ->save();
    -
    

    Hm, it seems this test was pretty wrong... Indeed below there is no auto_accept behaviour expected.

  2. +++ b/src/Entity/JobItem.php
    @@ -750,13 +750,16 @@ class JobItem extends ContentEntityBase implements JobItemInterface {
    +      // We don't know if the source plugin was able to save the translation
    +      // after this point. That means that the plugin has to set the 'accepted'
    +      // states on its own.
    

    Not true anymore. Make a proper statement.

+++ b/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php
@@ -229,16 +223,16 @@ class ConfigSourceUiTest extends EntityTestBase {
-        $this->assertEqual('Spanish' || 'German', (string) $value->td[1]);
+        $this->assertEqual('Spanish', (string) $value->td[1]);

Much nice 'Spanish' || 'German' ;-)
What confuses me is that still we have submitted two jobs to the translator, from English to both German and Spanish. As a result, i would expect both should be "needs review".

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new4.11 KB
new3.29 KB

Yes sorry, I forgot to change that old comment.
Ok, the problem was that the test was reviweing the first translation, so first option was to assert that was just one in needs reviwe, but yes, we can also not review the translation, and then both will be in "needs review". This is what I did this time. Also this make less lines to change.

juanse254’s picture

maybe we can extend the tests for this, otherwise looks good.

miro_dietiker’s picture

Status: Needs review » Needs work

Yes the revert and the fixing of the button is fine.

But you stumbled accross this:

+++ b/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php
@@ -104,16 +104,16 @@ class ConfigSourceUiTest extends EntityTestBase {
+        $this->assertEqual('Spanish' || 'German', (string) $value->td[1]);

This means the assert doesn't do anything valuable at all. 'Spanish' || 'German' is simply TRUE.
Since you are fixing this test, you should make it test something useful with the "Needs review" links.

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new7.89 KB
new4.12 KB

I modified that test.
Also I added another test to check if when the translator is set to auto_accept, it gets accepted.
This last test fails and I can not figure out why, I spend to much time debugging, so I need some help.

Furthermore, I find that the job when is auto_accepted is also put to needs_review but then accepted just checking if the translator is set to auto_accept, this confuse me a bit while reading the code.

Status: Needs review » Needs work

The last submitted patch, 11: make-2569651-11.patch, failed testing.

The last submitted patch, 11: make-2569651-11.patch, failed testing.

Berdir queued 11: make-2569651-11.patch for re-testing.

The last submitted patch, 11: make-2569651-11.patch, failed testing.

juanse254’s picture

rebase needed.

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new7.97 KB

Rebased

Status: Needs review » Needs work

The last submitted patch, 17: make-2569651-17.patch, failed testing.

The last submitted patch, 17: make-2569651-17.patch, failed testing.

miro_dietiker’s picture

+++ b/src/Entity/JobItem.php
@@ -750,13 +750,15 @@ class JobItem extends ContentEntityBase implements JobItemInterface {
   public function acceptTranslation() {
-    if (!$this->isNeedsReview() || !$plugin = $this->getSourcePlugin()) {

I would prefer an early exit with !$plugin
Rest looks fine to me! :-)

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new7.82 KB
new1014 bytes

Done.

Status: Needs review » Needs work

The last submitted patch, 21: make-2569651-21.patch, failed testing.

The last submitted patch, 21: make-2569651-21.patch, failed testing.

miro_dietiker’s picture

I would have loved to commit this, but the test shows that we are missing the node_access schema in ContentEntitySourceUnitTest::testAcceptTranslation().

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new8.46 KB
new1.61 KB

Done, thanks for the clue.

giancarlosotelo’s picture

Status: Needs review » Reviewed & tested by the community

Tests are green.

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Maybe we should have used a different entity type for this, but fine. The unit test is getting very slow because of all the things we install, we'll need to think about improving that.

  • Berdir committed a4b85a5 on 8.x-1.x authored by edurenye
    Issue #2569651 by edurenye: Make JobItem::saveTranslation update the...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.