Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
deadcube04 committed Jun 11, 2024
2 parents 3e1d29e + f2db648 commit 957ca9e
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 5 deletions.
55 changes: 55 additions & 0 deletions cypress/e2e/ReopeningService.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,63 @@ describe('Reopening Service Tests', () => {
cy.get('#reopen > p').click()
cy.get('.actions > [type="submit"]').click()
cy.get('.EM_ANALISE').invoke('text').should('have.string', 'EM ANÁLISE')
})

it('Trying to reopen over 30 days', () => {

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()
cy.CreateSolicitation()
cy.visit('/')
cy.ClientLogout()
cy.CreateAdmin()

cy.get('ul > :nth-child(1)').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('.content > form > button').click()

cy.get('.budgetContainer > input').type('90')
cy.get('.content > form > button').click()
cy.Logout()

cy.GoToClient()
cy.get('.view > button').click()
cy.get('.waitingForm > form > button').click()
cy.Logout()

cy.ChangeToAdmin()
cy.get('ul > :nth-child(1)').click()
cy.get(':nth-child(6) > a').click()
cy.get('.works > button').click()

cy.get('#detailed_problem_description').type('Muito pelo de gato dentro do motor está interferindo na ventilação interna')
cy.get('#necessary_parts').type('Nenhuma, apenas limpeza')
cy.get('.works > button').click()

cy.get(':nth-child(6) > a').click()
cy.get('#status').select('Conserto finalizado')
cy.get('.update').click()

cy.DefineClosedAtDate()

cy.Logout()

cy.GoToClient()
cy.get('.view > button').click()
cy.get('#reopen > p').click()
cy.get('.actions > [type="submit"]').click()
cy.get('.toast').invoke('text').should('have.string', 'Essa solicitação não pode ser reaberta')
})

it('Reopening again', () => {
Expand Down
4 changes: 4 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Cypress.Commands.add('DeleteAndCreateAdm', () => {
cy.exec('python test_initiate.py', { failOnNonZeroExit: false })
});

Cypress.Commands.add('DefineClosedAtDate', () => {
cy.exec('python test_reopen.py', { failOnNonZeroExit: false })
});

Cypress.Commands.add('CreateClient', (name = "Gustavo Mourato", email = "teste@teste.com") => {
cy.get('#client > a').click()
cy.get('.footer > a').click()
Expand Down
6 changes: 1 addition & 5 deletions test_initiate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ def create_admin(username, first_name, email, password):
user = Users.objects.create_user(username=username, first_name=first_name, email=email, password=password, role='A')
user.save()



username = "eceel-Tec@eceeltec.com"
first_name = "Cláudio"
email = "eceel-Tec@eceeltec.com"
password = "obGWjpaTayKJWpBiFSMm"


create_admin(username, first_name, email, password)

create_admin(username, first_name, email, password)
17 changes: 17 additions & 0 deletions test_reopen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import django
from datetime import datetime, timedelta

# Configurar o Django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'eceeltec.settings')
django.setup()

from app_client.models import OrderRequest

order_request = OrderRequest.objects.filter().first()

today = datetime.now().date()

order_request.closedAt = today - timedelta(days=31)

order_request.save()

0 comments on commit 957ca9e

Please sign in to comment.