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

Score page #82

Closed
wants to merge 146 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
5746281
artist generator files
Arrtee123 Apr 24, 2024
87b9808
QuizPage
katrinamichanicou Apr 24, 2024
cbab4c8
Merge remote-tracking branch 'origin/main' into generators
Arrtee123 Apr 24, 2024
fa13c0e
Adding route and service for getGenres
arana5683 Apr 24, 2024
bd2bbb1
Merge remote-tracking branch 'origin/main' into deezer-service
arana5683 Apr 24, 2024
e528d10
audio button component created and css styling
bobama123 Apr 24, 2024
381e28d
Merge remote-tracking branch 'origin/main' into audio_button
bobama123 Apr 24, 2024
8b96feb
tests added for GET genres
katrinamichanicou Apr 24, 2024
a5cd5a1
audio now loops
bobama123 Apr 24, 2024
881e0d7
tests added for component
bobama123 Apr 24, 2024
0cdad7c
Service file + 2 Tests working
ohmygois Apr 24, 2024
f9c1169
one more test
bobama123 Apr 24, 2024
5785aa1
All tests working
ohmygois Apr 24, 2024
1ae1967
Question component created. tests needed
jason-sayeed Apr 24, 2024
350c092
routes and services added
katrinamichanicou Apr 24, 2024
34f83e4
fixing api test placeholder
katrinamichanicou Apr 24, 2024
965ad1e
All tests passing
ohmygois Apr 24, 2024
9f73a3e
Merge pull request #1 from katrinamichanicou/audio_button
jason-sayeed Apr 25, 2024
7f31fef
quizpage created
jason-sayeed Apr 25, 2024
2ab6aff
Merge remote-tracking branch 'origin/main' into quiz_page_easy
jason-sayeed Apr 25, 2024
ff99266
Merge pull request #2 from katrinamichanicou/deezer-service
katrinamichanicou Apr 25, 2024
47d8d94
Merge remote-tracking branch 'origin/main' into quiz_page_easy
jason-sayeed Apr 25, 2024
c5ce7fd
Merge remote-tracking branch 'origin/main' into generators
Arrtee123 Apr 25, 2024
3b2a0ad
add preview and clean up logs
Arrtee123 Apr 25, 2024
95a55cc
update tests for new answer returned
Arrtee123 Apr 25, 2024
e3e8691
Add CI config
bobama123 Apr 25, 2024
4139f12
Updated CI config
bobama123 Apr 25, 2024
7be2e68
Updated CI config for frontend
bobama123 Apr 25, 2024
de3c44a
fixing CI config
bobama123 Apr 25, 2024
2a1a0d6
fixing CI config again
bobama123 Apr 25, 2024
9a980f4
Adding backend tests to the CI workflow
bobama123 Apr 25, 2024
b0678e5
linking Deezer service to generators
Arrtee123 Apr 25, 2024
8cb364c
backend test for CI removed
bobama123 Apr 25, 2024
ad266dd
Added job name
bobama123 Apr 25, 2024
102a596
Merge pull request #4 from katrinamichanicou/continuous_integration_bob
bobama123 Apr 25, 2024
4deeb48
question component updated
jason-sayeed Apr 25, 2024
7f25c96
removed whitespace and testing calls
Arrtee123 Apr 25, 2024
3ce15e8
updated quiz page with question component
jason-sayeed Apr 25, 2024
2c601fe
refactor answer generator
Arrtee123 Apr 25, 2024
b57ee0c
Merge pull request #3 from katrinamichanicou/generators
Arrtee123 Apr 25, 2024
a280ee6
tests changed to use toBe as more accurate and reliable test
bobama123 Apr 25, 2024
af3e01a
Merge pull request #5 from katrinamichanicou/audio_button
bobama123 Apr 25, 2024
b6946e9
tests for question component and quiz page
jason-sayeed Apr 25, 2024
31137f8
Merge remote-tracking branch 'origin/main' into quiz_page_easy
jason-sayeed Apr 25, 2024
0ea31eb
removed commented out code
jason-sayeed Apr 25, 2024
c3b452e
tests now pass as part of CI
jason-sayeed Apr 25, 2024
4c3f714
Merge pull request #6 from katrinamichanicou/quiz_page_easy
jason-sayeed Apr 25, 2024
972d604
answer component created
bobama123 Apr 25, 2024
8f3eea3
Merge remote-tracking branch 'origin/main' into answer_component
bobama123 Apr 25, 2024
73001fe
Answer component created and renders on Quizpage with showing if is c…
bobama123 Apr 25, 2024
11cfd77
button changes colour on click
bobama123 Apr 26, 2024
e82269d
Adding Google sign-in and styling
arana5683 Apr 26, 2024
d0d2fe0
changed name of Answer component
bobama123 Apr 26, 2024
219b377
Merge remote-tracking branch 'origin/main' into google-auth
arana5683 Apr 26, 2024
b4ff2a3
quizPage test file deleted so CI passes
bobama123 Apr 26, 2024
fb3dbaa
Merge pull request #8 from katrinamichanicou/answer_component
jason-sayeed Apr 26, 2024
fadc6a5
Merge pull request #7 from katrinamichanicou/google-auth
arana5683 Apr 26, 2024
e5b8609
Genre picker component
ohmygois Apr 26, 2024
b2ef933
Mergin main
ohmygois Apr 26, 2024
a786d2f
Genre Picker added
ohmygois Apr 26, 2024
8bc1ad8
tests are passing, had to mock the function
bobama123 Apr 26, 2024
b19a221
install tailwind and inital styling of quiz page
Arrtee123 Apr 26, 2024
9024b36
Genre Picker added, users can pick genre and it changes track and art…
ohmygois Apr 26, 2024
d94cc32
added white writing for answer when clicked, mocking tests are done f…
bobama123 Apr 26, 2024
391caf8
PR Changes reviewed
ohmygois Apr 26, 2024
e3343f2
updated hover functionality
katrinamichanicou Apr 26, 2024
e439e5f
question font size increased slightly
katrinamichanicou Apr 26, 2024
8948f14
buttonColors array issues corrected
katrinamichanicou Apr 26, 2024
9336865
Merge pull request #9 from katrinamichanicou/tailwind
katrinamichanicou Apr 26, 2024
3b89816
HomePage added with GoogleAuth
katrinamichanicou Apr 26, 2024
bf5618a
Testing for GenrePicker done
ohmygois Apr 26, 2024
709e845
accepting answer component changes
bobama123 Apr 26, 2024
bfc813e
minor updates: Google button wording and moved play as guest below
katrinamichanicou Apr 26, 2024
816297a
Merge remote-tracking branch 'origin/main' into GenrePicker
ohmygois Apr 26, 2024
2ccbc78
Tailwind tags added to the Genre Buttons
ohmygois Apr 26, 2024
ff0ab41
Merge pull request #10 from katrinamichanicou/GenrePicker
ohmygois Apr 26, 2024
0976563
Merge remote-tracking branch 'origin/main' into homepage
katrinamichanicou Apr 26, 2024
f1c9874
Tests completed for answer component and quiz page for play button, q…
bobama123 Apr 26, 2024
196156f
testing added and passes. testing-library/jest-dom dependency added t…
katrinamichanicou Apr 26, 2024
ec1dbb6
sliding animation added to the transition between genrepicker and the…
katrinamichanicou Apr 27, 2024
82c656e
update genrepicker buttons
katrinamichanicou Apr 27, 2024
5f5ea17
removing unnecessary code in tailwind.config file
katrinamichanicou Apr 27, 2024
410ee45
added custom background, updated config file for easy text and backgr…
Arrtee123 Apr 28, 2024
1ed77f7
update genrePicker testing
Arrtee123 Apr 29, 2024
9e0c040
custom background is now full page
Arrtee123 Apr 29, 2024
1c361b9
Merge pull request #12 from katrinamichanicou/homepage
katrinamichanicou Apr 29, 2024
af9923d
Merge pull request #13 from katrinamichanicou/quizpage-styling
katrinamichanicou Apr 29, 2024
79f7e9d
Merge pull request #11 from katrinamichanicou/answer_component
bobama123 Apr 29, 2024
f79593f
new question now generated
jason-sayeed Apr 29, 2024
c3e3782
quizpage and answer tests are now passing after the all merges
bobama123 Apr 29, 2024
83dee46
Merge pull request #14 from katrinamichanicou/answer_component
bobama123 Apr 29, 2024
613b1c0
corrected conflicts with styling
jason-sayeed Apr 29, 2024
606e21f
Merge remote-tracking branch 'origin/main' into round_of_questions
jason-sayeed Apr 29, 2024
4919e7f
only generates 5 questions
jason-sayeed Apr 29, 2024
19295e8
cloud db setup
katrinamichanicou Apr 29, 2024
ddafc6c
after 5th question navigate to results
jason-sayeed Apr 29, 2024
d0903f0
corrected tests
jason-sayeed Apr 29, 2024
ae42911
Merge pull request #15 from katrinamichanicou/round_of_questions
jason-sayeed Apr 29, 2024
1d15853
corrected navigate mock
jason-sayeed Apr 29, 2024
17a7286
added delay before going to results page
jason-sayeed Apr 29, 2024
6a71166
port option updated from 3000 to 10000
katrinamichanicou Apr 29, 2024
27a2f55
Merge pull request #16 from katrinamichanicou/round_of_questions
jason-sayeed Apr 29, 2024
e4c1ad0
error message added to genre request
katrinamichanicou Apr 29, 2024
1ce305d
access control headers set in app
katrinamichanicou Apr 29, 2024
7b7dad3
response headers added in previous commit now removed
katrinamichanicou Apr 29, 2024
a295f00
response added to error
katrinamichanicou Apr 29, 2024
308257a
updated api request from https to http
katrinamichanicou Apr 29, 2024
1af837d
commented out initial post and http changed back to https for getGenres
katrinamichanicou Apr 29, 2024
055f630
add response info to error for getArtistsForGenre function
katrinamichanicou Apr 29, 2024
7747322
commented code clean up
katrinamichanicou Apr 30, 2024
076bebe
time state added to add bonus points for quick answers, plus tests
Arrtee123 Apr 30, 2024
cd13514
question number hidden before new question generated. pages displays …
jason-sayeed Apr 30, 2024
8cf428c
corrected failing tests
jason-sayeed Apr 30, 2024
c3fa13c
remove redundant useEffect from AudioButton
Arrtee123 Apr 30, 2024
b468833
Score page updated
ohmygois Apr 30, 2024
234aec7
Merge pull request #18 from katrinamichanicou/results-timer
Arrtee123 Apr 30, 2024
f554c92
questions can now change for album title and song title, added backen…
bobama123 Apr 30, 2024
6c45b6f
Merge remote-tracking branch 'origin/main' into ScorePage
ohmygois Apr 30, 2024
e46e2d3
changes done for merge locally
bobama123 Apr 30, 2024
4cb9152
another file
bobama123 Apr 30, 2024
70ec253
Score page updated with timer
ohmygois Apr 30, 2024
bb13319
ScorePage finalised
ohmygois Apr 30, 2024
6ed45be
Done
ohmygois Apr 30, 2024
44048d9
Merge branch 'main' into round_of_questions
jason-sayeed Apr 30, 2024
4093f6e
added tests
jason-sayeed Apr 30, 2024
cb87fee
all tests passing now
bobama123 Apr 30, 2024
35830a5
Tests Fixed, Create PR
ohmygois Apr 30, 2024
ce0cc0c
Merge pull request #17 from katrinamichanicou/deploy
arana5683 Apr 30, 2024
81d3174
Merge remote-tracking branch 'origin/main' into round_of_questions
jason-sayeed Apr 30, 2024
aa1635a
corrected tests
jason-sayeed Apr 30, 2024
62dad1b
Merge pull request #19 from katrinamichanicou/round_of_questions
Arrtee123 May 1, 2024
c73b1f6
fixed tests and visuals with audio button
jason-sayeed May 1, 2024
b1afe56
Merge remote-tracking branch 'origin/main' into round_of_questions
jason-sayeed May 1, 2024
0f8d5d6
little clean up
bobama123 May 1, 2024
ce64b71
more clean up
bobama123 May 1, 2024
9704392
1 more clean
bobama123 May 1, 2024
9d4721b
fixed tests
jason-sayeed May 1, 2024
46fe497
Merge pull request #22 from katrinamichanicou/round_of_questions
jason-sayeed May 1, 2024
fa74e12
Merge branch 'main' into ScorePage
ohmygois May 1, 2024
0cdf98d
Merge branch 'main' into ScorePage
ohmygois May 1, 2024
7732274
Refactor on ScorePage done.
ohmygois May 1, 2024
216805a
PR Fixes
ohmygois May 1, 2024
9068114
resolved merge conflicts, all test passing
bobama123 May 1, 2024
9490915
Merge pull request #21 from katrinamichanicou/new_questions
bobama123 May 1, 2024
f88fedf
Clearing local storage after each test
ohmygois May 1, 2024
5943cad
Merge remote-tracking branch 'origin/main' into ScorePage
ohmygois May 1, 2024
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
36 changes: 36 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# The name of the workflow
name: Frontend Testing

