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

Php tests and error boundaries in react router #2140

Draft
wants to merge 37 commits into
base: legacy
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4f05577
WIP - cypress level test
jaltekruse May 15, 2023
dd0fe03
getting jest set up
jaltekruse Mar 31, 2023
e8aeacf
WIP - testing stuff
jaltekruse Mar 31, 2023
fcb31e7
WIP - trying to get a test running with react-router and recoil stuff…
jaltekruse May 15, 2023
8b06564
First working test with react-router
jaltekruse May 15, 2023
ae682c5
Factoring out a little bit of code
jaltekruse May 15, 2023
971d8fa
Make the utility function do a little more, delete the bad version of…
jaltekruse May 15, 2023
00e685f
Small cleanups, delete incomplete test for some recoil code
jaltekruse May 16, 2023
e5ca25a
Rename test, add vscode config for debugging jest tests, remove incom…
jaltekruse May 16, 2023
c1b2cdd
revert changes to courseActions
jaltekruse May 16, 2023
fbb26f0
Add an extension for jest to the devcontainer
jaltekruse May 16, 2023
40c0125
Update package-lock.json
jaltekruse May 16, 2023
0e81be6
change include to include_once to make testing easier
jaltekruse Apr 5, 2023
2f9a987
Add base model to abstract away common SQL boilerplate
jaltekruse Apr 27, 2023
b9db3bc
Move to using try/catch and the query
jaltekruse Apr 27, 2023
32fcdab
Create utility function for checking for required inputs
jaltekruse Apr 27, 2023
1911d86
Adding an ErrorPanel component that can display loader error automati…
jaltekruse Apr 28, 2023
8e09989
temp - throw an error
jaltekruse Apr 28, 2023
caad906
This is the wrong way to do things, makes the whole page break on one…
jaltekruse Apr 28, 2023
3dc259b
This does what I want, seems a bit weird to have a child route that s…
jaltekruse Apr 28, 2023
6f1bbae
Fixing admin page to use axios
jaltekruse Apr 28, 2023
e9f9f71
Don't give error on no promoted content groups (maybe revert?)
jaltekruse Apr 28, 2023
10a4660
Fix the community page
jaltekruse Apr 28, 2023
5b7d294
Fix bug, remove leftover code from previously using fetch()
jaltekruse Apr 28, 2023
11471cc
add php to dev container
Lyanthropos Apr 27, 2023
267525e
WIP - tests with phpunit
jaltekruse May 2, 2023
dcb831f
Start factoring out common queries into views
jaltekruse May 2, 2023
2185066
Can't put the nullish coalesce here because different fields need to …
jaltekruse May 2, 2023
69a3820
Move the coalescing into SQL, this way generic boolean handling when …
jaltekruse May 2, 2023
d7b81bb
Refactor to use try/catch
jaltekruse May 2, 2023
933f645
Use convenience method for all sql queries to ensure we are always ch…
jaltekruse May 2, 2023
9b3ddc6
Getting enough test infrastructure in place so we can call APIs
jaltekruse May 10, 2023
1ebe52d
Got an item added to a course in a test
jaltekruse May 10, 2023
14561f4
Fix namespacing when referring to things in global namespace
jaltekruse May 10, 2023
0d16230
Add some more assertions
jaltekruse May 10, 2023
bb2c295
Fix an issue in PHP now that we are adding a namespace to allow mocki…
jaltekruse May 16, 2023
7737059
Removing extra error added for demo purposes
jaltekruse May 17, 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
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"eamodio.gitlens",
"DotJoshJohnson.xml",
"wix.vscode-import-cost",
"bmewburn.vscode-intelephense-client"
"bmewburn.vscode-intelephense-client",
"Orta.vscode-jest"
],
"settings": {
"editor.formatOnSave": true,
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ build
dist_local
node_modules

# php dependencies
vendor

# production
# /dist
Expand All @@ -26,7 +28,6 @@ yarn-debug.log*
yarn-error.log*
package-lock.json

.vscode
# src/Tools/test/testCode.doenet
#ignore the distribution
# dist/index.html
Expand Down
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {presets: ['@babel/preset-env', '@babel/preset-react']}
26 changes: 22 additions & 4 deletions doenet_docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM node:19.8-bullseye
FROM composer as composer
WORKDIR /build
COPY ./doenet_docker/dev/composer.json .
RUN composer install --ignore-platform-reqs

FROM node:19.8-bullseye
RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >/etc/apt/sources.list.d/bullseye-backports.list

RUN apt-get update && \
apt-get -y install \
gnome-keyring \
Expand All @@ -12,8 +15,16 @@ RUN apt-get update && \
gnupg \
lsb-release \
#update git to support ssh signing
git/bullseye-backports

git/bullseye-backports \
# for php
php-common \
libapache2-mod-php \
php-cli \
php-xml \
php-mysqli \
php-mbstring

# prep Docker
WORKDIR /
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Expand All @@ -28,7 +39,14 @@ RUN rm -rf /var/lib/apt/lists/* &&\
apt-get -y autoremove && \
apt-get clean

# prep workspace
RUN mkdir -p /home/node/workspace/node_modules && chown -R node:node /home/node/workspace

# php composer deps
WORKDIR /usr/local/apache2/htdocs/api/
COPY --from=composer /build/vendor ./vendor

# local configs
WORKDIR /home/node/workspace
COPY --chown=node:node package*.json vite.config.js ./
USER node
Expand Down
6 changes: 6 additions & 0 deletions doenet_docker/dev/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"firebase/php-jwt": "5.2.*",
"phpunit/phpunit": "9.6.7"
}
}
49 changes: 49 additions & 0 deletions doenet_docker/volumes/db_init/views.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
create or replace view assignment_detail as
SELECT cc.type,
cc.doenetId,
cc.parentDoenetId,
cc.label,
cc.creationDate,
cc.isAssigned,
cc.isGloballyAssigned,
cc.isPublic,
cc.userCanViewSource,
cc.courseId,
CAST(cc.jsonDefinition as CHAR) AS json,
a.assignedDate,
a.dueDate,
a.pinnedAfterDate,
a.pinnedUntilDate,
a.timeLimit,
a.numberOfAttemptsAllowed,
a.attemptAggregation,
a.totalPointsOrPercent,
a.gradeCategory,
coalesce(a.individualize, 0) as individualize,
a.showSolution,
a.showSolutionInGradebook,
a.showFeedback,
a.showHints,
a.showCorrectness,
a.showCreditAchievedMenu,
a.paginate,
coalesce(a.showFinishButton, 0) as showFinishButton,
coalesce(a.proctorMakesAvailable, 0) as proctorMakesAvailable,
coalesce(a.autoSubmit, 0) as autoSubmit,
a.canViewAfterCompleted
FROM course_content AS cc
LEFT JOIN assignment AS a
ON a.doenetId = cc.doenetId
WHERE cc.isDeleted = '0'
ORDER BY cc.sortOrder;

create or replace view assigned_assignment_detail as
select ad.*,
coalesce(ua.completed, 0) as completed,
ua.completedDate
from assignment_detail ad
LEFT JOIN user_assignment AS ua
ON ad.doenetId = ua.doenetId
WHERE ad.isAssigned=1
AND (ad.type = 'activity' OR ad.type = 'section')
AND (ua.isUnassigned = 0 OR ad.isGloballyAssigned = 1);
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
// Your normal jest config settings
testPathIgnorePatterns: ["<rootDir>/cypress/", "<rootDir>/.cache/"],
testEnvironment: 'jsdom',
transform: {
"^.+\\.(js|jsx)$": "babel-jest",
},
modulePaths: [
"<rootDir>"
],
}
Loading