Skip to content

Commit

Permalink
VACMS-14955: Hide ief_reference_save button for CLP (#16585)
Browse files Browse the repository at this point in the history
* VACMS-14955: Hide ief_reference_save button for CLP

* VACMS-14955: Moves IEF form modification to va_gov_entity_browser.

* VACMS-14955: Adds entity browser cucumber assertions.

* VACMS-14955: Adds test for add new downloadable resource button style change when using Entity Browser.

---------

Co-authored-by: Jill Adams <[email protected]>
Co-authored-by: Daniel Sasser <[email protected]>
  • Loading branch information
3 people authored Jan 5, 2024
1 parent b06e6f7 commit 3e70254
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/**
* @file
* Contains va_gov_entity_browser.module.
*/

use Drupal\Core\Form\FormStateInterface;

/**
* Implements hook_inline_entity_form_reference_form_alter().
*/
function va_gov_entity_browser_inline_entity_form_reference_form_alter(array &$reference_form, FormStateInterface &$form_state): void {
// Hide IEF save button when using Entity Browser.
if (!empty($reference_form['entity_browser']) && !empty($reference_form['actions']['ief_reference_save'])) {
$reference_form['actions']['ief_reference_save']['#attributes']['style'] = 'display: none;';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ Feature: Content Type: Campaign Landing Page
Then I should see an element with the selector "#edit-field-clp-resources-header-0-value"
And I can fill in field with selector "#edit-field-clp-resources-header-0-value" with fake text
And I can fill in field with selector "#edit-field-clp-resources-intro-text-0-value" with fake text

# Test the 'Add new Downloadable resource' button
When I click the "Add new Downloadable resource" button
Then I can fill in "Name" field with fake text
And I can fill in "External File URL" field with fake text
And I can fill in "Description" field with fake text
# TODO: Test section drop-down for this segment

# Test the 'Add existing Downloadable resource' button
When I click the "Cancel" button
Then I click the "Add existing Downloadable resource" button
And I should see "Select Downloadable resource"
# TODO: Test clicking the "Select Downloadable resource" button and modal
And I click the "Add existing Downloadable resource" button
And I select 2 items from the "Select Downloadable resource" Entity Browser modal
Then I should not see an element with the selector ".ief-entity-submit.button[name='ief-reference-submit-field_clp_resources-form'"

# Test Downloadable resources CTA
And I should see "Downloadable resources cta"
And I click the "Add Call to action" button
And I fill in "Link" field with fake link
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Given } from "@badeball/cypress-cucumber-preprocessor";

Given(`I select one item from the {string} Entity Browser modal`, (text) => {
cy.contains(text).click({ force: true });
cy.get(".entity-browser-modal iframe").should("exist");
cy.wait(3000);

cy.get(".entity-browser-modal iframe")
.iframe()
.within(() => {
cy.get("tr")
.should("exist")
.parent()
.find("[type='checkbox']")
.first()
.check({ force: true });
cy.get("#edit-submit").click({ force: true });
});
cy.get(".entity-browser-modal iframe").should("not.exist");
});

Given(
`I select {int} items from the {string} Entity Browser modal`,
(numItems, text) => {
cy.contains(text).click({ force: true });
cy.get(".entity-browser-modal iframe").should("exist");
cy.wait(3000);
cy.get(".entity-browser-modal iframe")
.iframe()
.within(() => {
for (let i = 0; i < numItems; i++) {
cy.get("input[type='checkbox']")
.eq(i)
.should("exist")
.check({ force: true });
}
cy.get("#edit-submit").click({ force: true });
});
cy.get(".entity-browser-modal iframe").should("not.exist");
}
);

0 comments on commit 3e70254

Please sign in to comment.