Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
cconard96 committed Jan 4, 2025
1 parent ea9fb1a commit 0695299
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
12 changes: 9 additions & 3 deletions templates/pages/tools/search_solution.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,23 @@
{% endif %}
<div class="card search-card">
<div id="search_solution_form" class="d-flex justify-content-center mb-3 mt-3">
{{ inputs.text('contains', contains, {additional_attributes: {size: 50}, input_addclass: 'me-1'}) }}
{{ inputs.text('contains', contains, {
additional_attributes: {
size: 50,
'aria-label': __('Search…'),
},
input_addclass: 'me-1'
}) }}
{{ inputs.button('search', _x('button', 'Search')) }}
{{ inputs.hidden('start', start) }}
</div>
{% if results|length %}
{{ include('components/pager.html.twig', {
no_limit_display: true,
}) }}
<div class="search-solution-results list-group list-group-flush list-group-hoverable">
<div class="search-solution-results list-group list-group-flush list-group-hoverable" role="list">
{% for result in results %}
<div class="list-group-item d-flex" data-solution-id="{{ result.id }}">
<div class="list-group-item d-flex" data-solution-id="{{ result.id }}" role="listitem">
<div class="col-auto">
<i class="{{ result.icon }}" title="{{ result.icon_title }}"></i>
</div>
Expand Down
68 changes: 68 additions & 0 deletions tests/cypress/e2e/ITILObject/ticket_form.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* ---------------------------------------------------------------------
*
* GLPI - Gestionnaire Libre de Parc Informatique
*
* http://glpi-project.org
*
* @copyright 2015-2024 Teclib' and contributors.
* @copyright 2003-2014 by the INDEPNET Development Team.
* @licence https://www.gnu.org/licenses/gpl-3.0.html
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* ---------------------------------------------------------------------
*/

describe("Ticket Form", () => {
beforeEach(() => {
cy.login();
});

it('Search for Solution', () => {
cy.createWithAPI('Ticket', {
name: 'apple',
content: 'apple',
}).as('ticket_id');
cy.get('@ticket_id').then((ticket_id) => {
cy.visit(`/front/ticket.form.php?id=${ticket_id}`);
cy.get('.timeline-buttons .main-actions button.dropdown-toggle-split').click();
cy.findByText('Add a solution').click();
cy.findByLabelText('Search a solution').click();
cy.get('#modal_searchSolution').within(() => {
cy.findByLabelText('Search…').should('have.value', 'apple');
cy.findAllByRole('listitem').should('have.length.at.least', 2);

cy.findAllByTitle('Preview').first().click();
cy.findByText('Subject').should('be.visible');
cy.findByText('Content').should('be.visible');
cy.findByText('Content').parent().next().invoke('text').should('not.be.empty').as('content');
cy.findAllByRole('listitem').should('have.length', 0);
cy.findByText('Back to results').click();

cy.findAllByTitle('Use as a solution').first().click();
});
cy.get('#modal_searchSolution').should('not.exist');
cy.get('@content').then((content) => {
cy.get('textarea[name="content"]').awaitTinyMCE().should('contain.text', content.trim());
});
});
});
});

0 comments on commit 0695299

Please sign in to comment.