Skip to content

Commit

Permalink
h3 tests finished
Browse files Browse the repository at this point in the history
  • Loading branch information
n3waz committed Jun 7, 2024
1 parent 9e9ee4d commit ce01081
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
12 changes: 12 additions & 0 deletions app_company/templates/app_company/order-request-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,20 @@ <h1>Solicitação {{order_request.id}}</h1>
<div class="works">
<label for="detailed_problem_description">Descrição detalhada do problema:</label>
<textarea id="detailed_problem_description" name="detailed_problem_description" required></textarea>
{% if error %}
<span>
<i data-lucide="octagon-alert"></i>
{{ error.message }}
</span>
{% endif %}
<label for="necessary_parts">Partes necessárias:</label>
<textarea id="necessary_parts" name="necessary_parts" required></textarea>
{% if error %}
<span>
<i data-lucide="octagon-alert"></i>
{{ error.message }}
</span>
{% endif %}
<button type="submit">Gerar ordem de serviço.</button>
</div>
{% endif %}
Expand Down
20 changes: 19 additions & 1 deletion app_company/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,25 @@ def post(self, request, pk):
order_request.isOs = True
detailed_problem_description = request.POST.get('detailed_problem_description')
necessary_parts = request.POST.get('necessary_parts')


nule_detailed_problem_description = detailed_problem_description.strip()
nule_necessary_parts = necessary_parts.strip()
if not nule_detailed_problem_description or len(detailed_problem_description) <= 1:
ctx = {
"order_request": order_request,
"error": {
"message": f"O campo não pode ser vazio!"
}
}
return render(request, "app_company/order-request-detail.html", ctx)
if not nule_necessary_parts or len(necessary_parts) <= 1:
ctx = {
"order_request": order_request,
"error": {
"message": f"O campo não pode ser vazio!"
}
}
return render(request, "app_company/order-request-detail.html", ctx)
order_request.detailedProblemDescription = detailed_problem_description
order_request.necessaryParts = necessary_parts
order_request.status = 'EM_REPARO'
Expand Down
43 changes: 41 additions & 2 deletions cypress/e2e/ConvertOrderRequest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('HomePage', () => {
cy.get('.content > form > button').click()
cy.get('.logout > button').click()
cy.GoToClient("[email protected]")
cy.get('.view > button').click()
cy.get(':nth-child(4) > a').click()
cy.get('.yes')
cy.get('.waitingForm > form > button').click()
cy.ClientLogout()
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('HomePage', () => {
cy.get('.content > form > button').click()
cy.get('.logout > button').click()
cy.GoToClient("[email protected]")
cy.get('.view > button').click()
cy.get(':nth-child(4) > a').click()
cy.get('.waitingForm > form > button').click()
cy.get('.logout').click()
cy.get('#employee > a').click()
Expand All @@ -86,4 +86,43 @@ describe('HomePage', () => {
cy.get('#detailed_problem_description').invoke('text').should('have.string', "O compressor queimou")
cy.get('#necessary_parts').invoke('text').should('have.string', "1x Compressor Tecumseh 1/4 HP 60Hz 110V")
})
it('Campos Vazios', () => {
cy.exec('python manage.py migrate')
cy.DeleteAndCreateAdm()
cy.visit('/')
cy.on("uncaught:exception", (e, runnable) => {
console.log("error", e);
console.log("runnable", runnable);
console.log("error", e.message);
return false;
});

cy.CreateClient("Luan Kato", "[email protected]")
cy.CreateSolicitation()
cy.visit('/')
cy.ClientLogout()
cy.CreateAdmin()
cy.get(':nth-child(1) > a').click()
cy.get(':nth-child(6) > a').click()
cy.get('.scheduleDateContainer > input').invoke('removeAttr', 'type').type('2024-06-18')
cy.get('.content > form > button').click()
cy.get('#status').select('Aguardando orçamento')
cy.get('.content > form > button').click()
cy.get('.budgetContainer > input').type('50')
cy.get('.content > form > button').click()
cy.get('.logout > button').click()
cy.GoToClient("[email protected]")
cy.get(':nth-child(4) > a').click()
cy.get('.yes')
cy.get('.waitingForm > form > button').click()
cy.ClientLogout()
cy.ChangeToAdmin()
cy.get(':nth-child(1) > a').click()
cy.get(':nth-child(6) > a').click()
cy.get('#detailed_problem_description').type(' ')
cy.get('#necessary_parts').type(' ')
cy.get('.works > button').click()
cy.get('.works > :nth-child(3)').invoke('text').should("have.string", "O campo não pode ser vazio!")
cy.get('.works > :nth-child(6)').invoke('text').should("have.string", "O campo não pode ser vazio!")
})
})

0 comments on commit ce01081

Please sign in to comment.