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

REF:TEST: Refactored test to comply with test design #107

Closed
wants to merge 14 commits into from
4 changes: 3 additions & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ on:
pull_request:
branches: [ "main", "develop"]



jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: [3.12.2, 3.11.9, 3.10.14]

steps:
- uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'base.html' %}
{% load static %}
{% block title %}
Panel de control
Lista de usuarios
{% endblock %}


Expand Down Expand Up @@ -60,7 +60,7 @@

<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Panel de control</h1>
<h1 class="h3 mb-0 text-gray-800">Lista de usuarios</h1>
</div>

<!-- Content center -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="container-fluid p-0">

<!-- Page Heading -->
<h1 class="h3 mb-2 text-gray-800">Solicitudes de contratación</h1>
<h1 class="h3 mb-2 text-gray-800">Lista de usuarios</h1>
<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex justify-content-between align-items-center">
<h6 class="m-0 font-weight-bold text-primary">Listado de solicitudes de contratación</h6>
<h6 class="m-0 font-weight-bold text-primary">Listado de usuarios del equipo</h6>
<a id="addUser" href="add_user/" class="btn btn-primary btn-icon-split">
<span class="text">Agregar usuario</span>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<li class="nav-item active">

<a class="nav-link" href="{% url 'hiring_app:administrator_dashboard' %}">
<a id="ControlPanel" class="nav-link" href="{% url 'hiring_app:administrator_dashboard' %}">
<i class="fas fa-fw fa-tachometer-alt"></i>
<span>Panel de control</span>
</a>
Expand All @@ -29,7 +29,7 @@
{% endif %}

{% if actualgroup != "external" %}
<a class="nav-link" href="{% url 'hiring_app:statistics' %}">
<a id="Statistics" class="nav-link" href="{% url 'hiring_app:statistics' %}">
<i class="fas fa-fw fa-file-contract"></i>
<span>Estadisticas</span>
</a>
Expand Down
2 changes: 1 addition & 1 deletion hiring_module/hiring_app/tests/functionality/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .auth import *

from .control_board import *
from .left_panel import *

from .request_creation import *

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .admin_user import *
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def tearDownClass(cls):
super().tearDownClass()


def test_add_user(self):
def test_external_to_manager(self):
self.selenium.get(self.live_server_url)

username_input = self.selenium.find_element(By.NAME,'id')
Expand All @@ -38,7 +38,7 @@ def test_add_user(self):
self.selenium.find_element(By.ID, 'UserList').click()

time.sleep(2)
self.assertEqual('Panel de control', self.selenium.title)
self.assertEqual('Lista de usuarios', self.selenium.title)


self.selenium.find_element(By.ID, 'addUser').click()
Expand All @@ -52,10 +52,69 @@ def test_add_user(self):
time.sleep(2)


user = self.selenium.find_element(By.ID, '1106293874').text
user = self.selenium.find_element(By.ID, '1106293874_id').text

self.assertIn('1106293874', user)

def test_manager_to_leader(self):
self.selenium.get(self.live_server_url)

username_input = self.selenium.find_element(By.NAME, 'id')
password_input = self.selenium.find_element(By.NAME, 'password')
username_input.send_keys('1116070867')
password_input.send_keys('juandiaz123')

password_input.send_keys(Keys.RETURN)
self.assertIn('Panel de control de Administrador', self.selenium.title)

self.selenium.find_element(By.ID, 'UserList').click()

time.sleep(2)
self.assertEqual('Lista de usuarios', self.selenium.title)

self.selenium.find_element(By.ID, 'roleSelect_1111539567').send_keys('leader')

time.sleep(2)

self.assertEqual('1111539567', self.selenium.find_element(By.ID, '1111539567_id').text)

select_element = self.selenium.find_element(By.ID, "roleSelect_1111539567")

selected_option = select_element.find_element(By.CSS_SELECTOR, "option:checked")

selected_value = selected_option.get_attribute("value")

self.assertEqual('leader', selected_value)

def test_leader_to_admin(self):
self.selenium.get(self.live_server_url)

username_input = self.selenium.find_element(By.NAME, 'id')
password_input = self.selenium.find_element(By.NAME, 'password')
username_input.send_keys('1116070867')
password_input.send_keys('juandiaz123')

password_input.send_keys(Keys.RETURN)
self.assertIn('Panel de control de Administrador', self.selenium.title)

self.selenium.find_element(By.ID, 'UserList').click()

time.sleep(2)
self.assertEqual('Lista de usuarios', self.selenium.title)