# This workflow will run on any push to the repository
on: push

jobs:
test:
name: Frontend Tests
# Similar to docker, we set up a virtual machine to run our tests
runs-on: ubuntu-latest

steps:
# Each step has a name, some code, and some options
- name: Check out the code
uses: actions/checkout@v3 # This is a reference to some code to run

# This step installs the Node version
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x

# Move to frontend directory and install dependencies
- name: Move to frontend and install dependencies
run: |
cd frontend
npm install

# Test React app
- name: Move to frontend and Test
run: |
cd frontend
npm run test


2 changes: 2 additions & 0 deletions api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const cors = require("cors");
const usersRouter = require("./routes/users");
const postsRouter = require("./routes/posts");
const authenticationRouter = require("./routes/authentication");
const musicRouter = require("./routes/music")
const tokenChecker = require("./middleware/tokenChecker");

const app = express();
Expand All @@ -21,6 +22,7 @@ app.use(bodyParser.json());
app.use("/users", usersRouter);
app.use("/posts", tokenChecker, postsRouter);
app.use("/tokens", authenticationRouter);
app.use("/music", musicRouter)

// 404 Handler
app.use((_req, res) => {
Expand Down
93 changes: 93 additions & 0 deletions api/controllers/music.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
const getGenres = async (req, res) => {
const requestOptions = {
method: "GET"
}

const response = await fetch("https://api.deezer.com/genre", requestOptions);

if (response.status !== 200) {
throw new Error(`Unable to fetch genres. Status: ${response.status}. Headers: ${await response.text()}`);
}

const data = await response.json();
res.status(200).json(data.data)
};

const getArtistsForGenre = async (req, res) => {
const genreID = req.params.id;

const requestOptions = {
method: "GET"
}

const response = await fetch(`https://api.deezer.com/genre/${genreID}/artists`, requestOptions);

if (response.status !== 200) {
throw new Error("Unable to fetch artists. Status: ${response.status}. Headers: ${await response.text()}");
}

const data = await response.json();
res.status(200).json(data.data)
};

const getTopTracksForArtist = async (req, res) => {
const artistID = req.params.id;

const requestOptions = {
method: "GET"
}

const response = await fetch(`https://api.deezer.com/artist/${artistID}/top`, requestOptions);

if (response.status !== 200) {
throw new Error("Unable to fetch top tracks for artist");
}

const data = await response.json();
res.status(200).json(data.data)
};

const getTrack = async (req, res) => {
const trackID = req.params.id;

const requestOptions = {
method: "GET"
}

const response = await fetch(`https://api.deezer.com/track/${trackID}`, requestOptions);

if (response.status !== 200) {
throw new Error("Unable to fetch top tracks for artist");
}

const data = await response.json();
res.status(200).json(data)
};


const getAlbumsForArtist = async (req, res) => {
const artistID = req.params.id;

const requestOptions = {
method: "GET"
}

const response = await fetch(`https://api.deezer.com/artist/${artistID}/albums`, requestOptions);

if (response.status !== 200) {
throw new Error("Unable to fetch albums for artist");
}

const data = await response.json();
res.status(200).json(data.data)
};

const MusicController = {
getGenres: getGenres,
getArtistsForGenre: getArtistsForGenre,
getTopTracksForArtist: getTopTracksForArtist,
getTrack: getTrack,
getAlbumsForArtist: getAlbumsForArtist
};

module.exports = MusicController
28 changes: 17 additions & 11 deletions api/db/db.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
const mongoose = require("mongoose");

const connectToDatabase = async () => {
const mongoDbUrl = process.env.MONGODB_URL;

if (!mongoDbUrl) {
console.error(
"No MongoDB url provided. Make sure there is a MONGODB_URL environment variable set. See the README for more details."
);
throw new Error("No connection string provided");
}

await mongoose.connect(mongoDbUrl);
const uri = `mongodb+srv://${process.env.DB_USER}:${process.env.DB_PASSWORD}@kwizical.xpmi3dw.mongodb.net/?retryWrites=true&w=majority&appName=kwizical`;
const clientOptions = {
serverApi: { version: "1", strict: true, deprecationErrors: true },
};

if (process.env.NODE_ENV !== "test") {
console.log("Successfully connected to MongoDB");
try {
// Create a Mongoose client with a MongoClientOptions object to set the Stable API version
await mongoose.connect(uri, clientOptions);
await mongoose.connection.db.admin().command({ ping: 1 });
console.log(
"Pinged your deployment. You successfully connected to MongoDB!"
);
} catch {
console.dir
} finally {
// Ensures that the client will close when you finish/error
await mongoose.disconnect();
}
};

module.exports = { connectToDatabase };

2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const app = require("./app.js");
const { connectToDatabase } = require("./db/db.js");

const listenForRequests = () => {
const port = process.env.PORT || 3000;
const port = process.env.PORT || 10000;
app.listen(port, () => {
console.log("Now listening on port", port);
});
Expand Down
4 changes: 2 additions & 2 deletions api/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Post = mongoose.model("Post", PostSchema);

// These lines will create a test post every time the server starts.
// You can delete this once you are creating your own posts.
const dateTimeString = new Date().toLocaleString("en-GB");
new Post({ message: `Test message, created at ${dateTimeString}` }).save();
// const dateTimeString = new Date().toLocaleString("en-GB");
// new Post({ message: `Test message, created at ${dateTimeString}` }).save();

module.exports = Post;
84 changes: 25 additions & 59 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions api/routes/music.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const express = require("express");
const router = express.Router();

const MusicController = require("../controllers/music");

router.get("/genre", MusicController.getGenres);
router.get("/genre/:id/artists", MusicController.getArtistsForGenre);
router.get("/artist/:id/top", MusicController.getTopTracksForArtist);
router.get("/track/:id", MusicController.getTrack);
router.get("/artist/:id/albums", MusicController.getAlbumsForArtist);

module.exports = router;
16 changes: 16 additions & 0 deletions api/tests/controllers/music.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// const request = require("supertest");
// const app = require("../../app");

// TODO: Tests to be added. Need to research mocking fetch with Jest
// test below actually calls Deezer API
// - Aakash / Katrina

describe("GET, genres", () => {
test("the response code is 200", async () => {

// const response = await request(app)
// .get("/music/genre")

// expect(response.status).toEqual(200);
expect(true)
})});
22 changes: 22 additions & 0 deletions frontend/helpers/album_generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { shuffle } from "../helpers/shuffle.js";
import { getAlbumsForArtist } from "../src/services/deezerService.js";

export const randomAlbums = async (artistID) => {
try {

const data = await getAlbumsForArtist(artistID);
//create a list of dictionaries with artist ID and name
const albumList = data.map(album => ({
id: album.id,
title: album.title
}));

const shuffledAlbums = shuffle(albumList); // Shuffle the array of albums
const selectedAlbums = shuffledAlbums.slice(0, 4); // Select the first 4 albums
return selectedAlbums;

} catch (error) {
console.error("Error fetching artists:", error);
throw new Error("Unable to fetch random albums");
}
};
Loading