Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#75 Limitierung der Prüfungsnummern-Eingabe #79

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/resources/templates/fragments/exam-number-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<div>
<form action="#" th:action="@{/search}" th:object="${examNumberForm}" method="post">
<label for="examNumber">Prüfungsnummer eingeben*:</label>
<input type="text" name="examNumber" id="examNumber"
placeholder="20202" th:value="*{examNumber}" required>
<input type="text" name="examNumber" id="examNumber" oninput="this.value = this.value.replace(/\D+/g, '')"
placeholder="20202" th:value="*{examNumber}" th:maxlength="5" required>
<button type="submit" id="submitButton">Suchen</button>
<p th:if="${#fields.hasErrors('examNumber')}" th:errors="*{examNumber}">Prüfungsnummer Error</p>
</form>
Expand Down
11 changes: 10 additions & 1 deletion src/test/e2e/cypress/e2e/search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ it('should display error when no exams were found', () => {
});

it('should display error when exam number is invalid', () => {
cy.get('input[type="text"]').type('abc');
cy.get('input[type="text"]').type('123');
cy.get('button').click();
cy.contains('Prüfungsnummer muss 5 Ziffern lang sein');
});
Expand Down Expand Up @@ -81,3 +81,12 @@ it('should rename files to subject-folder they are inside of after downloading',
}
cy.expect(i).to.equal(3)
});


it('should not be able to input more than 5 characters', () => {
cy.get('input[type="text"]').type('110000').should('have.value', '11000');
});

it('should not be able to input other characters', () => {
cy.get('input[type="text"]').type('a2c').should('have.value', '2');
});
Loading