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

Creates Test Plan for Running Integration Tests on Server API Endpoints #1493

Merged
merged 31 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6c8bd33
adds tests for account endpoints
agosmou Sep 19, 2023
9a38856
Merge branch 'develop' of https://github.com/hackforla/tdm-calculator…
agosmou Oct 15, 2023
a2c8ee7
pushing WIP branch - not working yet
agosmou Oct 17, 2023
66f1dc6
fixes testcontainers environment and is now functional
agosmou Oct 17, 2023
5b8efa6
creates setup configuration for test database in container
agosmou Oct 18, 2023
34538d8
adds mock for sendgrid and organizes .env
agosmou Oct 18, 2023
a9ef7b4
Merge branch 'develop' of https://github.com/hackforla/tdm-calculator…
agosmou Oct 19, 2023
9f5e596
adds api endpoint blackbox tests - logout test is not passing yet
agosmou Oct 19, 2023
e0ff2a8
fixes logout test and adds comment
agosmou Oct 19, 2023
1a3fd93
adds functionality to start and close server for each test suite
agosmou Oct 19, 2023
d0dc0b7
working test suite
agosmou Oct 19, 2023
4435b4f
adds notes to readME and comments in jest setup
agosmou Oct 21, 2023
7922153
organizes jest config in codebase
agosmou Oct 21, 2023
2cbd941
removes bloat comments in code
agosmou Oct 21, 2023
57d551f
renames jest setup directory and files
agosmou Oct 21, 2023
60b6425
refactors jest test environment setup
agosmou Oct 22, 2023
07abca5
refactors to restore original code with standard env variables
agosmou Oct 22, 2023
f74e5bf
edits the example env file
agosmou Oct 22, 2023
0b02b6b
refactors to provide server setup and teardown to use on api endpoint…
agosmou Oct 22, 2023
347f539
refactors host port on container setup to use environment variable
agosmou Oct 22, 2023
fb3fcc2
adds github action to include tests on CI pipeline
agosmou Oct 26, 2023
f751ff3
adjust test file naming conventions and minor edits to setup files
agosmou Oct 26, 2023
d4b9bef
organizes files into folders for maintainability
agosmou Oct 26, 2023
2a82ee5
refactors for maintainability and readability
agosmou Oct 26, 2023
e14cf90
refactors tests
agosmou Oct 26, 2023
3407be0
minor refactors and linting
agosmou Oct 26, 2023
9febb94
linting
agosmou Oct 26, 2023
d45e2e4
resolving merge conflict
agosmou Oct 26, 2023
d315c4e
Merge branch 'develop' of https://github.com/hackforla/tdm-calculator…
agosmou Oct 26, 2023
0b39c02
resolves merge conflict
agosmou Oct 26, 2023
0425165
fixes lerna issues on branch
agosmou Oct 26, 2023
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
52 changes: 52 additions & 0 deletions .github/workflows/tdm-server-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: tdm-server-test
run-name: ${{ github.actor }} is running tests for the server
on:
pull_request:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'

- name: Change directory
run: cd server

- name: Install dependencies
run: npm install
working-directory: server

- name: Set up environment variables
run: |
echo "TEST_ENV=true" >> .env
echo "PORT=5002" >> .env
echo "NODE_OPTIONS=--trace-deprecation" >> .env
echo "JWT_SECRET_KEY=testingSecretKey" >> .env
echo "CLIENT_URL=http://localhost:3001" >> .env
echo "SERVER_URL=http://localhost:5002" >> .env
echo "SENDGRID_API_KEY=SG.testAPIkey" >> .env
echo "[email protected]" >> .env
echo "EMAIL_PUBLIC_COMMENT_LA_CITY=tdm+devpubliccommentplanning@test.org" >> .env
echo "[email protected]" >> .env
echo "APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://westus-0.in.applicationinsights.azure.com/;LiveEndpoint=https://westus.livediagnostics.monitor.azure.com/" >> .env
echo "[email protected]" >> .env
echo "SECURITY_ADMIN_PASSWORD=Dogfood1!" >> .env
echo "SQL_SERVER_NAME=localhost" >> .env
echo "SQL_SERVER_PORT=1434" >> .env
echo "SQL_DATABASE_NAME=tdmtestdb" >> .env
echo "SQL_USER_NAME=sa" >> .env
echo "SQL_PASSWORD=TestPassw0rd" >> .env
echo "SQL_ENCRYPT=false" >> .env
working-directory: server

