Skip to content

Commit

Permalink
Initialize add-test-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
github-classroom[bot] authored Sep 30, 2023
0 parents commit 043c6be
Show file tree
Hide file tree
Showing 56 changed files with 12,236 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bookworm",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "cd client; npm install; cd ../service; npm install"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
21 changes: 21 additions & 0 deletions .github/workflows/backend-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Node Continuous Integration

on:
# pull_request:
# branches: [ main ]

jobs:
test_pull_request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v1
with:
node-version: 12

- run: npm ci

- run: npm test

- run: npm run build
40 changes: 40 additions & 0 deletions .github/workflows/frontend-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Node Continuous Integration

on:
pull_request:
branches: [ main ]
create:

jobs:
# Build job
build:
# <Not provided for brevity>
# At a minimum this job should upload artifacts using actions/upload-pages-artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Get repository name
id: repo-name
uses: MariachiBear/[email protected]
with:
with-owner: 'false'
string-case: 'lowercase'

- name: Install and build
env:
REPO_NAME: ${{ steps.repo-name.outputs.repository-name }}
run: |
cd client
npm install
npm run build
# Publish the site
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: client/dist
46 changes: 46 additions & 0 deletions .github/workflows/test-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Artifacts
on: push

jobs:
cypress-run:
runs-on: ubuntu-22.04
name: Artifacts
steps:
- uses: actions/checkout@v4

- name: Install client
run: |
cd client
npm install
- name: Install server
run: |
cd service
npm install
cp .env.sample .env
- uses: cypress-io/github-action@v6
with:
working-directory: client
wait-on: 'http://localhost:5173, http://localhost:5000/api/v1'
wait-on-timeout: 30
browser: chrome
start: |
npm run dev
npm run server
# after the test run completes store videos and any screenshots
- uses: actions/upload-artifact@v3
# add the line below to store screenshots only on failures
# if: failure()
with:
name: cypress-screenshots
path: client/cypress/screenshots
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`


- uses: actions/upload-artifact@v3
with:
name: cypress-videos
path: client/cypress/videos
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Hack The Tunnels - Starter

![Hack The Tunnels](https://i.imgur.com/hfdpJca.png)

This is the project template for [Hack The Tunnels](https://ccss.carleton.ca/hackthetunnels/).

The project template utilizes [React](https://react.dev/), [TypeScript](https://www.typescriptlang.org/), [Express](https://expressjs.com/), and [Prisma](https://www.prisma.io/).

## Project Setup

Before you can set up the project, you will need to install [Node.js](https://nodejs.org/en).

To get the project working, you will need to have both the client and server running.

### Client Setup

1. Move into the client directory

```
cd client
```

2. Install client dependencies

```
npm install
```

3. Run the client

```
npm run dev
```

### Service Setup

1. Move into the service directory

```
cd service
```

2. Install service dependencies

```
npm install
```

3. Copy `.env.sample`

Create a copy of the `.env.sample` file. and rename the file's name to `.env`.


4. Run the service

```
npm run dev
```

18 changes: 18 additions & 0 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
1 change: 1 addition & 0 deletions client/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
9 changes: 9 additions & 0 deletions client/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
32 changes: 32 additions & 0 deletions client/cypress/e2e/1-getting-started/todo.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference types="cypress" />

// Welcome to Cypress!
//
// This spec file contains a variety of sample tests
// for a todo list app that are designed to demonstrate
// the power of writing tests in Cypress.
//
// To learn more about how Cypress works and
// what makes it such an awesome testing tool,
// please read our getting started guide:
// https://on.cypress.io/introduction-to-cypress

describe('website', () => {
beforeEach(() => {
// Cypress starts out with a blank slate for each test
// so we must tell it to visit our website with the `cy.visit()` command.
// Since we want to visit the same URL at the start of all our tests,
// we include it in our beforeEach function so that it runs before each test
cy.visit('http://localhost:5173/')
})

it('displays hello world', () => {
// We use the `cy.get()` command to get all elements that match the selector.
// Then, we use `should` to assert that there are two matched items,
// which are the two default items.
cy.contains('Hello World')

// Take a screenshot
cy.screenshot()
})
})
5 changes: 5 additions & 0 deletions client/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"
}
37 changes: 37 additions & 0 deletions client/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
20 changes: 20 additions & 0 deletions client/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
13 changes: 13 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hack The Tunnels Project</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading

0 comments on commit 043c6be

Please sign in to comment.