Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
af13f16
Scaffold create-react-app
Feb 15, 2020
5567038
Merge pull request #1 from sjalgeo/chore/scaffold-cra
stephen-algeo Feb 15, 2020
c9ba733
Display list of live football events
Feb 15, 2020
bcc7033
Merge pull request #2 from sjalgeo/feat/show-football-events
stephen-algeo Feb 15, 2020
2432512
Add routing and refactor live events component
Feb 15, 2020
44d6b4e
Merge pull request #3 from sjalgeo/feat/add-routing
stephen-algeo Feb 15, 2020
cced764
Show each events primary market
Feb 16, 2020
5a9b361
Merge pull request #4 from sjalgeo/feat/display-primary-market
stephen-algeo Feb 16, 2020
fe3746e
Add toggle for odds type
Feb 16, 2020
2a7927d
Merge pull request #5 from sjalgeo/feat/toggle-odds
stephen-algeo Feb 16, 2020
094153a
Add snapshot tests to components
Feb 16, 2020
4f47505
Merge pull request #6 from sjalgeo/feat/component-tests
stephen-algeo Feb 16, 2020
ab379a4
Update readme with instructions
Feb 16, 2020
b515a44
Merge pull request #7 from sjalgeo/chore/update-readme
stephen-algeo Feb 16, 2020
eae02ca
Add basic styling
Feb 17, 2020
8016e9f
Merge pull request #8 from sjalgeo/feat/basic-styles
stephen-algeo Feb 18, 2020
ac21e76
Point to SPA subdirectory in instructions
Feb 18, 2020
e47cecb
Merge pull request #9 from sjalgeo/fix/readme-subdir
stephen-algeo Feb 18, 2020
b7a5ebd
Segment scenes into subdirectory
Feb 18, 2020
0d1a68c
Merge pull request #10 from sjalgeo/chore/refactor-scenes
stephen-algeo Feb 18, 2020
c4e6e53
Refactor and add market screen
Feb 18, 2020
6a19d9e
Merge pull request #11 from sjalgeo/feat/market-screen
stephen-algeo Feb 18, 2020
031a885
Subscribe to price updates
Feb 19, 2020
d791a73
Merge pull request #12 from sjalgeo/feat/subscribe-to-prices
stephen-algeo Feb 19, 2020
4db7555
Use websocket to get event data
Feb 19, 2020
57e504f
Merge pull request #13 from sjalgeo/fix/get-market
stephen-algeo Feb 19, 2020
75d6126
Order markets and debounce expensive operation
Feb 19, 2020
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
131 changes: 28 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,51 @@
# Sky Betting & Gaming Tech Test
# SkyBet/Stars Tech Test

This test comes with a mock API and WebSocket server that represents a snapshot of some live football events we offer betting on at Sky Bet.
### App Scaffold

The challenge is to build a lightweight application to display the events returned by the API and enable users to browse for more details and betting opportunities.
I used create-react-app as I didn't want setting up babel/webpack to eat into the time of the test.

