Skip to content

Commit

Permalink
Chore: e2e tests on text input component (Issue/138) (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmyadams committed Apr 11, 2024
1 parent ab95d54 commit aa800d7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/e2e/textInput.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
describe('Text Input', function () {
beforeEach(function () {
cy.getData();
cy.visit('/');
});

it('should display the text input component', function () {
const textInputComponents = this.data.components.filter(component => component._component === 'textinput');
textInputComponents.forEach(textInputComponent => {
cy.visit(`/#/preview/${textInputComponent._id}`);
const stripHtml = cy.helpers.stripHtml;
cy.testContainsOrNotExists('.textinput__body', stripHtml(textInputComponent.body));
cy.testContainsOrNotExists('.textinput__title', stripHtml(textInputComponent.displayTitle));
cy.testContainsOrNotExists('.textinput__instruction', stripHtml(textInputComponent.instruction));

cy.get('.textinput-item__textbox').should('have.length', 1);
if (textInputComponent._items[0].placeholder) {
cy.get('.textinput-item__textbox').should('have.attr', 'placeholder', textInputComponent._items[0].placeholder);
};

// Make sure the current component is tested before moving to the next one
// Custom cypress tests are async so we need to wait for them to pass first
cy.wait(1000);
});
});
});

0 comments on commit aa800d7

Please sign in to comment.