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

Add_UI_Test/Cypress/Basic_tests #190

Open
wants to merge 42 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2d1f05d
cypress-base
Jan 16, 2021
fd0a9bb
cypress-build
Jan 16, 2021
8a14390
cypress-build
Jan 16, 2021
8583d31
cypress-build
Jan 16, 2021
2f61089
readme
Jan 17, 2021
219ad38
Merge branch 'main' of https://github.com/PythonFreeCourse/calendar i…
Jan 18, 2021
89aaeec
pull from dev
Jan 19, 2021
0b9bed3
merge changes
Jan 20, 2021
d1e4cfe
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Jan 20, 2021
77d135e
profile page tests
Jan 20, 2021
25aa774
Merge pull request #1 from PythonFreeCourse/develop
Lisafiluz Jan 20, 2021
b9a5bfb
delete-user
Jan 20, 2021
30b8975
delete_all_events_of_the_user
Jan 22, 2021
7f9e405
Merge pull request #2 from Lisafiluz/delete-user
Lisafiluz Jan 22, 2021
d1217d6
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Jan 22, 2021
34b2bf4
delete-user\add-confirmation
Jan 22, 2021
fb5aa93
Merge pull request #3 from Lisafiluz/delete-user
Lisafiluz Jan 22, 2021
ba9838d
delete-user/fix_comments
Jan 22, 2021
cdeddaf
Merge pull request #4 from Lisafiluz/delete-user
Lisafiluz Jan 22, 2021
695f0d6
Merge pull request #5 from PythonFreeCourse/develop
Lisafiluz Jan 23, 2021
8b8a5ac
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 1, 2021
9d5c5c8
update readme
Feb 1, 2021
bdac43f
Merge branch 'develop' of https://github.com/Lisafiluz/calendar into …
Feb 1, 2021
fd405a0
Merge pull request #8 from Lisafiluz/add-cypress
Lisafiluz Feb 1, 2021
281ab2c
add git idnore
Feb 2, 2021
1e833d7
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 2, 2021
bb2e36e
Delete tests/tests-ui/node_modules directory
Lisafiluz Feb 2, 2021
ae1486d
Merge branch 'develop' of https://github.com/Lisafiluz/calendar into …
Feb 2, 2021
8fc8c42
add_cypress_basic_templates
Feb 2, 2021
fdfd5bc
Merge pull request #10 from Lisafiluz/add-cypress
Lisafiluz Feb 2, 2021
4c0d3b8
Update database.py
Lisafiluz Feb 2, 2021
41c62a7
Update profile.py
Lisafiluz Feb 2, 2021
e07816c
Update test_profile.py
Lisafiluz Feb 2, 2021
602a5f3
Merge branch 'develop' into develop
Lisafiluz Feb 3, 2021
4d751bc
Merge branch 'develop' into develop
Lisafiluz Feb 4, 2021
f3aeb5d
Update cy_HomePage_Resolution.js
Lisafiluz Feb 4, 2021
1b5b1fe
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 23, 2021
c7568d6
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 23, 2021
fb10553
conflicts_fix
Feb 23, 2021
cc9b06e
Merge branch 'develop' of https://github.com/Lisafiluz/calendar into …
Feb 23, 2021
e3a9bc4
Merge branch 'develop' into add-cypress
Lisafiluz Feb 23, 2021
b8cd8d3
Merge pull request #12 from Lisafiluz/add-cypress
Lisafiluz Feb 23, 2021
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ app/.vscode/

app/routers/stam

# Cypress
tests/tests-ui/node_modules/