- name: Run tests
run: npm test
working-directory: server
1 change: 0 additions & 1 deletion APItests.json
Copy link
Member Author

Choose a reason for hiding this comment

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

OBSOLETE - This was a script to test using Hoppscotch

This file was deleted.

48 changes: 0 additions & 48 deletions server/.env-example
Copy link
Member Author

Choose a reason for hiding this comment

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

renamed file

This file was deleted.

3 changes: 2 additions & 1 deletion server/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"env": {
"es6": true,
"node": true
"node": true,
"jest": true
},
"extends": ["eslint:recommended", "prettier", "plugin:prettier/recommended"],
"plugins": ["prettier"],
Expand Down
97 changes: 97 additions & 0 deletions server/.example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Instructions: Create a .env file in the server directory. Copy and paste values from Google Docs.

# Node server settings
PORT=
NODE_OPTIONS=

JWT_SECRET_KEY=

# To support email interaction
SENDGRID_API_KEY=
EMAIL_PUBLIC_COMMENT_LA_CITY=
EMAIL_PUBLIC_COMMENT_WEB_TEAM=

# These env settings are specific to running the web api server and app on localhost.
CLIENT_URL=
SERVER_URL=

# User Test Accounts for Shared AWS Development Environment
#(Used by ThunderClient for API Endpoint testing)
USERTEST_EMAIL=
USERTEST_PASSWORD=
ROLESTEST_EMAIL=
ROLESTEST_PASSWORD=
ADMINTEST_EMAIL=
ADMINTEST_PASSWORD=

# Shared Development Database - Azure
SQL_SERVER_NAME=
SQL_SERVER_PORT=
SQL_DATABASE_NAME=
SQL_USER_NAME=
SQL_PASSWORD=
SQL_ENCRYPT=
SQL_TRUST_SERVER_CERTIFICATE=
EMAIL_SENDER=
APPLICATIONINSIGHTS_CONNECTION_STRING=

#########################################
## Local Development Database Settings ##
#########################################

## Local Development Database - Windows Native
# SQL_SERVER_NAME=
# SQL_SERVER_INSTANCE=
# SQL_SERVER_PORT=
# SQL_DATABASE_NAME=
# SQL_USER_NAME=
# SQL_PASSWORD=
# SQL_ENCRYPT=
# SQL_TRUST_SERVER_CERTIFICATE=
# EMAIL_SENDER=
# APPLICATIONINSIGHTS_CONNECTION_STRING=

## Local Development Database - Docker Container
## Example for SQL Server Express on Docker
# SQL_SERVER_NAME=
# SQL_SERVER_INSTANCE=
# SQL_SERVER_PORT=
# SQL_DATABASE_NAME=
# SQL_USER_NAME=
# SQL_PASSWORD=
# SQL_ENCRYPT=
# SQL_TRUST_SERVER_CERTIFICATE=
# EMAIL_SENDER=
# APPLICATIONINSIGHTS_CONNECTION_STRING=

###############################################################
## Testing (Comment out ALL the above variables) ##
Copy link
Member Author

Choose a reason for hiding this comment

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

renamed file with better naming convention and updated the .env file layout so that users can test locally by simply commenting out the development variables and un-commenting the testing variables.

I will have to add an updated .env file to the google drive upon accepted changes

###############################################################
# TEST_ENV=

# PORT=
# NODE_OPTIONS=

# JWT_SECRET_KEY=

# CLIENT_URL=
# SERVER_URL=

# SENDGRID_API_KEY=
# EMAIL_SENDER=
# EMAIL_PUBLIC_COMMENT_LA_CITY=
# EMAIL_PUBLIC_COMMENT_WEB_TEAM=

# APPLICATIONINSIGHTS_CONNECTION_STRING=

## Server Test Accounts
# SECURITY_ADMIN_EMAIL=
# SECURITY_ADMIN_PASSWORD=

## testingcontainer Environment Variables
# SQL_SERVER_NAME=
# SQL_SERVER_PORT=
# SQL_DATABASE_NAME=
# SQL_USER_NAME=
# SQL_PASSWORD=
# SQL_ENCRYPT =
Loading