Skip to content
Snippets Groups Projects
Commit 86e6517c authored by utkarsh_33's avatar utkarsh_33 Committed by Chris Wells
Browse files

Issue #3489126: Select/Deselect button is not working in modal

parent 17c1f059
No related branches found
No related tags found
1 merge request!633#3489126:Select/Deselect button is not working in modal
Pipeline #359482 passed with warnings
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -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
......
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment