Skip to content

Commit

Permalink
finishing managing order tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophia-15 committed Jun 6, 2024
1 parent 85793e8 commit 51512d2
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 78 deletions.
16 changes: 8 additions & 8 deletions app_company/templates/app_company/order-request-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ <h1>Solicitação {{order_request.id}}</h1>
{% endif %}
{% endif %}
{% if order_request.status != "ACEITO" %}
<button type="submit">Atualizar</button>
<button type="submit">Atualizar</button>
{% else %}
<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>
<label for="necessary_parts">Partes necessárias:</label>
<textarea id="necessary_parts" name="necessary_parts" required></textarea>
<button type="submit">Gerar ordem de serviço.</button>
</div>
<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>
<label for="necessary_parts">Partes necessárias:</label>
<textarea id="necessary_parts" name="necessary_parts" required></textarea>
<button type="submit">Gerar ordem de serviço.</button>
</div>
{% endif %}
</form>

Expand Down
44 changes: 23 additions & 21 deletions app_company/templates/app_company/service-order.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,31 @@ <h1>Solicitação {{service_order.id}}</h1>
</option>
</select>

{% if not service_order.employee %}

{% if user.role == 'A' %}
<div class="technicianContainer">
<label for="tecnician">Designar Técnico:</label>
<select name="tecnician" id="tecnician" placeholder="Escolher Técnico">
<option value="" selected disabled>
Escolher Técnico
</option>
{% for tec in employees %}
<option value="{{ tec.id }}">
{{ tec.first_name }}
</option>
{% endfor %}
</select>
</div>

<label>Deseja assumir a OS?</label>
<button type="submit" name="assume" class="assume" value="true">Assumir OS</button>
{% else %}
{% if not service_order.employee and user.role == 'F' %}
<label>Deseja assumir a OS?</label>
<button type="submit" name="assume" class="assume" value="true">Assumir OS</button>
{% endif %}
{% else %}
<div class="technicianContainer">
<label for="tecnician">Designar Técnico:</label>
<select name="tecnician" id="tecnician" placeholder="Escolher Técnico">
<option value="" selected disabled>
Escolher Técnico
</option>
{% for tec in employees %}
<option
value="{{ tec.id }}"
{% if service_order.employee and service_order.employee.first_name == tec.first_name %}
selected
{% endif %}
>
{{ tec.first_name }}
</option>
{% endfor %}
</select>
</div>

<label>Deseja assumir a OS?</label>
<button type="submit" name="assume" class="assume" value="true">Assumir OS</button>
{% endif %}
<br>
<button class="update" type="submit">Atualizar</button>
Expand Down
3 changes: 2 additions & 1 deletion app_company/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ def post(self, request, pk):

if not service_order.employee and employee:
service_order.employee_id = employee

elif service_order.employee and employee and service_order.employee != employee:
service_order.employee_id = employee

service_order.save()
messages.success(request, "Status atualizado.")
Expand Down
128 changes: 91 additions & 37 deletions cypress/e2e/ManagingOrder.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,96 @@ describe('HomePage', () => {
cy.get('.employee').invoke('text').should("have.string", "Robson")
})

// it('Remover uma ordem de serviço com sucesso', () => {
// 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;
// });
it('Remover uma ordem de serviço com sucesso', () => {
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.CreateSolicitation("Sophia Gallindo")
// cy.visit('/')
// cy.ClientLogout()
// cy.CreateAdmin()
// cy.get(':nth-child(1) > a').click()
// cy.get(':nth-child(6) > a').click()
// cy.get('#status').select('Aguardando orçamento')
// cy.get('.content > form > button').click()
// cy.get('.budgetContainer > input').type("200")
// cy.get('.content > form > button').click()
// cy.get('.logout > button').click()
// cy.GoToClient()
// cy.get(':nth-child(4) > a').click()
// cy.get('.yes > label').click()
// cy.get('.waitingForm > form > button').click()
// cy.ClientLogout()
// cy.ChangeToAdmin()
// cy.get('ul > :nth-child(1) > a').click()
// cy.CreateOrder()
// cy.get(':nth-child(6) > a').click()
// cy.get('#status').select('Cancelado')
// cy.get('.update').click()
// cy.get('ul > :nth-child(1) > a').click()
// cy.get('.deleteOrderRequest').click()
// cy.get('.deleteRequestOrder').click()
// cy.get('tbody > tr:first-child').should("not.exist")
// })
cy.CreateClient("Sophia Gallindo")
cy.CreateSolicitation()
cy.visit('/')
cy.ClientLogout()
cy.CreateAdmin()
cy.get(':nth-child(1) > a').click()
cy.get(':nth-child(6) > a').click()
cy.get('#status').select('Aguardando orçamento')
cy.get('.content > form > button').click()
cy.get('.budgetContainer > input').type("200")
cy.get('.content > form > button').click()
cy.get('.logout > button').click()
cy.GoToClient()
cy.get(':nth-child(4) > a').click()
cy.get('.yes > label').click()
cy.get('.waitingForm > form > button').click()
cy.ClientLogout()
cy.ChangeToAdmin()
cy.get('ul > :nth-child(1) > a').click()
cy.CreateOrder()
cy.get(':nth-child(6) > a').click()
cy.get('#status').select('Cancelado')
cy.get('.update').click()
cy.get('ul > :nth-child(1) > a').click()
cy.get('.deleteOrderRequest').click()
cy.get('.deleteRequestOrder').click()
cy.get('tbody > tr:first-child').should("not.exist")
})

