diff --git a/sveltejs/public/build/bundle.js b/sveltejs/public/build/bundle.js index 08bcd87ef70d068fa8e73b51baafb1ff1492ccc7..024bf65d8dcfc1cefab156f1f3b117713b64e755 100644 Binary files a/sveltejs/public/build/bundle.js and b/sveltejs/public/build/bundle.js differ diff --git a/sveltejs/public/build/bundle.js.map b/sveltejs/public/build/bundle.js.map index c9b60ffe29b7b248709e9822d2c5300b005a9f48..2fd8c782c248d56ff9c537d671880ceaa88c0c26 100644 Binary files a/sveltejs/public/build/bundle.js.map and b/sveltejs/public/build/bundle.js.map differ diff --git a/sveltejs/src/Project/ActionButton.svelte b/sveltejs/src/Project/ActionButton.svelte index e858a4846c38db615d3dc6f1e97fafa16f77ab3f..c9899c2a33a062a83c16830d4059007ad5dde9da 100644 --- a/sveltejs/src/Project/ActionButton.svelte +++ b/sveltejs/src/Project/ActionButton.svelte @@ -16,19 +16,6 @@ const { Drupal } = window; - // Check if a project is in the queue - function isQueued(projectId) { - let isInQueue = false; - queueList.subscribe((currentList) => { - if (currentList[$activeTab]) { - isInQueue = currentList[$activeTab].some( - (item) => item.id === projectId, - ); - } - })(); - return isInQueue; - } - function handleAddToQueueClick(singleProject) { addToQueue($activeTab, singleProject); $updated = new Date().getTime(); @@ -50,7 +37,7 @@ {:else} <span> {#if PACKAGE_MANAGER.available && PACKAGE_MANAGER.errors.length === 0} - {#if isQueued(project.id)} + {#if ($queueList[$activeTab] && $queueList[$activeTab].some((item) => item.id === project.id)) || false} <ProjectButtonBase click={() => handleDequeueClick(project.id)}> {Drupal.t('Deselect')}<span class="visually-hidden" >{project.title}</span diff --git a/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php b/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php index 0ff3409d7fc06d53bda071fd47cc5a3cfc0dc78c..0138d61337eab01509f0c003793b19d0b85f9b82 100644 --- a/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php +++ b/tests/src/FunctionalJavascript/ProjectBrowserInstallerUiTest.php @@ -8,10 +8,10 @@ use Behat\Mink\Element\NodeElement; use Drupal\Core\Recipe\Recipe; use Drupal\Core\State\StateInterface; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; -use Drupal\Tests\project_browser\Traits\PackageManagerFixtureUtilityTrait; use Drupal\project_browser\EnabledSourceHandler; use Drupal\project_browser\InstallState; use Drupal\system\SystemManager; +use Drupal\Tests\project_browser\Traits\PackageManagerFixtureUtilityTrait; /** * Provides tests for the Project Browser Installer UI. @@ -445,4 +445,28 @@ class ProjectBrowserInstallerUiTest extends WebDriverTestBase { ); } + /** + * Tests the "Select/Deselect" button functionality in modal. + */ + public function testSelectDeselectToggleInModal(): void { + $assert_session = $this->assertSession(); + $this->drupalGet('admin/modules/browse'); + $this->svelteInitHelper('text', 'Cream cheese on a bagel'); + $assert_session->waitForButton('Helvetica')?->click(); + // Click select button in modal. + $assert_session->elementExists('css', '.pb-detail-modal__sidebar_element button.project__action_button')->click(); + + $this->assertSame('Deselect Helvetica', + $assert_session->elementExists('css', '.pb-detail-modal__sidebar_element button.project__action_button')->getText()); + + // Close the modal. + $assert_session->waitForButton('Close')?->click(); + $assert_session->elementNotExists('xpath', '//span[contains(@class, "ui-dialog-title") and text()="Helvetica"]'); + $select_button = $assert_session->waitForElementVisible('css', "#project-browser .pb-layout__main ul > li:nth-child(7) button.project__action_button"); + $this->assertNotEmpty($select_button); + // Asserts that the project is selected. + $was_selected = $select_button->waitFor(10, fn ($button) => $button->getText() === 'Deselect Helvetica'); + $this->assertTrue($was_selected); + } + }