Full details of the API are available [on the docker hub page](https://hub.docker.com/r/sbgtechtest/api/) and further information about terms used, example API responses and the betting domain in general are available in [the background docs](./Background.md)
### State management

## The Test
I tried to use React's built in features including hooks and context to manage the state and data within the application, as the app is built out, a third party library may be required but this sufficed for the purposes of the exercise.

We realise everyone has different levels of skill and experience when it comes to development so we have listed different levels of tasks below for you to choose from. If you do not have the time or the knowledge to complete them all then that's ok, we just want to see how you approach the problem and get a feel for how you code.
### Tests

The API uses a snapshot of Sky Bet's catalogue as the underlying data source. The start times for the events are accurate as of the snapshot so can be used for displaying as an absolute value only. They should not be used to calculate the amount of time elapsed in a game as they will be hugely inaccurate!
I used Jest for the tests because its the tool I'm most familiar with and has a much better developer experience than the others I've tried.

It is possible to explore the catalogue using the HTTP endpoints provided, however, we ask that you try and use the WebSocket connection to handle all data fetching as part of this test.
### Run app

> We have structured the test below with what we consider to be a sensible way of building up the application iteratively and sequentially. You are free to work on as many or as few of the subtasks (and in any order) that you feel showcases your capabilities best
Run server as described in the original task:

### Task One

Using the provided WebSocket API:
1. Build an application which displays the currently live Football events. An example of making this request is shown below.
2. Add an option to show the primary market for each of the events
1. The primary market should also result in the odds showing for any outcomes linked to the market
3. Add a feature to toggle the odds display between fractional and decimal (this should apply globally to any place in the app where odds are shown)

```javascript
// The WebSocket API responds to several different actions: getEvent, getMarket, getOutcome and getLiveEvents
// To fetch all the currently live events (without primary markets) you can do something similar to the below
// NB. All payloads to the WebSocket API should be stringified
websocket.send(JSON.stringify({type: "getLiveEvents", primaryMarkets: false}));
```

### Task Two

1. Add a feature to allow users to browse for full details for one of the events (this may be a new page or some other mechanic)
1. Use as much of the detail in the Event response as possible to inform the user of meta data such as event type, start time and scores
2. Event responses sent via the WebSocket only include an array of IDs for the markets it includes. Use the Event payload to build further queries to the API so you can show a list of all the markets available for the event.
3. Markets similarly contain an array of IDs for outcomes. Use this data to initially show the outcomes for the first ten markets only.
1. Markets should be sorted by displayOrder (ascending) and then name.
4. Add the ability to load the outcomes for a market on demand (on skybet.com this happens when the market's accordion is clicked)
5. Use the `displayable` status to filter events, markets and outcomes which should not be shown to the user

### Task Three

1. Use the ability to subscribe to updates for events, outcomes and markets of interest. Handle these updates so that the UI correctly reflects any changes to data currently being displayed on the page.
1. Use the included images to help understand what `status.suspended` implies for the User.
2. Consider how the different levels of subscription affect the data received via the WebSocket.
2. On the overview page, instead of showing all events in one list, group them by their `linkedEventTypeName` property. A missing value should cause the grouping to fall back to the `typeName` property.
1. Additionally, anywhere you are displaying full details of an event, where possible use the `linkedEventTypeName` to highlight the competition the event belongs to.
3. Add support for displaying markets with different types (i.e. `win-draw-win` and `correct-score`) with more appropriate layouts. (See the [live website](https://m.skybet.com) for inspiration.)
4. Allow the user to click on outcomes to add them to a bet slip. The bet slip should display enough information about the selected outcome for the user to be able to see the event name, market name, outcome name and odds.
5. Manage WebSocket subscriptions to allow the bet slip to listen for updates to selected outcomes and markets as and when they change, and invalidate selections as appropriate.

## Languages

This is a "client side" focused test so the end deliverable should be viewable as a standard website. How you get there is up to you, though it's worth noting that we typically support a stack that uses technology such as PHP, node.js and React. We don't require you to write any form of server component but ask that you consider how you can ensure your submission will run effectively on any potential reviewers computer.

## Review Criteria

All tech test submissions (for any of our tech tests) are anonymised and reviewed using a standard template.

At a high level we will be looking for:
* Clear instructions for how to run the application on a reviewer's machine
* Good understanding of the tasks undertaken and content presented in a clear, understandable format
* Well structured code
* High quality code that uses relevant design patterns
* Appropriate unit tests
* Security best practices applied
* Good understanding of errors and how to handle them

There's flexibility in the review process to take into account candidates who have strengths in different areas. Submissions that are very strong on visual design, UX and css are equally as valid as those which focus on the underlying code.

As mentioned previously, we aren't prescribing any specific languages, libraries or frameworks for the test but obviously the reviewer will need to take into account choices made in this area. For example, a submission using a technology like [create react app](https://github.com/facebookincubator/create-react-app) or [ember.js](https://www.emberjs.com/) will potentially offer a more complete set of tasks than one attempting to build everything from scratch. It is up to you to decide how pragmatic you wish to be. Make sure you choose an approach which you feel will show off your talents most effectively.

## Getting Started

### System Requirements

* Docker

### Running the API and Websocket Server

Full details of the API are available [on the docker hub page](https://hub.docker.com/r/sbgtechtest/api/). We would recommend running with `docker-compose up` so any logs from the API are visible in the terminal.

```bash
# running the basic image
docker run -it --rm --name sbg-tech-test-api -p 8888-8890:8888-8890 sbgtechtest/api:2.0.0

# running using docker compose
docker-compose up

# running using docker compose in the background
docker-compose up -d
> docker run -it --rm --name sbg-tech-test-api -p 8888-8890:8888-8890 sbgtechtest/api:2.0.0
```

The API will now be available on `http://localhost:8888/` and you should be able to view the available routes by hitting the API root.
Pre-requisite: yarn

If you are developing on Windows it's likely that docker won't have mapped the ports to `localhost`. Run `docker-machine ip default` to find the correct IP, the ports and endpoints will be the same.
(in `/app` subdirectory)

The WebSocket Server will be available on `ws://localhost:8889` and you can test this is working by subscribing to all outcome updates:
Build:

```javascript
// In your browser's console add the following one line at a time
const w = new WebSocket("ws://localhost:8889");
w.addEventListener("message", m => console.log(JSON.parse(m.data)));
w.send(JSON.stringify({type: "subscribe", keys: ["o.*"]}));
w.send(JSON.stringify({type: "getLiveEvents", primaryMarkets: false }));
```
> yarn
```

See the documentation [on the docker hub page](https://hub.docker.com/r/sbgtechtest/api/) for full details of the WebSocket interface.

## The Deliverable
Start:

Replace the contents of this README.md with:
```
> yarn start
```

1. A covering note explaining the technology choices you have made.
1. Any instructions required to run your solution and tests in a Linux environment.
### Run Tests

Email as an attachment or a link the git bundled repository showing your commit history with all your commits on the master branch:
Interactive mode:

git bundle create <anything>.bundle --all
```
> yarn test
```

## Equality & Diversity
Full run:

We consider all candidates equally, fairly and without bias. To that end, we ask that you do not leave any personally identifying information in your submission (such as your name within an author field or file, or in use as test data). We run all VCS-based submissions through an anonymiser before assessment, so that there is no identifying information in the commit history, but this will only remove references in the committing author and email address, not deep in the code submitted.
```
> yarn test --watchAll=false
```
23 changes: 23 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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*
yarn-debug.log*
yarn-error.log*
68 changes: 68 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `yarn 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.

### `yarn 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.

### `yarn 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.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

### Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

### Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

### Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

### Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

### `yarn build` fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
35 changes: 35 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added app/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions app/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added app/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions app/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions app/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Loading