self.selenium.find_element(By.ID, 'roleSelect_1109185879').send_keys('administrator')

time.sleep(2)

self.assertEqual('1109185879', self.selenium.find_element(By.ID, '1109185879_id').text)

select_element = self.selenium.find_element(By.ID, "roleSelect_1109185879")

selected_option = select_element.find_element(By.CSS_SELECTOR, "option:checked")

selected_value = selected_option.get_attribute("value")

self.assertEqual('admin', selected_value)


def test_delete_user(self):
Expand All @@ -75,7 +134,7 @@ def test_delete_user(self):
self.selenium.find_element(By.ID, 'UserList').click()

time.sleep(2)
self.assertEqual('Panel de control', self.selenium.title)
self.assertEqual('Lista de usuarios', self.selenium.title)

self.selenium.find_element(By.ID, 'roleSelect_1109185879').send_keys('remove')

Expand Down
24 changes: 24 additions & 0 deletions hiring_module/hiring_app/tests/functionality/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,27 @@ def test_login_external_user(self):
password_input.send_keys(Keys.RETURN)

self.assertIn('Panel de control de usuario externo', self.selenium.title)

def test_login_wrong_password(self):
self.selenium.get(self.live_server_url)

username_input = self.selenium.find_element(By.NAME,'id')
password_input = self.selenium.find_element(By.NAME, 'password')
username_input.send_keys('1116070867')
password_input.send_keys('juandiaz')

password_input.send_keys(Keys.RETURN)

self.assertIn('Log In', self.selenium.title)

def test_login_wrong_username(self):
self.selenium.get(self.live_server_url)

username_input = self.selenium.find_element(By.NAME,'id')
password_input = self.selenium.find_element(By.NAME, 'password')
username_input.send_keys('111607086')
password_input.send_keys('juandiaz123')

password_input.send_keys(Keys.RETURN)

self.assertIn('Log In', self.selenium.title)

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .left_panel_navitagion import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
from django.contrib.auth.models import User
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException

class LeftPanelNavigation(StaticLiveServerTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.selenium = WebDriver()
cls.selenium.implicitly_wait(10)

@classmethod
def tearDownClass(cls):
cls.selenium.quit()
super().tearDownClass()


def test_admin_redirections(self):
self.selenium.get(self.live_server_url)

username_input = self.selenium.find_element(By.NAME,'id')
password_input = self.selenium.find_element(By.NAME, 'password')
username_input.send_keys('1116070867')
password_input.send_keys('juandiaz123')


password_input.send_keys(Keys.RETURN)

user_list_button = self.selenium.find_element(By.ID, 'UserList')

user_list_button.click()


self.assertIn('Lista de usuarios', self.selenium.title)

control_pannel_button = self.selenium.find_element(By.ID, 'ControlPanel')

control_pannel_button.click()

self.assertIn('Panel de control', self.selenium.title)

statistics_button = self.selenium.find_element(By.ID, 'Statistics')

statistics_button.click()

self.assertIn('Estadísticas', self.selenium.title)

def test_leader_redirections(self):
self.selenium.get(self.live_server_url)

username_input = self.selenium.find_element(By.NAME,'id')
password_input = self.selenium.find_element(By.NAME, 'password')
username_input.send_keys('1107838593')
password_input.send_keys('alejandrolondono123')


password_input.send_keys(Keys.RETURN)

with self.assertRaises(NoSuchElementException):
user_list_button = self.selenium.find_element(By.ID, 'UserList')


statistics_button = self.selenium.find_element(By.ID, 'Statistics')

statistics_button.click()

self.assertIn('Estadísticas', self.selenium.title)

control_pannel_button = self.selenium.find_element(By.ID, 'ControlPanel')

control_pannel_button.click()

self.assertIn('Panel de control', self.selenium.title)

def test_external_user_redirections(self):
self.selenium.get(self.live_server_url)

username_input = self.selenium.find_element(By.NAME,'id')
password_input = self.selenium.find_element(By.NAME, 'password')
username_input.send_keys('1106293874')
password_input.send_keys('mariagonzales123')

password_input.send_keys(Keys.RETURN)

with self.assertRaises(NoSuchElementException):
user_list_button = self.selenium.find_element(By.ID, 'UserList')

with self.assertRaises(NoSuchElementException):
statistics_button = self.selenium.find_element(By.ID, 'Statistics')

control_pannel_button = self.selenium.find_element(By.ID, 'ControlPanel')

control_pannel_button.click()

self.assertIn('Panel de control', self.selenium.title)
Loading