Problem/Motivation

The tool menu link added by the tracker module is missing test coverage.

Proposed resolution

Add tests for tool menu link added by tracker module

Remaining tasks

Commit it.

User interface changes

None

API changes

None

Data model changes

None.

Original Report

According to the documentation of the tracker module, after it is enabled there should be a new link in the Tools menu and a tab on a user's profile page. This functionality appears to be broken in the current branch. See tracker_help() and the doc page.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BryanGullan’s picture

Just so others know, I'm currently working on a patch for this.

BryanGullan’s picture

Status: Active » Needs review
FileSize
987 bytes

I've attached a patch for this. Question: should there be any tests created to confirm that the menu items are present? I don't think that other menu items in that menu have tests, but I could be mistaken.

dags’s picture

Minor whitespace fix:

+++ b/core/modules/tracker/tracker.module
@@ -120,6 +120,18 @@ function tracker_cron() {
+  ¶

Patch adds the 'Tracker' tab to the user profile page, but I don't see anything in the Tools menu. Actually, I can't even load the Tools menu page (/admin/structure/menu/manage/tools). I think my local dev env. might is busted or misconfigured somehow... I'm getting this on every menu mange page:

PHP Warning:  Uncaught exception 'Symfony\Component\Routing\Exception\ResourceNotFoundException' with message 'None of the routers in the chain matched this request
GET /admin/structure/menu/manage HTTP/1.1
Accept:          text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Host:            localhost
User-Agent:      Symfony/2.X

' in /Applications/MAMP/htdocs/d8/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php:202
BryanGullan’s picture

Hey,

It does sound like your build is playing up. Works fine for me on the fresh install on which I created the patch. The Tools menu item is labelled "Recent content", in line with the description in the existing help text within the tracker module.

Re. the whitespace fix: as part of the tracker_cron() function, that's unrelated to this bug and the patch: the patch does not change that particular line within the module file. To be pedantic, my opinion would be that the whitespace there should be fixed in its own issue (I've not looked, but maybe there is already an issue for that?) :-)

Bryan

BryanGullan’s picture

Issue summary: View changes

Updated issue summary.

miro_dietiker’s picture

Issue summary: View changes

makemineatriple, the whitespace reference by dags was wrong.
Your patch added a whitespace in hook_menu() though.

pwolanin’s picture

Status: Needs review » Needs work

patch is outdated

duellj’s picture

Status: Needs work » Needs review
FileSize
985 bytes

Rerolled patch to remove whitespace.

miro_dietiker’s picture

Issue tags: +Needs tests

This functionality was missing after port, because there's no test coverage.
A fix should add test coverage as well.

dawehner’s picture

Status: Needs review » Needs work

We also have to move to .menu_links.yml files.

joshi.rohit100’s picture

I can see the Track link in user profile. So, Is this need to be done or just test case waiting ?

miro_dietiker’s picture

joshi.rohit100 you could check if there is a test by ... for instance file a patch that removes the Track link and see if it fails with the testbots on d.o.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Issue tags: +Bug Smash Initiative

Thank you for reporting this issue and posting a patch.

As part of the Bug Smash Initiative, we are triaging issues that are marked "Needs tests". This issue was marked "Needs tests" back in June 2014. The issue itself is fixed, joshi.rohit100 pointed that out in July 2014. Also in July 2014, miro_dietiker recommended adding tests because the "This functionality was missing after port".

If I get this, this needs a test to confirm that 'recent content' link exists in the tools menu and that the 'Activity' tab appears on the users profile page. Looking at the existing functional tests,TrackerTest and TrackerNodeAccessTest, there are usages of $this->drupalGet('activity'); and assertions on the text of the resulting page. Is that sufficient tests for the activity tab? I didn't see any tests using the 'recent content' link, so that will still need a test.

jibran’s picture

The bug seems to be fixed.
In core/modules/tracker/tracker.routing.yml

a tab on a user's profile page.

We now have

tracker.user_tab:
  path: '/user/{user}/activity'
  defaults:
    _controller: '\Drupal\tracker\Controller\TrackerController::buildContent'
    _title_callback: '\Drupal\tracker\Controller\TrackerController::getTitle'
  requirements:
    _permission: 'access content'
    _entity_access: 'user.view'
    user: \d+

And we do have tests for this in \Drupal\Tests\tracker\Functional\TrackerTest::testTrackerUser()

here should be a new link in the Tools menu

We have core/modules/tracker/tracker.links.menu.yml

tracker.page:
  title: 'Recent content'
  route_name: tracker.page

We don't have dedicated test for this.

I didn't see any tests using the 'recent content' link, so that will still need a test.

we have \Drupal\Tests\tracker\Functional\TrackerTest::testTrackerHistoryMetadata() for that.

quietone’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
1.4 KB

@jibran, thanks for your help here and in #bugsmash. Without that his help this patch would not be here.

jibran’s picture

Yay! patch looks great. Here are some suggestions:

  1. +++ b/core/modules/tracker/tests/src/Functional/TrackerRecentContentLinksTest.php
    @@ -0,0 +1,53 @@
    +  protected function setUp(): void {
    +    parent::setUp();
    +  }
    

    This can be removed.

  2. +++ b/core/modules/tracker/tests/src/Functional/TrackerRecentContentLinksTest.php
    @@ -0,0 +1,53 @@
    +    $this->drupalPlaceBlock('system_menu_block:tools');
    

    Let's assert no link before adding this block.

  3. +++ b/core/modules/tracker/tests/src/Functional/TrackerRecentContentLinksTest.php
    @@ -0,0 +1,53 @@
    +    $user = $this->drupalCreateUser([]);
    

    [] not required.

quietone’s picture

Yay, indeed!

1. Ah, silly me. Too focused on having a test outside of migrate actually work that I didn't notice this.
2. Good idea. Added.
3. Didn't know that. Fixed.

I renamde the test file which made an interdiff not helpful at all, so I made a diff instead.

jibran’s picture

This seems ready just a nit.

+++ b/core/modules/tracker/tests/src/Functional/TrackerRecentContentLinkTest.php
@@ -0,0 +1,47 @@
+    $this->drupalGet('<front>');

We can move this line two lines above because we are trying to assert that frontpage has no link before we place the block.

quietone’s picture

Oh, that makes sense.

jibran’s picture

Title: Tracker module no longer creates a Tools menu link or a tab on users' profiles » Add tests for tracker module's Tools menu link
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Thanks, looks good now. Updated the title and IS.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 1ea2763329 to 9.1.x and a832400398 to 9.0.x and d63ddf191e to 8.9.x. Thanks!

I ran the test on 9.1.x before committing - it was green.

  • alexpott committed 1ea2763 on 9.1.x
    Issue #2120877 by quietone, BryanGullan, duellj, jibran, miro_dietiker,...

  • alexpott committed a832400 on 9.0.x
    Issue #2120877 by quietone, BryanGullan, duellj, jibran, miro_dietiker,...

  • alexpott committed d63ddf1 on 8.9.x
    Issue #2120877 by quietone, BryanGullan, duellj, jibran, miro_dietiker,...

Status: Fixed » Closed (fixed)

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