-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Django database support for e2e tests Update all tests to use server responses, remove fixtures Add scripts to manage the database between tests Modify settings.py to include a database cache Remove Cypress Django test user setup Add Cypress pylint configuration Add parallelization for cypress tests Reorganize Cypress specs Add better Cypress run titles Fix issue submitting email for user that doesn't exist Fix button type in add student modal, add span around emails
- Loading branch information
1 parent
da4c74e
commit 68bc8e7
Showing
27 changed files
with
4,908 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
name: Cypress E2E | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
jobs: | ||
cypress-run-chrome: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.9] | ||
containers: [1, 2] | ||
services: | ||
postgres: | ||
image: postgres:14 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: csm_web_dev | ||
ports: ["5432:5432"] | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Install npm dependencies | ||
run: | | ||
npm ci | ||
- name: Install Chrome 106 | ||
run: | | ||
sudo wget --no-verbose -O /usr/src/google-chrome-stable_current_amd64.deb "http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_106.0.5249.91-1_amd64.deb" && \ | ||
sudo dpkg -i /usr/src/google-chrome-stable_current_amd64.deb ; \ | ||
sudo apt-get install -f -y && \ | ||
sudo rm -f /usr/src/google-chrome-stable_current_amd64.deb | ||
- name: Run Cypress | ||
uses: cypress-io/github-action@v4 | ||
with: | ||
record: true | ||
build: npm run build | ||
start: python csm_web/manage.py runserver | ||
wait-on: http://localhost:8000 | ||
browser: chrome | ||
parallel: true | ||
group: Tests on Chrome 106 | ||
env: | ||
SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
DJANGO_ENV: dev | ||
POSTGRES_PASSWORD: postgres | ||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | ||
# pass GitHub token to allow accurately detecting a build vs a re-run build | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# better cypress run titles | ||
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}} | ||
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}} | ||
cypress-run-firefox: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.9] | ||
containers: [1, 2] | ||
services: | ||
postgres: | ||
image: postgres:14 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: csm_web_dev | ||
ports: ["5432:5432"] | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Install npm dependencies | ||
run: | | ||
npm ci | ||
- name: Install Firefox 106 | ||
run: | | ||
sudo wget --no-verbose -O /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/106.0.2/linux-x86_64/en-US/firefox-106.0.2.tar.bz2 && \ | ||
sudo tar -C /opt -xjf /tmp/firefox.tar.bz2 && \ | ||
sudo rm /tmp/firefox.tar.bz2 && \ | ||
sudo ln -fs /opt/firefox/firefox /usr/bin/firefox | ||
- name: Run Cypress | ||
uses: cypress-io/github-action@v4 | ||
with: | ||
record: true | ||
build: npm run build | ||
start: python csm_web/manage.py runserver | ||
wait-on: http://localhost:8000 | ||
browser: firefox | ||
parallel: true | ||
group: Tests on Firefox 106 | ||
env: | ||
SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
DJANGO_ENV: dev | ||
POSTGRES_PASSWORD: postgres | ||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | ||
# pass GitHub token to allow accurately detecting a build vs a re-run build | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# better cypress run titles | ||
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}} | ||
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from "react"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
|
||
export const testQueryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
retry: false | ||
} | ||
} | ||
}); | ||
|
||
/** | ||
* Wrap an element with a query client provider, so that react-query functions correctly. | ||
*/ | ||
export const testQueryClientWrapper = ({ children }: { children: React.ReactElement }) => ( | ||
<QueryClientProvider client={testQueryClient}>{children}</QueryClientProvider> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django.core.management import BaseCommand | ||
from scheduler.models import User | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Populates database with a single test user for testing." | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"--silent", action="store_true", help="no stdout during execution" | ||
) | ||
|
||
def handle(self, *args, **options): | ||
demo_user = User.objects.create( | ||
username="demo_user", | ||
email="[email protected]", | ||
first_name="Demo", | ||
last_name="User", | ||
) | ||
demo_user.is_staff = True | ||
demo_user.is_superuser = True | ||
demo_user.set_password("pass") | ||
demo_user.save() | ||
if "silent" not in options or not options["silent"]: | ||
print("Created demo user with username 'demo_user' and password 'pass'") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
projectId: "ar111y", | ||
baseUrl: "http://localhost:8000" | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["plugin:cypress/recommended"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[tool.pylint.main] | ||
load-plugins = ["pylint_django"] |
Oops, something went wrong.