Skip to content

Commit

Permalink
Merge branch 'develop' into gh-349-video-delete-api
Browse files Browse the repository at this point in the history
  • Loading branch information
connordoman committed Feb 22, 2024
2 parents 70e1bdf + cbf4983 commit a387180
Show file tree
Hide file tree
Showing 25 changed files with 5,804 additions and 98 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/db-itest-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Database Initializer Integration Tests

concurrency:
group: ${{ github.run_id }}
cancel-in-progress: true

on:
push:
branches:
- "develop"
- "master"
- "main"
pull_request:
types:
- opened
- reopened
- synchronize

env:
OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/Release.key"
OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04"


jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Install podman v4
run: |
echo "deb $OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list
curl -fsSL $OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg > /dev/null
sudo apt -y purge podman
sudo apt update && sudo apt -y install podman
- name: Start Podman API
run: |
systemctl --user enable --now podman.socket
echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV"
- name: Check out the repository
uses: actions/checkout@v4
with:
token: ${{ github.token }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: app/web/db/itests/package-lock.json
- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: app/web/db/itests
- name: Run tests
working-directory: app/web/db
run: make oci-build itest
4 changes: 2 additions & 2 deletions app/video-processing/lambda/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
boto3==1.34.43
botocore==1.34.43
boto3==1.34.47
botocore==1.34.47
numpy==1.26.4
opencv-python-headless==4.9.0.80
4 changes: 2 additions & 2 deletions app/web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js

Expand All @@ -25,7 +25,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
**/.env*
.env*

# vercel
.vercel
Expand Down
71 changes: 71 additions & 0 deletions app/web/__tests__/AppointmentViewer.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright [2023] [Privacypal Authors]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import AppointmentViewer from "@components/appointment/AppointmentViewer";
import { render, screen } from "@testing-library/react";
import { ViewableAppointment } from "@lib/appointment";
import { UserRole } from "@lib/userRole";

describe("AppointmentViewer Component", () => {
const pro = {
id: 1,
username: "professional_test_user",
email: "pro@example.com",
firstName: "Pro",
lastName: "User",
role: UserRole.PROFESSIONAL,
};
const client = {
id: 2,
username: "client_test_user",
email: "client@example.com",
firstName: "Client",
lastName: "User",
role: UserRole.CLIENT,
};
const appt: ViewableAppointment = {
id: 1,
professionalUser: pro,
clientUser: client,
time: new Date(Date.UTC(2025, 0, 1, 12, 0, 0)), // jan 1st 2025 12:00 noon
video_count: 1,
};

it("component is unchanged from snapshot", () => {
const { container: container } = render(
<div>
<AppointmentViewer appointment={appt} viewer={pro} />,
<AppointmentViewer appointment={appt} viewer={client} />
</div>,
);
expect(container).toMatchSnapshot();
});
it("pro viewer has cancel and view details buttons", () => {
const { container: proContainer } = render(
<AppointmentViewer appointment={appt} viewer={pro} />,
);
expect(screen.getByText("Cancel appointment")).toBeDefined();
expect(screen.getByText("View appointment details")).toBeDefined();
});
it("client viewer has upload video button", () => {
const { container: clientContainer } = render(
<AppointmentViewer appointment={appt} viewer={client} />,
);
expect(
screen.getByText("Upload a video to this appointment"),
).toBeDefined();
});
});
99 changes: 99 additions & 0 deletions app/web/__tests__/__snapshots__/AppointmentViewer.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AppointmentViewer Component component is unchanged from snapshot 1`] = `
<div>
<div>
<div
class="pf-v5-c-card"
data-ouia-component-id="OUIA-Generated-Card-1"
data-ouia-component-type="PF5/Card"
data-ouia-safe="true"
id=""
>
<div
class="pf-v5-c-card__body"
>
<h2>
Appointment
</h2>
<time>
1/1/2025
</time>
<p>
Professional:
Pro User
</p>
<p>
Client:
Client User
</p>
<p>
Number of associated videos:
1
</p>
<button
aria-disabled="false"
class="pf-v5-c-button pf-m-danger"
data-ouia-component-id="OUIA-Generated-Button-danger-1"
data-ouia-component-type="PF5/Button"
data-ouia-safe="true"
type="button"
>
Cancel appointment
</button>
<a
aria-disabled="false"
class="pf-v5-c-button pf-m-primary"
data-ouia-component-id="OUIA-Generated-Button-primary-1"
data-ouia-component-type="PF5/Button"
data-ouia-safe="true"
href="/staff/appointment?id=1"
>
View appointment details
</a>
</div>
</div>
,
<div
class="pf-v5-c-card"
data-ouia-component-id="OUIA-Generated-Card-2"
data-ouia-component-type="PF5/Card"
data-ouia-safe="true"
id=""
>
<div
class="pf-v5-c-card__body"
>
<h2>
Appointment
</h2>
<time>
1/1/2025
</time>
<p>
Professional:
Pro User
</p>
<p>
Client:
Client User
</p>
<p>
Number of associated videos:
1
</p>
<a
aria-disabled="false"
class="pf-v5-c-button pf-m-primary"
data-ouia-component-id="OUIA-Generated-Button-primary-2"
data-ouia-component-type="PF5/Button"
data-ouia-safe="true"
href="/upload"
>
Upload a video to this appointment
</a>
</div>
</div>
</div>
</div>
`;
10 changes: 7 additions & 3 deletions app/web/db/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ add-license: ## Add license header to source files
--security-opt label=disable \
-v "$${PWD}":"/src" \
-it --replace \
ghcr.io/google/addlicense -v -f ./license.header.txt include tests
ghcr.io/google/addlicense -v -f ./license.header.txt include tests itests

.PHONY: check-license
check-license: ## Check if license header is available in source files
Expand All @@ -52,12 +52,16 @@ check-license: ## Check if license header is available in source files
--security-opt label=disable \
-v "$${PWD}":"/src" \
-it --replace \
ghcr.io/google/addlicense -v -f ./license.header.txt -check include tests
ghcr.io/google/addlicense -v -f ./license.header.txt -check include tests itests

.PHONY: test
test: ## Run unit test
test: ## Run unit tests
bash tests/entrypoint_test.sh

.PHONY: itest
itest: ## Run integration tests
cd itests && npm run test

##@ Build

.PHONY: oci-build
Expand Down
30 changes: 30 additions & 0 deletions app/web/db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,33 @@ To launch the initialization container against an existing Postgres instance, ru
```bash
make run
```

## TEST

### Unit tests

To run unit tests for the entrypoint script, use:

```bash
bash tests/entrypoint_test.sh
```

### Integration tests

To run integration tests with Podman, launch Podman API as follows:

```bash
systemctl --user enable --now podman.socket
export DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock
```

**Note:** Above steps are not required for `docker` usage.

The database initializer container image, default to `ghcr.io/cosc-499-w2023/privacypal-init-db:<tag>` must be available in local registry or pullable from remote registry.


To run integration tests to validate schema generation with an actual postgres instance, use:

```
make itest
```
Loading

0 comments on commit a387180

Please sign in to comment.