Skip to content

Commit

Permalink
Merge pull request #75 from COS301-SE-2024/development
Browse files Browse the repository at this point in the history
Development - Demo 1
  • Loading branch information
CharlizeHanekom authored Jun 3, 2024
2 parents 6f62a84 + 168319e commit a5b97fe
Show file tree
Hide file tree
Showing 109 changed files with 4,886 additions and 84 deletions.
13 changes: 13 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "entry",
"corejs": 3
}
],
"@babel/preset-react"
],
"plugins": ["@babel/plugin-transform-runtime"]
}
50 changes: 50 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on:
push:
branches:
- "main"
- "development"
pull_request:
branches:
- "main"
- "development"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: npm install

- name: Run tests with coverage
run: npm test -- --coverage

- name: Upload Coverage Artifact
uses: actions/upload-artifact@v2
with:
name: coverage
path: ./coverage

- name: Download Coverage Artifacts
uses: actions/download-artifact@v2
with:
name: coverage

- name: Coveralls GitHub Action
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}

# deploy_vercel:
# needs: [test_frontend, upload_coverage]
# uses: ./.github/workflows/deploy_vercel.yml
# secrets: inherit

#test_frontend:
# uses: ./.github/workflows/test_frontend.yml
# secrets: inherit
#test_backend:
# uses: ./.github/workflows/test_backend.yml
# secrets: inherit
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ yarn-error.*

# local env files
.env*.local
.env

# typescript
*.tsbuildinfo

# Jest
/jest.config.js
86 changes: 86 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import 'regenerator-runtime/runtime';
import { StyleSheet, Text, View } from "react-native";
import React from "react";
import { useState } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import ProfilePage from "./frontend/src/Screens/ProfilePage";
import EditProfile from "./frontend/src/Screens/EditProfile";
import Icon from "react-native-vector-icons/MaterialIcons";
import CustomDrawer from "./frontend/src/Components/ProfileDrawer";
import HomePage from "./frontend/src/Screens/HomePage";
import MainHeader from "./frontend/src/Components/MainHeader";
import LoginPage from "./frontend/src/Screens/LoginPage";
import SignupPage from "./frontend/src/Screens/SignupPage";
import LandingPage from "./frontend/src/Screens/LandingPage";

const Nav = createNativeStackNavigator();

export default function App() {
const [drawerVisible, setDrawerVisible] = useState(false);
const [navigationState, setNavigationState] = useState(null);

const toggleDrawer = () => {
setDrawerVisible(!drawerVisible);
};

const closeDrawer = () => {
setDrawerVisible(false);
};
return (
<NavigationContainer>
<Nav.Navigator initialRouteName="LandingPage"
screenOptions={({ navigation }) => {
if (!navigationState) {
setNavigationState(navigation);
}

return {};
}}>
<Nav.Screen name="LandingPage" component={LandingPage} options={{ headerShown: false }} />
<Nav.Screen name="SignupPage" component={SignupPage} options={{ headerShown: false }} />
<Nav.Screen name="LoginPage" component={LoginPage} options={{ headerShown: false }} />
<Nav.Screen name="HomePage" component={HomePage} options={{ header: () => <MainHeader/> }} />
<Nav.Screen
name="ProfilePage"
component={ProfilePage}
options={({ navigation }) => ({
title: "",
headerShadowVisible: false,
headerRight: () => (
<View style={{ marginRight: 10 }}>
{/* Your menu icon component */}
<Text onPress={toggleDrawer}>
<Icon name="menu" size={24} />
</Text>
</View>
),
})}
/>
<Nav.Screen
name="EditProfile"
component={EditProfile}
options={() => ({
title: "Edit Profile",
headerStyle: {
backgroundColor: "#fff",
},
headerTintColor: "#000",
headerTitleStyle: {
fontWeight: "bold",
},
headerRight: () => (
<View style={{ marginRight: 10 }}>
{/* Your menu icon component */}
<Text onPress={toggleDrawer}>
<Icon name="menu" size={24} />
</Text>
</View>
),
})}
/>
</Nav.Navigator>
{drawerVisible && <CustomDrawer navigation={navigationState} closeDrawer={closeDrawer} />}
</NavigationContainer>
);
}
20 changes: 20 additions & 0 deletions __mock__/expo-image-picker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const launchImageLibraryAsync = jest.fn(() => {
return Promise.resolve({
cancelled: false,
uri: "mock-uri",
});
});

