-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from COS301-SE-2024/development
Development - Demo 1
- Loading branch information
Showing
109 changed files
with
4,886 additions
and
84 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,13 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"useBuiltIns": "entry", | ||
"corejs": 3 | ||
} | ||
], | ||
"@babel/preset-react" | ||
], | ||
"plugins": ["@babel/plugin-transform-runtime"] | ||
} |
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,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 |
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,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 |
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 |
---|---|---|
|
@@ -30,6 +30,10 @@ yarn-error.* | |
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
|
||
# Jest | ||
/jest.config.js |
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,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> | ||
); | ||
} |
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 @@ | ||
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", | ||
}); | ||
}); |
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,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); | ||
}); | ||
}); | ||
|
||
|
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 @@ | ||
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'); |
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,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" | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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,6 @@ | ||
module.exports = function(api) { | ||
api.cache(true); | ||
return { | ||
presets: ['babel-preset-expo'], | ||
}; | ||
}; |
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 @@ | ||
{ | ||
"presets": ["@babel/preset-env"] | ||
} |
Oops, something went wrong.