it('Atualizar uma Ordem de Serviço com sucesso', () => {
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("Sophia Gallindo")
cy.CreateSolicitation()
cy.visit('/')
cy.ClientLogout()
cy.CreateAdmin()
cy.CreateEmployee()
cy.CreateEmployee("Paulo", "paulo@paulo.com")
cy.get(':nth-child(1) > a').click()
cy.get(':nth-child(6) > a').click()
cy.get('#status').select('Aguardando orçamento')
cy.get('.content > form > button').click()
cy.get('.budgetContainer > input').type("200")
cy.get('.content > form > button').click()
cy.get('.logout > button').click()
cy.GoToClient()
cy.get(':nth-child(4) > a').click()
cy.get('.yes > label').click()
cy.get('.waitingForm > form > button').click()
cy.ClientLogout()
cy.ChangeToAdmin()
cy.get('ul > :nth-child(1) > a').click()
cy.CreateOrder()
cy.get(':nth-child(6) > a').click()
cy.get('#tecnician').select("Robson")
cy.get('.update').click()
cy.get('ul > :nth-child(1) > a').click()
cy.get(':nth-child(6) > a').click()
cy.get('#status').select("Aguardando peças")
cy.get('#tecnician').select("Paulo")
cy.get('#necessary_parts').clear()
cy.get('#necessary_parts').type("2x Pás")
cy.get('#detailed_problem_description').clear()
cy.get('#detailed_problem_description').type("Pás quebraram")
cy.get('.update').click()
cy.get('ul > :nth-child(1) > a').click()
cy.get(':nth-child(6) > a').click()

cy.get('.employee').invoke('text').should("have.string", "Paulo")
cy.get('#necessary_parts').invoke('text').should("have.string", "2x Pás")
cy.get('#detailed_problem_description').invoke('text').should("have.string", "Pás quebraram")
})
})
13 changes: 2 additions & 11 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,12 @@ Cypress.Commands.add('CreateClient', (name = "Gabriel Albuquerque", email = "tes

Cypress.Commands.add('CreateOrder', () => {
cy.get(':nth-child(6) > a').click()
cy.get('#detailed_problem_description').type('Tá quebrado')
cy.get('#necessary_parts').type("Por enquanto, nenhuma")
cy.get('#detailed_problem_description').type('Cabos corroídos')
cy.get('#necessary_parts').type("5 cabos")
cy.get('.works > button').click()
})

Cypress.Commands.add('CreateEmployee', (name = "Robson", email = "robson@robson.com") => {
// cy.get('#employee > a').click()
// cy.get('#email').type('eceel-Tec@eceeltec.com')
// cy.get('#password').type('obGWjpaTayKJWpBiFSMm')
// cy.get('button').click()
// cy.get('#password').type('obGWjpaTayKJWpBiFSMm')
// cy.get('#new_password').type('obGWjpaTayKJWpBiFSMm')
// cy.get('.form-card > form > button').click()
// cy.get('.employees > a').click()
cy.get('.new-employee-button').click()
cy.get('#username').type(name)
cy.get('#phone').type('81900028922')
Expand All @@ -55,7 +47,6 @@ Cypress.Commands.add('CreateSolicitation', () => {
cy.get('#submit_button').click()
})


Cypress.Commands.add('ClientLogout', () => {
cy.visit('/');
cy.get('#employee > a').click()
Expand Down

0 comments on commit 51512d2

Please sign in to comment.