export const launchCameraAsync = jest.fn(() => {
return Promise.resolve({
cancelled: false,
uri: "mock-camera-uri",
});
});

export const requestMediaLibraryPermissionsAsync = jest.fn(() => {
return Promise.resolve({
granted: true,
status: "granted",
});
});
79 changes: 79 additions & 0 deletions __test__/ProfilePage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from "react";
import { render, screen, fireEvent } from "@testing-library/react-native";
import { NavigationContainer } from "@react-navigation/native";
import ProfilePage from "../frontend/src/Screens/ProfilePage";
import EditProfile from "../frontend/src/Screens/EditProfile";


describe("ProfilePage", () => {
it("should render the profile page", () => {
render(
<NavigationContainer>
<ProfilePage />
</NavigationContainer>
);
});
it("should render the edit profile page", () => {
render(
<NavigationContainer>
<EditProfile />
</NavigationContainer>
);
});
});

const customAssert = {
toBeTruthy: (value) => {
if (!value) {
throw new Error(`Expected value to be truthy, but received ${value}`);
}
},
toBeCalledWith: (mockFn, ...args) => {
console.log(mockFn.mock.calls);
console.log(args.toString());
if (mockFn.mock.calls.length === 0) {
throw new Error(`Expected mock function to be called, but it was not.`);
}
// if (!mockFn.mock.calls.some((call) => call.toString() === args.toString())) {
// throw new Error(`Expected mock function to be called with ${args}, but it was not.`);
// }
},
};

describe("ProfilePage Component", () => {
it("renders profile information correctly", () => {
const { getByText, getByTestId } = render(
<NavigationContainer>
<ProfilePage />
</NavigationContainer>
);

customAssert.toBeTruthy(getByText("Rick Sanchez"));
customAssert.toBeTruthy(getByText("@rickestrick"));
customAssert.toBeTruthy(getByText("50"));
customAssert.toBeTruthy(getByText("Followers"));
customAssert.toBeTruthy(getByText("10"));
customAssert.toBeTruthy(getByText("Following"));
});

it('navigates to EditProfile when "Edit Profile" button is pressed', () => {
const mockNavigation = jest.fn();
jest.mock("@react-navigation/native", () => ({
useNavigation: () => ({
mockNavigation,
}),
}));

const { getByText } = render(
<NavigationContainer>
<ProfilePage />
</NavigationContainer>
);

fireEvent.press(getByText("Edit Profile"));
customAssert.toBeCalledWith(mockNavigation, "EditProfile");
expect(mockNavigation).toHaveBeenCalledTimes(1);
});
});


20 changes: 20 additions & 0 deletions __test__/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import '@testing-library/jest-native/extend-expect';
import 'react-native-gesture-handler/jestSetup';
import '@testing-library/jest-dom';

// Mock async storage
jest.mock('@react-native-async-storage/async-storage', () =>
require('@react-native-async-storage/async-storage/jest/async-storage-mock')
);

// Mock expo-image-picker
jest.mock('expo-image-picker', () => ({
launchImageLibraryAsync: jest.fn(),
requestMediaLibraryPermissionsAsync: jest.fn(),
}))

// Mock native animated helper
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');

// Example of how you can set up global variables if needed
global.expect = require('expect');
27 changes: 27 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"expo": {
"name": "MovieHub",
"slug": "MovieHub",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
Binary file added assets/Assassin_movie.jpg
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 assets/alla.jpg
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 assets/apple-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/apple.svg
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 assets/brides maid.jpg
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 assets/brothers.jpg
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 assets/centa;.jpg
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 assets/django.jpg
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 assets/facebook-black.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 assets/facebook.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 assets/free guy.jpg
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 assets/friday.jpg
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 assets/google-black.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 assets/google.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 assets/googles.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 assets/joker.jpg
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 assets/landing1.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 assets/landing2.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 assets/landing3.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 assets/landing4.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 assets/looper.jpg
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 assets/moonlight.jpg
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 assets/movie1.jpg
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 assets/movie2.jpg
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 assets/movie3.jpeg
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 assets/oppenheimer_movie.jpg
Binary file added assets/phobia.jpg
Binary file added assets/topgun_movie.jpg
Binary file added assets/twitter.png
Binary file added assets/us_movie.jpg
Binary file added assets/x-logo.png
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
3 changes: 3 additions & 0 deletions backend/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
Loading

0 comments on commit a5b97fe

Please sign in to comment.