Problem/Motivation

#2004690: taxonomy page broken inspired us to write tests for all the forms where we add a translate link into the operations.
#1971384: [META] Convert page callbacks to controllers Drupal Code Sprint Kyiv 2013

Proposed resolution

Add tests.

Remaining tasks

  • Do one test first.
  • Get a review.
  • Do the rest.

User interface changes

No.

API changes

No.

Related

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

#1998600: Block config translation fails also needs test coverage yeah. We can write those tests here at once I think. I believe we only test views translatability and not all of the UI steps there either in the navigation chain.

YesCT’s picture

current idea:

look for:

<li class="translate odd last dropbutton-action secondary-action">
<a href="/drupal/admin/structure/menu/manage/admin/translate">Translate</a>
YesCT’s picture

Assigned: Unassigned » YesCT
Status: Active » Needs review
FileSize
1.56 KB

tests were taking a long time to run, so I just took my one little one out and put it in a different class.
it runs much faster. can be moved back in later after it's nicer.

fails locally on taxonomy.

next: try it on a listing that works like menu and make sure it passes.

because it is a copy, it has extra permissions and such... for now.

Status: Needs review » Needs work

The last submitted patch, test_all_lists-2004710-3.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
FileSize
3.51 KB
3.01 KB

I'm having trouble getting a test that would pass for menus. Here is what I have so far.
The verbose from running test locally, shows *no* translate operation in the drop-buttons... uh, and I don't know why it's different in the test than locally on a site install. Permission for config_translation looks to be being added ok.

Status: Needs review » Needs work

The last submitted patch, test_all_lists-2004710-5.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
FileSize
2 KB
3.45 KB

code improvements and trying the menu translate link directly.

Status: Needs review » Needs work

The last submitted patch, test_all_lists-2004710-7.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
FileSize
0 bytes
4.44 KB

Tried looking at views... still no translate link in the drop button. So @xjm recommended seeing if profile made a difference and then trying as user 1. So about to do that now.

Here is where I am for now. ... Organized each of the tests that we will need to have, into sections... alphabetically.

YesCT’s picture

Status: Needs review » Needs work

example from moduleapitest
on how to force using standard profile.

  // Requires Standard profile modules/dependencies.
  protected $profile = 'standard';
YesCT’s picture

Status: Needs work » Needs review
FileSize
980 bytes
4.53 KB
142.01 KB

Note to self... turning of xdebug makes things run much faster.

turning on standard profile *does* make the translate operation show.

standard_profile_translate_operation.png

Next, identify what parts of standard profile are needed, add them to setup and then take the standard profile back off.

Status: Needs review » Needs work

The last submitted patch, test_all_lists-2004710-11.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
FileSize
1.2 KB
4.65 KB

I found I could install locally with minimal and play around with what is the difference. I found that blocks seems to have translate link in operations with minimal profile. so trying that in the tests.

Status: Needs review » Needs work

The last submitted patch, test_all_lists-2004710-13.patch, failed testing.

YesCT’s picture

Assigned: YesCT » Unassigned
Status: Needs work » Needs review
FileSize
1.73 KB
5.13 KB

in the tests, the blocks list is empty.
here block module and permission are added.

attempted to place an existing block, just guessing/grepping for id and machine name.
strange errors in the test results, but I'm taking a break from this.

Use of undefined constant system_menu_tools - assumed 'system_menu_tools'

Drupal\config_translation\Tests\ConfigTranslationListUITest->testTranslateOperationInListUI()
Drupal\simpletest\TestBase->run()
...
YesCT’s picture

Status: Needs review » Needs work
+++ b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.phpundefined
@@ -0,0 +1,143 @@
+ * Tests for listings altered by Configuration Translation module.
...
+ * Tests for altered listings that should have Translate operation.

I forgot to take out the word "for". "Tests" should be a verb.

....
needs work ... for other more important things.

victor-shelepen’s picture

Assigned: Unassigned » victor-shelepen
Issue tags: +CodeSprintUA
YesCT’s picture

Assigned: victor-shelepen » YesCT

likin, I'm going to try something @larowlan showed me from #1869476: Convert global menus (primary links, secondary links) into blocks
$this->drupalPlaceBlock('menu_navigation', array('region' => 'secondary_menu'), array('menu' => 'account'));
ping me in irc if you have some work to post before I give it a try.

victor-shelepen’s picture

This patches confuse me. Because they are not applicable. Could anybody filter the content of the issue and clarify the task?

YesCT’s picture

Status: Needs work » Needs review
FileSize
1.53 KB
4.89 KB

It was a while since I worked on this too. :) After a few minutes I remembered to apply it to the git clone of the config_translation project which is in modules directory. :) Then it applies.

@tim.plunkett picked out an easier block to add.

here it is.
I ran the test locally and I can see the block added to the block list *and* Translate in the dropbutton. So we can then test that Translate link is there next.

victor-shelepen’s picture

YesCT’s picture

yes, I'm not sure why Translate operation link does not get added to the menus in minimal profile. ... but I think the *test* is ok.

Gábor Hojtsy’s picture

Does this work manually?

victor-shelepen’s picture

Manualy. It works.

YesCT’s picture

Assigned: YesCT » Unassigned
FileSize
5.51 KB
5.49 KB

