Skip to content

Commit

Permalink
fix e2e test event_template.cy.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaskikutis committed Jan 29, 2024
1 parent 7eebef9 commit c4fa3cd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
10 changes: 6 additions & 4 deletions e2e/cypress/e2e/events/event_template.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {setup, login, waitForPageLoad, Modal, SubNavBar} from '../../support/common';
import {UiFrameworkModal} from '../../support/common/ui/ui-framework-modal';
import {EventEditor} from '../../support/planning';

describe('Planning.Events: event templates', () => {
const editor = new EventEditor();
const subnav = new SubNavBar();
const modal = new Modal();
const uiFrameworkModal = new UiFrameworkModal();

const event = {
'dates.start.date': '12/12/2045',
Expand Down Expand Up @@ -54,13 +56,13 @@ describe('Planning.Events: event templates', () => {
editor.actionMenu
.getAction('Save event as a template')
.click();
modal.waitTillOpen(30000);
modal.element
uiFrameworkModal.waitTillOpen(30000);
uiFrameworkModal.element
.find('textarea')
.type('Example');
modal.getFooterButton('Submit')
uiFrameworkModal.getFooterButton('Submit')
.click();
modal.waitTillClosed(30000);
uiFrameworkModal.waitTillClosed(30000);

// Wait for the Editor to re-render
// otherwise the close button may re-render during attempts to click it
Expand Down
33 changes: 33 additions & 0 deletions e2e/cypress/support/common/ui/ui-framework-modal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {Popup} from './popup';

export class UiFrameworkModal extends Popup {
/**
* Creates an instance of the Modal wrapper
* @param {string} selector - The CSS selector to find the modal
*/
constructor(selector = '.p-dialog') {
super(selector);
}

get footer() {
return this.element.find('.p-dialog-footer');
}

/**
* Returns the dom node for a specific button in the footer
* @param {string} label - The label on the button
* @param {number} timeout - The ms timeout when getting the button
* @returns {Cypress.Chainable<JQuery<HTMLElement>>}
*/
getFooterButton(label, timeout = 3000, shouldExist = true) {
return this.element.find('.p-dialog-footer')
.contains(label, {timeout: timeout})
.should('exist');
}

shouldContainTitle(title: string) {
return this.element.find('.p-dialog-header')
.should('exist')
.contains(title);
}
}

0 comments on commit c4fa3cd

Please sign in to comment.