-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add initial version of scoreboard app * mock score display * add cypress and tests * add docker script and update readme * remove loose type file * remove hard-coded players ; add back generated loose type file * yarn --> npm * add cy:podman npm script * add cross-env * add max length test * make changes for students to fix * Update scoreboard/cypress/fixtures/example.json Co-authored-by: Jaime Ramírez <[email protected]> Co-authored-by: Jaime Ramírez <[email protected]>
- Loading branch information
Showing
33 changed files
with
15,676 additions
and
0 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,4 @@ | ||
[*] | ||
tab_width = 4 | ||
indent_size = 4 | ||
insert_final_newline = true |
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,61 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"es6": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"prettier/@typescript-eslint", | ||
"plugin:prettier/recommended" | ||
], | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly", | ||
"process": "readonly" | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": 2018, | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["react", "@typescript-eslint"], | ||
"rules": { | ||
"max-len": ["error", 120], | ||
"indent": ["error", 4], | ||
"linebreak-style": ["error", "unix"], | ||
// Prettier determines quotes that are easiest to read | ||
"quotes": ["off", "double"], | ||
"semi": ["error", "always"], | ||
"eol-last": ["error", "always"] | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": { | ||
"@typescript-eslint/no-unused-vars": [ | ||
2, | ||
{ | ||
"args": "none" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"files": ["server.js", "src/Config.js"], | ||
"env": { | ||
"node": true | ||
} | ||
} | ||
] | ||
} |
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,24 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
|
||
# cypress | ||
*.mp4 |
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,4 @@ | ||
{ | ||
"trailingComma": "all", | ||
"tabWidth": 4 | ||
} |
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,89 @@ | ||
# Scoreboard | ||
|
||
A simple scoreboard app built using React. | ||
|
||
 | ||
|
||
## Pre-requisites | ||
|
||
To run the application, you will need: | ||
|
||
- Node.js version 12 or higher | ||
- NPM version 6 or higher | ||
|
||
Additionally, in order to run functional tests with Cypress, you will need either Chrome or Firefox installed. | ||
You may instead use Docker to run Cypress in "headless mode" (see below under `npm run cy:docker`). | ||
|
||
See more details about system requirements for Cypress here: | ||
[https://docs.cypress.io/guides/getting-started/installing-cypress.html#System-requirements](https://docs.cypress.io/guides/getting-started/installing-cypress.html#System-requirements) | ||
|
||
## Installation | ||
|
||
Install all NPM dependencies by running: | ||
|
||
`npm install` | ||
|
||
Install NPM dependencies excluding develepment-only dependencies by running: | ||
|
||
`npm install --prod` | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `npm start` | ||
|
||
Runs the app in the development mode.<br /> | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.<br /> | ||
You will also see any lint errors in the console. | ||
|
||
### `npm test` | ||
|
||
Launches the test runner in the interactive watch mode.<br /> | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.<br /> | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.<br /> | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `npm run format` | ||
|
||
Automatically formats all files using Prettier. | ||
Learn more about Prettier at [prettier.io](https://prettier.io) | ||
|
||
### `npm run cy:open` | ||
|
||
Opens the Cypress GUI. | ||
This allows you to select which browser Cypress should use, as well as select test files to run. | ||
|
||
Requires Chrome or Firefox installation. | ||
The development server must also be running (see `npm start`). | ||
|
||
### `npm run cy:run` | ||
|
||
Runs all Cypress tests in "headless mode" (doesn't open a browser window). | ||
|
||
Requires Chrome or Firefox installation. | ||
The development server must also be running (see `npm start`). | ||
|
||
### `npm run cy:docker` | ||
|
||
Runs all Cypress tests in "headless mode" withing a container using Docker. | ||
|
||
Requires Docker installation. | ||
The development server must also be running (see `npm start`). | ||
|
||
### `npm run cy:podman` | ||
|
||
Runs all Cypress tests in "headless mode" withing a container using podman. | ||
|
||
Requires podman installation. | ||
The development server must also be running (see `npm start`). |
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 @@ | ||
{ | ||
"baseUrl": "http://localhost:3000" | ||
} |
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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
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,55 @@ | ||
beforeEach(() => { | ||
// GIVEN the user is on the app | ||
cy.visit("/"); | ||
}); | ||
|
||
describe("add player", () => { | ||
it("should add a player", () => { | ||
// AND the user has entered 'bobby' into the 'Player Name' field | ||
cy.get("form").find('[placeholder="Player Name"]').type("bobby"); | ||
|
||
// WHEN they submit the form | ||
cy.get("form").submit(); | ||
|
||
// THEN 'bobby' should be added to the players | ||
cy.get("#player-scores").should("contain", "bobby"); | ||
}); | ||
}); | ||
|
||
describe("update score", () => { | ||
beforeEach(() => { | ||
// AND the player 'tom' exists | ||
cy.get("form").find('[placeholder="Player Name"]').type("tom"); | ||
cy.get("form").submit(); | ||
}); | ||
|
||
it("should increase a player's score", () => { | ||
// AND tom has a score of 0 | ||
cy.get("#player-scores").should("contain", "tom: 0"); | ||
|
||
// WHEN the user hits '+' next to 'tom' | ||
cy.get("#player-scores") | ||
.contains("tom") | ||
.siblings() | ||
.contains("+") | ||
.click(); | ||
|
||
// THEN 'tom's score should be 1 | ||
cy.get("#player-scores").should("contain", "tom: 1"); | ||
}); | ||
|
||
it.skip("should decrease a player's score", () => { | ||
// AND tom has a score of 0 | ||
cy.get("#player-scores").should("contain", "tom: 0"); | ||
|
||
// WHEN the user hits '-' next to 'tom' | ||
cy.get("#player-scores") | ||
.contains("tom") | ||
.siblings() | ||
.contains("-") | ||
.click(); | ||
|
||
// THEN 'tom's score should be -1 | ||
cy.get("#player-scores").should("contain", "tom: 0"); | ||
}); | ||
}); |
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,21 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
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 @@ | ||
// *********************************************** | ||
// This example commands.js 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) => { ... }) |
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,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js 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') |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["es5", "dom"], | ||
"types": ["cypress"] | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
Oops, something went wrong.