From 8395417c14ce103c76b61af65ce40488383c09b0 Mon Sep 17 00:00:00 2001 From: Miguel Lehmann Date: Tue, 17 Sep 2024 10:32:45 +0200 Subject: [PATCH] add trim and change tests --- src/main/resources/static/js/ButtonDisabler.js | 2 +- src/test/e2e/cypress/e2e/search.cy.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/resources/static/js/ButtonDisabler.js b/src/main/resources/static/js/ButtonDisabler.js index 2fd30ab38..21566ddfa 100644 --- a/src/main/resources/static/js/ButtonDisabler.js +++ b/src/main/resources/static/js/ButtonDisabler.js @@ -3,7 +3,7 @@ document.addEventListener("DOMContentLoaded", function () { const submitButton = document.getElementById("submitButton"); function updateButtonState() { const examNumber = examNumberInput.value; - submitButton.disabled = examNumber === ""; + submitButton.disabled = examNumber.trim() === ""; } examNumberInput.addEventListener("input", updateButtonState); updateButtonState(); diff --git a/src/test/e2e/cypress/e2e/search.cy.js b/src/test/e2e/cypress/e2e/search.cy.js index 50f0cdb4d..ab54059b9 100644 --- a/src/test/e2e/cypress/e2e/search.cy.js +++ b/src/test/e2e/cypress/e2e/search.cy.js @@ -82,11 +82,13 @@ it('should rename files to subject-folder they are inside of after downloading', cy.expect(i).to.equal(3) }); -it('should disable button if not enough numbers are in input', () => { +it('should not be disabled if number is in input', () => { cy.get('input[type="text"]').type('110'); - cy.get('button').should('not.be.disabled') + cy.get('button').should('not.be.disabled'); }); it('should disable button if input is empty', () => { + cy.get('button').should('be.disabled'); + cy.get('input[type="text"]').type(' '); cy.get('button').should('be.disabled') }); \ No newline at end of file