From c6262dded0df945faed70433f65a8f38ded15326 Mon Sep 17 00:00:00 2001
From: Fran Garcia-Linares <fjgarlin@gmail.com>
Date: Mon, 13 Jun 2022 12:26:56 +0200
Subject: [PATCH] Add tests.

---
 .../ProjectBrowserSource/RandomDataPlugin.php      |  1 +
 .../ProjectBrowserPluginTest.php                   | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/modules/project_browser_devel/src/Plugin/ProjectBrowserSource/RandomDataPlugin.php b/modules/project_browser_devel/src/Plugin/ProjectBrowserSource/RandomDataPlugin.php
index 4f02ff4f4..4f2e990b0 100644
--- a/modules/project_browser_devel/src/Plugin/ProjectBrowserSource/RandomDataPlugin.php
+++ b/modules/project_browser_devel/src/Plugin/ProjectBrowserSource/RandomDataPlugin.php
@@ -169,6 +169,7 @@ class RandomDataPlugin extends PluginBase implements ProjectBrowserSourceInterfa
         'field_module_categories' => [$categories[$category]],
         'field_security_advisory_coverage' => $security_values[$security]['id'],
         'field_project_machine_name' => $machine_name,
+        'is_compatible' => (bool) ($i % 4),
         'project_usage' => [],
         'project_usage_total' => rand(0, 100000),
         'flag_project_star_user_count' => rand(0, 100),
diff --git a/tests/src/FunctionalJavascript/ProjectBrowserPluginTest.php b/tests/src/FunctionalJavascript/ProjectBrowserPluginTest.php
index 724c8659e..247d7037e 100644
--- a/tests/src/FunctionalJavascript/ProjectBrowserPluginTest.php
+++ b/tests/src/FunctionalJavascript/ProjectBrowserPluginTest.php
@@ -126,4 +126,18 @@ class ProjectBrowserPluginTest extends WebDriverTestBase {
     $assert_session->responseContains('puzzle-piece-placeholder.svg');
   }
 
+  /**
+   * Tests the not-compatible flag.
+   */
+  public function testNotCompatibleButton(): void {
+    $assert_session = $this->assertSession();
+    $page = $this->getSession()->getPage();
+
+    $this->drupalGet('admin/modules/browse');
+    $assert_session->waitForElementVisible('css', '#project-browser .project');
+    $assert_session->pageTextContains('Results');
+    $disabled_button = $page->find('css', '.button.is-disabled');
+    $this->assertEquals('Not compatible', $disabled_button->getText());
+  }
+
 }
-- 
GitLab