# PyCharm
.idea

Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@ source venv/bin/activate
pip install -r requirements.txt
cp app/config.py.example app/config.py
# Edit the variables' values.
uvicorn app.main:app --reload
```

### Cypress:
Front end testing tool.

Every test created with testLevel configuration, the defualt level we run our test is 5.
Basic tests will spicified with lower testLevel than advanced tests.

#To run Cypress:
Lisafiluz marked this conversation as resolved.
Show resolved Hide resolved

1. Make sure you already installed npm (run npm --version to check).
2. Run the server
3. Nevigate to 'test-ui' folder: calendar/tests/test-ui
- Run with Test Runner:
1. Run on terminal: ```npx cypress open```
2. Test Runner will open: choose test and click it to execute
- Run all test without watching:
1. Run on terminal: ```npx cypress run```
- Run a specific test file without watching:
1. Run on terminal: ```npx cypress run --spec cypress/integration/path/to/file```
- Run tests with change level env config to 10: ```npx cypress run --env level=10```
### Running tests
# Rendering JWT_KEY:
python -c "import secrets; from pathlib import Path; f = Path('app/config.py'); f.write_text(f.read_text().replace('JWT_KEY_PLACEHOLDER', secrets.token_hex(32), 1));"

Expand Down
34 changes: 34 additions & 0 deletions app/database/database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker


from app import config


SQLALCHEMY_DATABASE_URL = os.getenv(
"DATABASE_CONNECTION_STRING", config.DEVELOPMENT_DATABASE_STRING)


def create_env_engine(psql_environment, sqlalchemy_database_url):
if not psql_environment:
return create_engine(
sqlalchemy_database_url, connect_args={"check_same_thread": False})

return create_engine(sqlalchemy_database_url)


engine = create_env_engine(config.PSQL_ENVIRONMENT, SQLALCHEMY_DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base()


def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
7 changes: 7 additions & 0 deletions app/routers/profile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import io

from loguru import logger
Expand Down Expand Up @@ -40,7 +41,13 @@ def get_placeholder_user():
async def profile(
request: Request,
session=Depends(get_db),
<<<<<<< HEAD
new_user=Depends(get_placeholder_user),
new_event=Depends(get_placeholder_event)):

=======
new_user=Depends(get_placeholder_user)):
>>>>>>> b91708d299bde83bbd10ff93496b23af9d35dd8f
Comment on lines +44 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflict.

# Get relevant data from database
upcoming_events = range(5)
user = session.query(User).filter_by(id=1).first()
Expand Down
31 changes: 30 additions & 1 deletion schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,41 @@
├── requirements.txt
├── schema.md
└── tests
└── tests_ui
├──cypress
├──enums
├──fixtures
├──integration
├──plugins
├──screenshots
├──support
└──videos
├──node_modules
├──cypress.json
├──package-lock.json
└──package.json
├── __init__.py
└── conftest.py
└── test_profile.py
└── test_app.py
└── tests_ui
├──cypress
├──enums
├──fixtures
├──integration
├──plugins
├──screenshots
├──support
└──videos
├──node_modules
├──cypress.json
├──package-lock.json
└──package.json
├── conftest.py
├── test_agenda_internal.py
├── test_agenda_route.py
├── test_app.py
├── test_categories.py
├── test_email.py
├── test_event.py
└── test_profile.py
└── test_profile.py
1 change: 1 addition & 0 deletions tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from app import config
from app.dependencies import MEDIA_PATH
from app.routers.profile import get_image_crop_area, get_placeholder_user
from starlette.status import HTTP_302_FOUND

CROP_RESULTS = [
(20, 10, (5, 0, 15, 10)),
Expand Down
15 changes: 15 additions & 0 deletions tests/tests-ui/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"baseUrl": "http://localhost:8000",
"viewportWidth": 1920,
"viewportHeight": 1080,
"pageLoadTimeout": 30000,
"requestTimeout": 10000,
"responseTimeout": 35000,
"defaultCommandTimeout": 20000,
"retries": 1,
"env": {
"user": "_user_qa",
"password": "TheBestPassword123",
"level": 1
}
}
5 changes: 5 additions & 0 deletions tests/tests-ui/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
5 changes: 5 additions & 0 deletions tests/tests-ui/cypress/fixtures/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": 8739,
"name": "Jane",
"email": "[email protected]"
}
Loading