Verified Commit a6797350 authored by Jess's avatar Jess
Browse files

Issue #3279279 by phenaproxima, dww, tedbow: Remove "Download" link from Available Updates report

(cherry picked from commit 71f0e1de)
parent 0fcc3a07
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -34,11 +34,6 @@
    </div>
    <div class="layout-column layout-column--half">
      <ul class="project-update__version-links">
        {% if version.core_compatible is not defined or version.core_compatible %}
          <li class="project-update__download-link">
            <a href="{{ version.download_link }}">{{ 'Download'|t }}</a>
          </li>
        {% endif %}
        <li class="project-update__release-notes-link">
          <a href="{{ version.release_link }}">{{ 'Release notes'|t }}</a>
        </li>
+3 −10
Original line number Diff line number Diff line
@@ -876,25 +876,18 @@ protected function assertCoreCompatibilityMessage(string $version, string $expec
    $this->assertStringContainsString("Requires Drupal core: $expected_range", $compatibility_details->getText());
    $details_summary_element = $compatibility_details->find('css', 'summary');
    if ($is_compatible) {
      $download_version = str_replace('.', '-', $version);
      // If an update is compatible with the installed version of Drupal core,
      // it should have a download link and the details element should be closed
      // by default.
      // the details element should be closed by default.
      $this->assertFalse($compatibility_details->hasAttribute('open'));
      $this->assertSame('Compatible', $details_summary_element->getText());
      $this->assertEquals(
        "http://example.com/{$this->updateProject}-$download_version.tar.gz",
        $update_element->findLink('Download')->getAttribute('href')
      );
    }
    else {
      // If an update is not compatible with the installed version of Drupal
      // core, it should not have a download link and the details element should
      // be open by default.
      // core, the details element should be open by default.
      $this->assertTrue($compatibility_details->hasAttribute('open'));
      $this->assertSame('Not compatible', $details_summary_element->getText());
      $this->assertFalse($update_element->hasLink('Download'));
    }
    $this->assertFalse($update_element->hasLink('Download'));
  }

}
+0 −11
Original line number Diff line number Diff line
@@ -156,7 +156,6 @@ public function testMajorUpdateAvailable() {
          $this->standardTests();
          $this->assertUpdateTableTextNotContains('Security update required!');
          $this->assertUpdateTableElementContains(Link::fromTextAndUrl('9.0.0', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0-release"))->toString());
          $this->assertUpdateTableElementContains(Link::fromTextAndUrl('Download', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0.tar.gz"))->toString());
          $this->assertUpdateTableElementContains(Link::fromTextAndUrl('Release notes', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0-release"))->toString());
          $this->assertUpdateTableTextNotContains('Up to date');
          $this->assertUpdateTableTextContains('Not supported!');
@@ -425,16 +424,6 @@ public function testUnsupportedRelease() {
    }
  }

  /**
   * {@inheritdoc}
   */
  protected function assertVersionUpdateLinks($label, $version, $download_version = NULL) {
    // Test XML files for Drupal core use '-' in the version number for the
    // download link.
    $download_version = str_replace('.', '-', $version);
    parent::assertVersionUpdateLinks($label, $version, $download_version);
  }

  /**
   * {@inheritdoc}
   */
+6 −17
Original line number Diff line number Diff line
@@ -87,13 +87,15 @@ protected function standardTests() {
    $this->assertSession()->linkByHrefExists('http://example.com/project/drupal');
    $this->assertSession()->pageTextNotContains('No available releases found');
    $this->assertSession()->pageTextContains('Last checked:');
    // No download URLs should be present.
    $this->assertSession()->responseNotContains('.tar.gz');
  }

  /**
   * Asserts the expected security updates are displayed correctly on the page.
   *
   * @param string $project_path_part
   *   The project path part needed for the download and release links.
   *   The project path part needed for the release link.
   * @param string[] $expected_security_releases
   *   The security releases, if any, that the status report should recommend.
   * @param string $expected_update_message_type
@@ -109,11 +111,7 @@ protected function assertSecurityUpdates($project_path_part, array $expected_sec
    $all_security_release_urls = array_map(function ($link) {
      return $link->getAttribute('href');
    }, $page->findAll('css', "$update_element_css_locator .version-security a[href$='-release']"));
    $all_security_download_urls = array_map(function ($link) {
      return $link->getAttribute('href');
    }, $page->findAll('css', "$update_element_css_locator .version-security a[href$='.tar.gz']"));
    if ($expected_security_releases) {
      $expected_download_urls = [];
      $expected_release_urls = [];
      if ($expected_update_message_type === static::SECURITY_UPDATE_REQUIRED) {
        $assert_session->elementTextNotContains('css', $update_element_css_locator, 'Update available');
@@ -129,23 +127,18 @@ protected function assertSecurityUpdates($project_path_part, array $expected_sec
      foreach ($expected_security_releases as $expected_security_release) {
        $expected_url_version = str_replace('.', '-', $expected_security_release);
        $release_url = "http://example.com/$project_path_part-$expected_url_version-release";
        $download_url = "http://example.com/$project_path_part-$expected_url_version.tar.gz";
        $assert_session->responseNotContains("http://example.com/$project_path_part-$expected_url_version.tar.gz");
        $expected_release_urls[] = $release_url;
        $expected_download_urls[] = $download_url;
        // Ensure the expected links are security links.
        $this->assertContains($release_url, $all_security_release_urls, "Release $release_url is a security release link.");
        $this->assertContains($download_url, $all_security_download_urls, "Release $download_url is a security download link.");
        $assert_session->linkByHrefExists($release_url);
        $assert_session->linkByHrefExists($download_url);
      }
      // Ensure no other links are shown as security releases.
      $this->assertEquals([], array_diff($all_security_release_urls, $expected_release_urls));
      $this->assertEquals([], array_diff($all_security_download_urls, $expected_download_urls));
    }
    else {
      // Ensure there were no security links.
      $this->assertEquals([], $all_security_release_urls);
      $this->assertEquals([], $all_security_download_urls);
      $assert_session->pageTextNotContains('Security update required!');
      if ($expected_update_message_type === static::UPDATE_AVAILABLE) {
        $assert_session->elementTextContains('css', $update_element_css_locator, 'Update available');
@@ -168,18 +161,14 @@ protected function assertSecurityUpdates($project_path_part, array $expected_sec
   *   The label for the update.
   * @param string $version
   *   The project version.
   * @param string|null $download_version
   *   (optional) The version number as it appears in the download link. If
   *   $download_version is not provided then $version will be used.
   */
  protected function assertVersionUpdateLinks($label, $version, $download_version = NULL) {
    $download_version = $download_version ?? $version;
  protected function assertVersionUpdateLinks($label, $version) {
    $update_element = $this->findUpdateElementByLabel($label);
    // In the release notes URL the periods are replaced with dashes.
    $url_version = str_replace('.', '-', $version);

    $this->assertEquals($update_element->findLink($version)->getAttribute('href'), "http://example.com/{$this->updateProject}-$url_version-release");
    $this->assertEquals($update_element->findLink('Download')->getAttribute('href'), "http://example.com/{$this->updateProject}-$download_version.tar.gz");
    $this->assertStringNotContainsString("http://example.com/{$this->updateProject}-$version.tar.gz", $update_element->getOuterHtml());
    $this->assertEquals($update_element->findLink('Release notes')->getAttribute('href'), "http://example.com/{$this->updateProject}-$url_version-release");
  }

+0 −5
Original line number Diff line number Diff line
@@ -32,11 +32,6 @@
    </div>
    <div class="layout-column layout-column--half">
      <ul class="project-update__version-links">
        {% if version.core_compatible is not defined or version.core_compatible %}
          <li class="project-update__download-link">
            <a href="{{ version.download_link }}">{{ 'Download'|t }}</a>
          </li>
        {% endif %}
        <li class="project-update__release-notes-link">
          <a href="{{ version.release_link }}">{{ 'Release notes'|t }}</a>
        </li>