cleaned up some intermediate tries at testing.
some tests still needed.

unassigning, taking a break from this for a bit.

when trying manually, try it on a minimal profile.
also, run the test locally to see the verbose message screens.

xjm’s picture

Nice work! One thing to keep in mind is that the minimal profile and the testing profile are two different profiles.

A few suggestions:

  1. +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.phpundefined
    @@ -0,0 +1,154 @@
    +    // Test if Translate appears anywhere on the page.
    +    $this->assertText($translate_operation_title);
    ...
    +    // Simple test for 'Translate' anywhere on the taxonomy list page.
    +    $this->drupalGet($list_url);
    +    $this->assertText($translate_operation_title);
    

    This assertion is probably redundant now that we have the check for the translate link.

  2. +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.phpundefined
    @@ -0,0 +1,154 @@
    +    $translate_link = 'admin/structure/block/manage/stark.' . $block_machine_name . '/translate';
    +    // Test if the link to translate the block is on the page.
    +    $this->assertLinkByHref($translate_link);
    

    This assertion is the core of what we want to test -- looks good!

  3. +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.phpundefined
    @@ -0,0 +1,154 @@
    +    // Create a test menu to decouple looking for Translate operations
    +    // link so this does not test more than necessary.
    +    $this->drupalGet('admin/structure/menu/add');
    +    // Lowercase the machine name. Find the issue that is supposed to be making
    +    // randomMachineName().
    +    $menu_name = drupal_strtolower($this->randomName(16));
    +    $label = $this->randomName(16);
    +    $edit = array(
    +      'id' => $menu_name,
    +      'description' => '',
    +      'label' =>  $label,
    +    );
    +    $this->drupalPost('admin/structure/menu/add', $edit, t('Save'));
    

    Once this is working (I think it is?), a good next step would be to create the menu link programmatically instead of with drupalPost(). (Similarly for the vocabulary.)

  4. +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.phpundefined
    @@ -0,0 +1,154 @@
    +    // Views 'admin/structure/views'.
    +    // Frontpage view is enabled in test minimal profile, so do not need to add
    +    // a test view.
    +    $list_url = 'admin/structure/views';
    

    So, it's bad practice to rely on default anything provided by the testing profile. We always want a decoupled test implementation.

    In this case, this couples the test to both the Node module and the Frontpage view. See #1541298: Remove Node module dependency from Testing profile.

    So, instead, I'd suggest putting this in a separate test that uses one of the Views' modules base classes and test views.

Status: Needs review » Needs work
Issue tags: -CodeSprintUA

The last submitted patch, test_all_lists-2004710-25.patch, failed testing.

xjm’s picture

Status: Needs work » Needs review

The test was stuck, so I cancelled and requeued it.

#25: test_all_lists-2004710-25.patch queued for re-testing.

xjm’s picture

Issue summary: View changes

I've got time to work with this task. I am working with Kyiv Drupal initiative.

Status: Needs review » Needs work
Issue tags: +CodeSprintUA

The last submitted patch, test_all_lists-2004710-25.patch, failed testing.

kfritsche’s picture

Assigned: Unassigned » kfritsche

Working on this now.

kfritsche’s picture

Moved the single test to do*ListTest() function to have a better structured test and not everything in this single function. Moved the views test to a new Test which extends the UITestBase.

The test is now working, except the new View test. I'm currently trying to figure out how it works.
But 1., 3. and 4. from #26 should be fixed.

Still lots of other Tests are marked as todo.

kfritsche’s picture

Status: Needs work » Needs review

Set to needs review.

Status: Needs review » Needs work

The last submitted patch, test_all_lists-2004710-31.patch, failed testing.

kfritsche’s picture

Assigned: kfritsche » Unassigned
FileSize
8.4 KB
6.66 KB

View Test works now.
Minor cleanup with comments.
More tomorrow.

kfritsche’s picture

Status: Needs work » Needs review

As always forgot status change...

YesCT’s picture

Here is a clean up on just that.

I suggest we commit this, and then add the rest of the tests later. This can let the testbot go with these good tests that we have while we add the rest.

Gábor Hojtsy’s picture

Status: Needs review » Fixed

I agree that the test to land now would be useful. Thanks, committed! We may want to work on a followup or more followups to complete the coverage.

Gábor Hojtsy’s picture

Title: Add tests for all the forms to see if they have translate link in operations » Add tests for block, menu, vocabulary and views listings
Issue tags: +D8MI, +language-config

Retitled for what was achieved. I think continuing in #2019831: people and roles page broken would be good, adding tests for roles to verify the before/after break/pass of that patch. I asked @kfritsche to work on that next.

kfritsche’s picture

YesCT’s picture

Status: Fixed » Closed (fixed)

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

victor-shelepen’s picture

Status: Closed (fixed) » Needs work

I have problems wih the test. I am resolving this issue. https://drupal.org/node/1978916.
I receive a lot of test errors that are not related with my task. Could anybody make some specifications? Where should I move? I understand I need correct tests. But, there are many tests. I do not know where to start.

YesCT’s picture

Status: Needs work » Closed (fixed)

@likin Thanks for working on that issue.

I think it is not a related to this config_translation issue though, so re-closing this.

YesCT’s picture

Issue summary: View changes

added related