From 822573baa6b10759299664ec4016dccd2960da82 Mon Sep 17 00:00:00 2001 From: Wepo Date: Wed, 29 May 2024 15:20:23 +0200 Subject: [PATCH 01/20] feat: corrected announcement card --- components/AnnoucementCard/AnnouncementCard.tsx | 2 +- firebase/Registration.ts | 3 ++- screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx | 4 +++- screens/Explore/EventScreen/EventScreen.tsx | 6 ++++++ screens/Registration/InterestsScreen/InterestsScreen.tsx | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/components/AnnoucementCard/AnnouncementCard.tsx b/components/AnnoucementCard/AnnouncementCard.tsx index 5cac54af..6d36d796 100644 --- a/components/AnnoucementCard/AnnouncementCard.tsx +++ b/components/AnnoucementCard/AnnouncementCard.tsx @@ -18,7 +18,7 @@ const AnnouncementCard = ({announcement, recommended} : AnnouncementCardProps) = {announcement.interests.join("- ")} - {!recommended && ( + {recommended && ( Matches all your interests ★ )} diff --git a/firebase/Registration.ts b/firebase/Registration.ts index 8b1b62bc..b585f902 100644 --- a/firebase/Registration.ts +++ b/firebase/Registration.ts @@ -47,7 +47,8 @@ export async function storeInitialUserData(uid: string, email: string, firstName location: location, description: description, selectedInterests: selectedInterests, - profilePicture: "" + profilePicture: "", + events : [] }) } catch (error) { showErrorToast("There was an error storing your user data, please try again.") diff --git a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx index 89ff8e1d..fc16665b 100644 --- a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx +++ b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx @@ -109,7 +109,7 @@ const AnnouncementScreen = ({ })) } - return announcements + const recomm = announcements .map((announcement) => ({ announcement, recommended: announcement.interests.filter((interest) => @@ -121,6 +121,8 @@ const AnnouncementScreen = ({ if (a.recommended && !b.recommended) return -1 return 0 }) + console.log(recomm) + return recomm } const sections = [ diff --git a/screens/Explore/EventScreen/EventScreen.tsx b/screens/Explore/EventScreen/EventScreen.tsx index ca3b0ef2..bb59e5c0 100644 --- a/screens/Explore/EventScreen/EventScreen.tsx +++ b/screens/Explore/EventScreen/EventScreen.tsx @@ -78,6 +78,9 @@ const EventScreen = ({ onEventPress, userID }: EventsScreenProps) => { setFilteredFutureEvents(userFutureEvents) setFilteredPastEvents(userPastEvents) + if (userFutureEvents.length === 0 && userPastEvents.length === 0) { + showErrorToast("You have no events yet.") + } } const userImages = await fetchAllUserImages() if(userImages) { @@ -92,6 +95,9 @@ const EventScreen = ({ onEventPress, userID }: EventsScreenProps) => { setFilteredFutureEvents(fetchedFutureEvents) setFilteredPastEvents(fetchedPastEvents) + if (fetchedFutureEvents.length === 0 && fetchedPastEvents.length === 0) { + showErrorToast("You have no events yet.") + } const userImages = await fetchAllUserImages() if(userImages) { setUserImages(userImages) diff --git a/screens/Registration/InterestsScreen/InterestsScreen.tsx b/screens/Registration/InterestsScreen/InterestsScreen.tsx index a5b0f7ac..32827467 100644 --- a/screens/Registration/InterestsScreen/InterestsScreen.tsx +++ b/screens/Registration/InterestsScreen/InterestsScreen.tsx @@ -49,7 +49,7 @@ const InterestButton: React.FC = ({ ) - +//add announcement const InterestsScreen = () => { const insets = useSafeAreaInsets() const [searchTerm, setSearchTerm] = useState("") From 46bb86b5b816ba8e2dcdbba3d88adffc538d7489 Mon Sep 17 00:00:00 2001 From: Wepo Date: Wed, 29 May 2024 15:39:21 +0200 Subject: [PATCH 02/20] fix: user that has no events is notified accordingly --- screens/Explore/EventScreen/EventScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screens/Explore/EventScreen/EventScreen.tsx b/screens/Explore/EventScreen/EventScreen.tsx index bb59e5c0..0a844c93 100644 --- a/screens/Explore/EventScreen/EventScreen.tsx +++ b/screens/Explore/EventScreen/EventScreen.tsx @@ -220,7 +220,7 @@ const EventScreen = ({ onEventPress, userID }: EventsScreenProps) => { renderItem={renderItem} renderSectionHeader={renderSectionHeader} showsVerticalScrollIndicator={false} - stickySectionHeadersEnabled={false} + stickySectionHeadersEnabled={true} /> From 326ef427b2a28bbfa6219d90944a7058d088f9b4 Mon Sep 17 00:00:00 2001 From: Wepo Date: Wed, 29 May 2024 15:54:58 +0200 Subject: [PATCH 03/20] fix: add announcement layout --- .../Explore/AnnouncementScreen/AnnouncementScreen.tsx | 9 +++++---- screens/Explore/AnnouncementScreen/styles.ts | 11 ++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx index fc16665b..49dd9af4 100644 --- a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx +++ b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx @@ -156,17 +156,18 @@ const AnnouncementScreen = ({ return ( - navigation.navigate("EventCreation" as never, {isAnnouncement: true})} style={styles.createEventWrapper} > - Create an announcement - - + navigation.navigate("EventCreation" as never, {isAnnouncement: true})} style={styles.createEventWrapper} > + Create an announcement + + + Date: Wed, 29 May 2024 16:22:03 +0200 Subject: [PATCH 04/20] fix: resolved conflicts --- screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx index 1f79e3ac..cf8d8ca2 100644 --- a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx +++ b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx @@ -20,7 +20,6 @@ import { getUserData } from "../../../firebase/User" import { globalStyles } from "../../../assets/global/globalStyles" import { Ionicons } from "@expo/vector-icons" import { useNavigation } from "@react-navigation/native" -import InputField from "../../../components/InputField/InputField" interface AnnouncementsScreenProps { onAnnouncementPress: (announcement: Announcement) => void From 268dcd1f24412441149ed4a2052ab79bc781ef95 Mon Sep 17 00:00:00 2001 From: Wepo Date: Wed, 29 May 2024 16:59:50 +0200 Subject: [PATCH 05/20] test: fix some tests --- .../InterestsScreen/InterestsScreen.test.tsx | 6 ++--- .../AnnouncementScreen/AnnouncementScreen.tsx | 27 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/__test__/screens/Registration/InterestsScreen/InterestsScreen.test.tsx b/__test__/screens/Registration/InterestsScreen/InterestsScreen.test.tsx index 74fae5c6..b2a3ddf3 100644 --- a/__test__/screens/Registration/InterestsScreen/InterestsScreen.test.tsx +++ b/__test__/screens/Registration/InterestsScreen/InterestsScreen.test.tsx @@ -43,8 +43,8 @@ const mockNavigation = { isFocused: jest.fn().mockReturnValue(false), } -jest.mock('@react-navigation/native', () => { - const actualNav = jest.requireActual('@react-navigation/native') +jest.mock("@react-navigation/native", () => { + const actualNav = jest.requireActual("@react-navigation/native") return { ...actualNav, useNavigation: () => mockNavigation, @@ -73,7 +73,7 @@ describe("InterestsScreen", () => { ) await waitFor(() => { - expect(getByPlaceholderText("Search")).toBeTruthy() + expect(getByPlaceholderText("Search...")).toBeTruthy() const interestButtons = getAllByText(/.+/) expect(interestButtons.length).toBeGreaterThan(0) }) diff --git a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx index cf8d8ca2..2740207c 100644 --- a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx +++ b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx @@ -6,7 +6,7 @@ import { SectionListRenderItemInfo, TouchableOpacity, Pressable, - TextInput, + } from "react-native" import { styles } from "./styles" // Ensure the paths are correct import AnnouncementCard from "../../../components/AnnoucementCard/AnnouncementCard" @@ -20,6 +20,7 @@ import { getUserData } from "../../../firebase/User" import { globalStyles } from "../../../assets/global/globalStyles" import { Ionicons } from "@expo/vector-icons" import { useNavigation } from "@react-navigation/native" +import InputField from "../../../components/InputField/InputField" interface AnnouncementsScreenProps { onAnnouncementPress: (announcement: Announcement) => void @@ -110,7 +111,7 @@ const AnnouncementScreen = ({ })) } - const recomm = announcements + const recomm = announcements .map((announcement) => ({ announcement, recommended: @@ -123,8 +124,8 @@ const AnnouncementScreen = ({ if (a.recommended && !b.recommended) return -1 return 0 }) - console.log(recomm) - return recomm + console.log(recomm) + return recomm } const sections = [ @@ -163,18 +164,26 @@ const AnnouncementScreen = ({ return ( - - navigation.navigate("EventCreation" as never, {isAnnouncement: true})} style={styles.createEventWrapper} > - Create an announcement + + navigation.navigate("EventCreation" as never, { + isAnnouncement: true, + }) + } + style={styles.createEventWrapper} + > + + Create an announcement + - + Date: Wed, 29 May 2024 17:13:56 +0200 Subject: [PATCH 06/20] feat: added the selected announcement's interest on announcement creation screen --- screens/EventCreation/EventCreationScreen.tsx | 13 ++++++++++--- .../AnnouncementScreen/AnnouncementScreen.tsx | 1 - 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/screens/EventCreation/EventCreationScreen.tsx b/screens/EventCreation/EventCreationScreen.tsx index c08855c5..63e584d8 100644 --- a/screens/EventCreation/EventCreationScreen.tsx +++ b/screens/EventCreation/EventCreationScreen.tsx @@ -154,9 +154,16 @@ const EventCreationScreen = ({ navigation }: EventCreationScreenProps) => { )} {selectedInterests?.length !== 0 && ( - - Interests selected! - + <> + + Interests selected! + + {selectedInterests.map((interest, index) => ( + + {interest} + + ))} + )} diff --git a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx index 2740207c..eb5cd26a 100644 --- a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx +++ b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx @@ -124,7 +124,6 @@ const AnnouncementScreen = ({ if (a.recommended && !b.recommended) return -1 return 0 }) - console.log(recomm) return recomm } From 11aa2d5e72f70230629f5b738a959cd7d467f1a7 Mon Sep 17 00:00:00 2001 From: Wepo Date: Wed, 29 May 2024 17:38:07 +0200 Subject: [PATCH 07/20] feat: display of the selected interests --- screens/EventCreation/EventCreationScreen.tsx | 10 +++++----- screens/EventCreation/styles.ts | 18 +++++++++++++++--- .../AnnouncementScreen/AnnouncementScreen.tsx | 1 - screens/Explore/AnnouncementScreen/styles.ts | 8 +++----- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/screens/EventCreation/EventCreationScreen.tsx b/screens/EventCreation/EventCreationScreen.tsx index 63e584d8..019259d0 100644 --- a/screens/EventCreation/EventCreationScreen.tsx +++ b/screens/EventCreation/EventCreationScreen.tsx @@ -155,15 +155,15 @@ const EventCreationScreen = ({ navigation }: EventCreationScreenProps) => { {selectedInterests?.length !== 0 && ( <> + Interests selected! - {selectedInterests.map((interest, index) => ( - - {interest} + + {selectedInterests.join(" - ")} - ))} - + + )} diff --git a/screens/EventCreation/styles.ts b/screens/EventCreation/styles.ts index 7d936532..e49d458a 100644 --- a/screens/EventCreation/styles.ts +++ b/screens/EventCreation/styles.ts @@ -80,6 +80,17 @@ export const styles = StyleSheet.create({ paddingHorizontal: 30, width: "100%", }, + interests: { + color: black, + fontSize: 12, + fontStyle: "italic", + marginLeft: 13, + paddingBottom: 5, + }, + + interestsContainer: { + flexDirection: "column", + }, label: { color: black, display: "flex", @@ -91,7 +102,6 @@ export const styles = StyleSheet.create({ mandatoryInput: { flexDirection: "row", }, - section: { display: "flex", flexDirection: "column", @@ -101,11 +111,13 @@ export const styles = StyleSheet.create({ paddingTop: 10, width: "100%", }, + tags: { flexDirection: "row", justifyContent: "space-between", marginBottom: 10, }, + tagsSeparator: { borderBottomColor: black, borderBottomWidth: 1, @@ -114,6 +126,6 @@ export const styles = StyleSheet.create({ tagsTitle: { color: black, marginBottom: 10, - padding: 10, + paddingTop: 7, }, -}) \ No newline at end of file +}) diff --git a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx index eb5cd26a..efb96155 100644 --- a/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx +++ b/screens/Explore/AnnouncementScreen/AnnouncementScreen.tsx @@ -95,7 +95,6 @@ const AnnouncementScreen = ({ recommendAnnouncements(searchedAnnouncement) setFilteredAnnouncements(recommendedAnnouncements) } else { - console.log(userData?.selectedInterests) setFilteredAnnouncements(recommendAnnouncements(announcements)) } diff --git a/screens/Explore/AnnouncementScreen/styles.ts b/screens/Explore/AnnouncementScreen/styles.ts index c618dc3c..d71ec524 100644 --- a/screens/Explore/AnnouncementScreen/styles.ts +++ b/screens/Explore/AnnouncementScreen/styles.ts @@ -18,10 +18,7 @@ export const styles = StyleSheet.create({ }, createEventWrapper: { - alignItems: "center", - flexDirection: "row", - justifyContent: "center", - + justifyContent: "center" }, input: { borderColor: lightGray, @@ -32,6 +29,7 @@ export const styles = StyleSheet.create({ paddingHorizontal: 20, width: "57%", }, + searchAndMap: { alignItems: "center", flexDirection: "row", @@ -47,5 +45,5 @@ export const styles = StyleSheet.create({ }, view: { flex: 1, - }, + } }) From 45c7e92ef296ae8c79919438ee854b84aaddccf1 Mon Sep 17 00:00:00 2001 From: Wepo Date: Wed, 29 May 2024 18:11:07 +0200 Subject: [PATCH 08/20] test: fixed test --- .../EventCreation/EventCreationScreeen.test.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/__test__/screens/EventCreation/EventCreationScreeen.test.tsx b/__test__/screens/EventCreation/EventCreationScreeen.test.tsx index 22b6e1d1..3bbd2593 100644 --- a/__test__/screens/EventCreation/EventCreationScreeen.test.tsx +++ b/__test__/screens/EventCreation/EventCreationScreeen.test.tsx @@ -24,6 +24,7 @@ const mockNavigation = { canGoBack: jest.fn(), dangerouslyGetParent: jest.fn(), dangerouslyGetState: jest.fn(), + selectedInterests: jest.fn(), } as unknown as NavigationProp jest.mock("firebase/auth", () => ({ @@ -42,6 +43,18 @@ jest.mock("firebase/firestore", () => { } }) +//added after interests rendering +jest.mock("react", () => ({ + ...jest.requireActual("react"), + useContext: () => ({ + selectedInterests: jest.fn(), + description: jest.fn(), + setDescription: jest.fn(), + setSelectedInterests: jest.fn(), + }), +})) + + jest.mock("@react-navigation/native", () => { return { ...jest.requireActual("@react-navigation/native"), From 5152920be2d635c87a3aef0fb31e5fd1b92d0446 Mon Sep 17 00:00:00 2001 From: Wepo Date: Sat, 1 Jun 2024 15:07:58 +0200 Subject: [PATCH 09/20] test: achieved coverage --- __test__/screens/Explore/EventScreen.test.tsx | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/__test__/screens/Explore/EventScreen.test.tsx b/__test__/screens/Explore/EventScreen.test.tsx index de1377bb..0a5e720b 100644 --- a/__test__/screens/Explore/EventScreen.test.tsx +++ b/__test__/screens/Explore/EventScreen.test.tsx @@ -1,10 +1,11 @@ -import { render } from '@testing-library/react-native' +import { render, waitFor } from '@testing-library/react-native' import EventScreen from '../../../screens/Explore/EventScreen/EventScreen' import { SafeAreaProvider } from 'react-native-safe-area-context' import React from 'react' import { Firestore } from 'firebase/firestore' import { NavigationContainer, NavigationProp, ParamListBase } from '@react-navigation/native' +import { showErrorToast } from '../../../components/ToastMessage/toast' jest.mock("../../../firebase/firebaseConfig", () => ({ @@ -62,14 +63,47 @@ describe('EventScreen', () => { it('refresh', async () => { - const { debug } = render( + const { getByText } = render( { }} userID='123' /> ) - debug() + await waitFor (() => { + expect(getByText('Upcoming Events')).toBeTruthy() + }) }) }) + +///Test for no events + +jest.mock('../../../firebase/ManageEvents', () => ({ + getAllFutureEvents: jest.fn(() => Promise.resolve([ + ])), + getAllPastEvents: jest.fn(() => Promise.resolve([ + ])) +})) +jest.mock("../../../components/ToastMessage/toast", () => ({ + showErrorToast: jest.fn(), + showSuccessToast: jest.fn(), +})) + +describe('EventScreenNoEvents', () => { + + it('refresh', async () => { + + render( + + + { }} userID='123' /> + + + ) + await waitFor (() => { + expect(showErrorToast).toHaveBeenCalledWith("Error fetching user data. Please check your connection and try again.") + }) + }) + +}) \ No newline at end of file From e1a23e765bf0009edacbf0393c8c7e549b0ffda3 Mon Sep 17 00:00:00 2001 From: Wepo Date: Sat, 1 Jun 2024 15:29:03 +0200 Subject: [PATCH 10/20] test: fix --- __test__/screens/Explore/EventScreen.test.tsx | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/__test__/screens/Explore/EventScreen.test.tsx b/__test__/screens/Explore/EventScreen.test.tsx index 0a5e720b..e03bdb19 100644 --- a/__test__/screens/Explore/EventScreen.test.tsx +++ b/__test__/screens/Explore/EventScreen.test.tsx @@ -1,7 +1,6 @@ -import { render, waitFor } from '@testing-library/react-native' +import { fireEvent, render, waitFor } from '@testing-library/react-native' import EventScreen from '../../../screens/Explore/EventScreen/EventScreen' -import { SafeAreaProvider } from 'react-native-safe-area-context' import React from 'react' import { Firestore } from 'firebase/firestore' import { NavigationContainer, NavigationProp, ParamListBase } from '@react-navigation/native' @@ -43,7 +42,9 @@ const mockNavigation = { jest.mock('@react-navigation/native', () => { return { ...jest.requireActual('@react-navigation/native'), // keep all the original implementations - useNavigation: () => mockNavigation, + useNavigation: () => ({ + navigate: mockNavigation.navigate, + }), } }) @@ -65,13 +66,14 @@ describe('EventScreen', () => { const { getByText } = render( - + { }} userID='123' /> - + ) await waitFor (() => { expect(getByText('Upcoming Events')).toBeTruthy() + }) }) @@ -92,13 +94,13 @@ jest.mock("../../../components/ToastMessage/toast", () => ({ describe('EventScreenNoEvents', () => { - it('refresh', async () => { + it('check Errors', async () => { render( - + { }} userID='123' /> - + ) await waitFor (() => { @@ -106,4 +108,19 @@ describe('EventScreenNoEvents', () => { }) }) + it('check Errors', async () => { + + const {getByText}= render( + + + { }} userID='123' /> + + + ) + await waitFor (() => { + fireEvent.press(getByText('Create an event')) + expect(mockNavigation.navigate).toHaveBeenCalled + }) +}) + }) \ No newline at end of file From fd250a7efcf8722ee41beedced0bf658b371d0b0 Mon Sep 17 00:00:00 2001 From: Wepo Date: Sat, 1 Jun 2024 15:40:52 +0200 Subject: [PATCH 11/20] test: fixed --- __test__/screens/Explore/EventScreen.test.tsx | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/__test__/screens/Explore/EventScreen.test.tsx b/__test__/screens/Explore/EventScreen.test.tsx index e03bdb19..31306029 100644 --- a/__test__/screens/Explore/EventScreen.test.tsx +++ b/__test__/screens/Explore/EventScreen.test.tsx @@ -48,6 +48,35 @@ jest.mock('@react-navigation/native', () => { } }) +export type User = { + uid: string + email: string + firstName: string + friends: string[] + lastName: string + date: Date + description: string + location: string + selectedInterests: string[] + profilePicture: string + events: string[] +} +jest.mock('../../../firebase/User.ts', () => ({ + getUserData: jest.fn(() => Promise.resolve({ + uid: "1234", + email: "test", + firstName: "alex", + lastName: "doe", + friends: [], + date: new Date(), + description: "test description", + location: "test location", + selectedInterests: [], + profilePicture: "test.jpg", + events: [] + })) +})) + jest.mock('../../../firebase/ManageEvents', () => ({ getAllFutureEvents: jest.fn(() => Promise.resolve([ { id: '1', title: 'Future Event 1', date: '2024-01-01' }, @@ -60,6 +89,8 @@ jest.mock('../../../firebase/ManageEvents', () => ({ ])) })) + + describe('EventScreen', () => { it('refresh', async () => { @@ -104,7 +135,7 @@ describe('EventScreenNoEvents', () => { ) await waitFor (() => { - expect(showErrorToast).toHaveBeenCalledWith("Error fetching user data. Please check your connection and try again.") + expect(showErrorToast).toHaveBeenCalledWith("You have no events yet.") }) }) From d9e7381741979a230983a162f0130a5e8934269a Mon Sep 17 00:00:00 2001 From: Wepo Date: Sun, 2 Jun 2024 11:59:39 +0200 Subject: [PATCH 12/20] fix: solved issue rendering user events on external profile --- __test__/screens/Explore/EventScreen.test.tsx | 1 + .../screens/Profile/ProfileEvents/ProfileEvents.test.tsx | 8 ++++++-- .../ExternalProfileScreen/ExternalProfileScreen.tsx | 2 +- screens/Profile/MyProfileScreen/MyProfileScreen.tsx | 2 +- screens/Profile/ProfileEvents/ProfileEvents.tsx | 4 +--- screens/Profile/ProfileInterests/ProfileInterests.tsx | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/__test__/screens/Explore/EventScreen.test.tsx b/__test__/screens/Explore/EventScreen.test.tsx index 31306029..91f72645 100644 --- a/__test__/screens/Explore/EventScreen.test.tsx +++ b/__test__/screens/Explore/EventScreen.test.tsx @@ -104,6 +104,7 @@ describe('EventScreen', () => { ) await waitFor (() => { expect(getByText('Upcoming Events')).toBeTruthy() + expect(getByText('Past Events')).toBeTruthy() }) }) diff --git a/__test__/screens/Profile/ProfileEvents/ProfileEvents.test.tsx b/__test__/screens/Profile/ProfileEvents/ProfileEvents.test.tsx index 27a7dbcc..4de863fa 100644 --- a/__test__/screens/Profile/ProfileEvents/ProfileEvents.test.tsx +++ b/__test__/screens/Profile/ProfileEvents/ProfileEvents.test.tsx @@ -62,9 +62,11 @@ describe("ProfileEvents", () => { }) it("renders EventScreen with userID", async () => { + const userID : string = "123" + const { getByText } = render( - + ) await waitFor(() => { @@ -73,9 +75,11 @@ describe("ProfileEvents", () => { }) it("navigates to ViewEvent when an event is pressed", async () => { + const userID = "123" + const { getByText } = render( - + ) diff --git a/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx b/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx index f8634c83..9b1b95bb 100644 --- a/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx +++ b/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx @@ -157,7 +157,7 @@ const ExternalProfileScreen = () => { - {selectedTab === "Events" && } + {selectedTab === "Events" && } {selectedTab === "Interests" && ( )} diff --git a/screens/Profile/MyProfileScreen/MyProfileScreen.tsx b/screens/Profile/MyProfileScreen/MyProfileScreen.tsx index 42d5682f..ceec5b30 100644 --- a/screens/Profile/MyProfileScreen/MyProfileScreen.tsx +++ b/screens/Profile/MyProfileScreen/MyProfileScreen.tsx @@ -88,7 +88,7 @@ export const MyProfileScreen = ({ navigation }: MyProfileScreenProps) => { onTabChange={setSelectedTab} /> - {selectedTab === "Events" && } + {selectedTab === "Events" && } {selectedTab === "Interests" && } diff --git a/screens/Profile/ProfileEvents/ProfileEvents.tsx b/screens/Profile/ProfileEvents/ProfileEvents.tsx index e2544ae6..258afdbc 100644 --- a/screens/Profile/ProfileEvents/ProfileEvents.tsx +++ b/screens/Profile/ProfileEvents/ProfileEvents.tsx @@ -1,13 +1,11 @@ import { View } from "react-native" import { styles } from "./styles" import React from "react" -import { getAuth } from "firebase/auth" import EventScreen from "../../Explore/EventScreen/EventScreen" import { useNavigation } from "@react-navigation/native" import { User } from "../../../types/User" -export const ProfileEvents = () => { - const userId = getAuth().currentUser?.uid +export const ProfileEvents = (userId: string ) => { const navigation = useNavigation() const onHostPress = (host: User) => { diff --git a/screens/Profile/ProfileInterests/ProfileInterests.tsx b/screens/Profile/ProfileInterests/ProfileInterests.tsx index c7b81c81..1bec2a46 100644 --- a/screens/Profile/ProfileInterests/ProfileInterests.tsx +++ b/screens/Profile/ProfileInterests/ProfileInterests.tsx @@ -14,7 +14,7 @@ const Interest = ({ interest }: { interest: string }) => ( ) -export const ProfileInterests = ({ user }: ProfileInterestsProps) => { +export const xProfileInterests = ({ user }: ProfileInterestsProps) => { return ( Date: Sun, 2 Jun 2024 11:59:56 +0200 Subject: [PATCH 13/20] test: added end-to-end test --- __test__/end-to-end/app-end-to-end.yaml | 16 +++++++++++ __test__/end-to-end/app-presentation.yaml | 4 +-- __test__/end-to-end/login-test.yaml | 9 ++++-- __test__/end-to-end/registration-test.yaml | 32 ---------------------- __test__/end-to-end/registrationM4.yaml | 14 +++++----- 5 files changed, 31 insertions(+), 44 deletions(-) create mode 100644 __test__/end-to-end/app-end-to-end.yaml delete mode 100644 __test__/end-to-end/registration-test.yaml diff --git a/__test__/end-to-end/app-end-to-end.yaml b/__test__/end-to-end/app-end-to-end.yaml new file mode 100644 index 00000000..e325b6ff --- /dev/null +++ b/__test__/end-to-end/app-end-to-end.yaml @@ -0,0 +1,16 @@ +# flow.yaml + + +appId: com.epfl. +# need to have a connected user +--- +- launchApp: + clearState: true +- tapOn: "Username or email" +- inputText: "email@oui.com" +- tapOn: "Password" +- inputText: "VeryHard6_" +- tapOn : "Log In" +- tapOn: + point: "50%,25%" + diff --git a/__test__/end-to-end/app-presentation.yaml b/__test__/end-to-end/app-presentation.yaml index 7ff188a3..e7643748 100644 --- a/__test__/end-to-end/app-presentation.yaml +++ b/__test__/end-to-end/app-presentation.yaml @@ -1,7 +1,7 @@ # flow.yaml -#replace by the right appId -appId: com.alexandremrt.uniconnect + +appId: com.epfl.uniconnect # need to have a connected user --- - launchApp diff --git a/__test__/end-to-end/login-test.yaml b/__test__/end-to-end/login-test.yaml index d9dfc91e..7565a504 100644 --- a/__test__/end-to-end/login-test.yaml +++ b/__test__/end-to-end/login-test.yaml @@ -1,15 +1,18 @@ # flow.yaml #replace by the right appId -appId: com.alexandremrt.uniconnect +appId: com.epfl.uniconnect # need to run registrationM4 before --- -- launchApp +- launchApp: + clearState: true + - tapOn: "Username or email" - inputText: "email@oui.com" - tapOn: "Password" - inputText: "VeryHard6_" +- tapOn : "Log In" - tapOn: - id: "login-btn" + point: "50%,25%" diff --git a/__test__/end-to-end/registration-test.yaml b/__test__/end-to-end/registration-test.yaml deleted file mode 100644 index 2b2ed7cc..00000000 --- a/__test__/end-to-end/registration-test.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# flow.yaml - -#replace by the right appId -appId: com.alexandremrt.uniconnect ---- -- launchApp -- startRecording: recording -- tapOn: "Dont have an account?" -- tapOn: "First name" -- inputText: "Alex" -- tapOn: "Last name" -- inputText: "Mourot" -- tapOn: "Date of birth" -- inputText: "01/01/1990" -- tapOn: "Location" -- inputText: "Paris" - -- tapOn: "Add a description now" -- inputText: "I am a software engineer" -- hideKeyboard - -- tapOn: "Next" - -- tapOn: "Machine Learning" -- tapOn: "NLP" -- tapOn: "Search" -- inputText: "Ass" -- tapOn: "Assembly" -- tapOn: "Next" - - -- stopRecording \ No newline at end of file diff --git a/__test__/end-to-end/registrationM4.yaml b/__test__/end-to-end/registrationM4.yaml index 00f75ae5..2c724d17 100644 --- a/__test__/end-to-end/registrationM4.yaml +++ b/__test__/end-to-end/registrationM4.yaml @@ -1,10 +1,10 @@ - # flow.yaml #replace by the right appId -appId: com.alexandremrt.uniconnect +appId: com.epfl.uniconnect --- -- launchApp +- launchApp: + clearState: true - startRecording: recording - tapOn: "Dont have an account?" - tapOn: "First name" @@ -29,13 +29,13 @@ appId: com.alexandremrt.uniconnect - tapOn: "Writing" - tapOn: "Next" - tapOn: "****************" -- inputText: "VeryHard6_" +- inputText: "VeryHard7_" - tapOn: "****************" -- inputText: "VeryHard6_" +- inputText: "VeryHard7_" - tapOn: "E-mail" -- inputText: "email@oui.com" +- inputText: "emaill@oui.com" - tapOn: "Confirm your e-mail" -- inputText: "email@oui.com" +- inputText: "emaill@oui.com" - "hideKeyboard" - tapOn: "Confirm" - tapOn: "Not now" From 5bcd12301fbc608f9bba5e5168ddf9767db214ff Mon Sep 17 00:00:00 2001 From: Wepo Date: Sun, 2 Jun 2024 12:17:42 +0200 Subject: [PATCH 14/20] fix: typo ProfileInterest name --- __test__/screens/Explore/EventScreen.test.tsx | 2 -- screens/Profile/ProfileInterests/ProfileInterests.tsx | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/__test__/screens/Explore/EventScreen.test.tsx b/__test__/screens/Explore/EventScreen.test.tsx index d9eb3fd9..05afb27a 100644 --- a/__test__/screens/Explore/EventScreen.test.tsx +++ b/__test__/screens/Explore/EventScreen.test.tsx @@ -120,8 +120,6 @@ describe('EventScreen', () => { { }} userID='123' /> - - ) await waitFor (() => { diff --git a/screens/Profile/ProfileInterests/ProfileInterests.tsx b/screens/Profile/ProfileInterests/ProfileInterests.tsx index 1bec2a46..c7b81c81 100644 --- a/screens/Profile/ProfileInterests/ProfileInterests.tsx +++ b/screens/Profile/ProfileInterests/ProfileInterests.tsx @@ -14,7 +14,7 @@ const Interest = ({ interest }: { interest: string }) => ( ) -export const xProfileInterests = ({ user }: ProfileInterestsProps) => { +export const ProfileInterests = ({ user }: ProfileInterestsProps) => { return ( Date: Sun, 2 Jun 2024 18:18:33 +0200 Subject: [PATCH 15/20] feat: fixed profileEvent Rendering --- screens/Explore/EventScreen/EventScreen.tsx | 7 +++++-- .../ExternalProfileScreen/ExternalProfileScreen.tsx | 2 +- screens/Profile/MyProfileScreen/MyProfileScreen.tsx | 2 +- screens/Profile/ProfileEvents/ProfileEvents.tsx | 5 ++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/screens/Explore/EventScreen/EventScreen.tsx b/screens/Explore/EventScreen/EventScreen.tsx index 784d06c8..df9bcb6c 100644 --- a/screens/Explore/EventScreen/EventScreen.tsx +++ b/screens/Explore/EventScreen/EventScreen.tsx @@ -39,6 +39,7 @@ type RootStackParamList = { } const EventScreen = ({ onEventPress, userID }: EventsScreenProps) => { + const navigation = useNavigation>() const [futureEvents, setFutureEvents] = React.useState([]) const [pastEvents, setPastEvents] = React.useState([]) @@ -61,7 +62,9 @@ const EventScreen = ({ onEventPress, userID }: EventsScreenProps) => { try { setLoading(true) if (userID) { + const userData = await getUserData(userID) + if (userData) { const userEvents = userData.events const fetchedFutureEvents = await getAllFutureEvents() @@ -77,8 +80,8 @@ const EventScreen = ({ onEventPress, userID }: EventsScreenProps) => { setFutureEvents(userFutureEvents) setPastEvents(userPastEvents) - setFilteredFutureEvents(userFutureEvents) - setFilteredPastEvents(userPastEvents) + setFilteredFutureEvents(userFutureEvents) + setFilteredPastEvents(userPastEvents) if (userFutureEvents.length === 0 && userPastEvents.length === 0) { showErrorToast("You have no events yet.") } diff --git a/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx b/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx index 5f28ae3c..dc32eb05 100644 --- a/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx +++ b/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx @@ -158,7 +158,7 @@ const ExternalProfileScreen = () => { - {selectedTab === "Events" && } + {selectedTab === "Events" && } {selectedTab === "Interests" && ( )} diff --git a/screens/Profile/MyProfileScreen/MyProfileScreen.tsx b/screens/Profile/MyProfileScreen/MyProfileScreen.tsx index ceec5b30..10893c98 100644 --- a/screens/Profile/MyProfileScreen/MyProfileScreen.tsx +++ b/screens/Profile/MyProfileScreen/MyProfileScreen.tsx @@ -88,7 +88,7 @@ export const MyProfileScreen = ({ navigation }: MyProfileScreenProps) => { onTabChange={setSelectedTab} /> - {selectedTab === "Events" && } + {selectedTab === "Events" && } {selectedTab === "Interests" && } diff --git a/screens/Profile/ProfileEvents/ProfileEvents.tsx b/screens/Profile/ProfileEvents/ProfileEvents.tsx index 258afdbc..e236b348 100644 --- a/screens/Profile/ProfileEvents/ProfileEvents.tsx +++ b/screens/Profile/ProfileEvents/ProfileEvents.tsx @@ -5,7 +5,10 @@ import EventScreen from "../../Explore/EventScreen/EventScreen" import { useNavigation } from "@react-navigation/native" import { User } from "../../../types/User" -export const ProfileEvents = (userId: string ) => { +interface ProfileEventsProps { + userId: string +} +export const ProfileEvents = ({userId}: ProfileEventsProps ) => { const navigation = useNavigation() const onHostPress = (host: User) => { From 77489204de9c59d89b51012f2c43378a6d0d42d2 Mon Sep 17 00:00:00 2001 From: Wepo Date: Sun, 2 Jun 2024 19:07:49 +0200 Subject: [PATCH 16/20] test: end to end --- __test__/end-to-end/app-end-to-end.yaml | 88 +++++++++++++- screens/Network/mockContacts.tsx | 153 ------------------------ 2 files changed, 86 insertions(+), 155 deletions(-) delete mode 100644 screens/Network/mockContacts.tsx diff --git a/__test__/end-to-end/app-end-to-end.yaml b/__test__/end-to-end/app-end-to-end.yaml index e325b6ff..7cb07c69 100644 --- a/__test__/end-to-end/app-end-to-end.yaml +++ b/__test__/end-to-end/app-end-to-end.yaml @@ -1,7 +1,7 @@ # flow.yaml -appId: com.epfl. +appId: com.epfl.uniconnect # need to have a connected user --- - launchApp: @@ -10,7 +10,91 @@ appId: com.epfl. - inputText: "email@oui.com" - tapOn: "Password" - inputText: "VeryHard6_" -- tapOn : "Log In" +- tapOn: "Log In" - tapOn: point: "50%,25%" +- tapOn: "Search..." +- inputText: "Pedro" +- tapOn: + point: "92%,91%" +- tapOn: "Interests" +- tapOn: "Events" +- tapOn: + id: "event-card-Book Club Meeting" +- tapOn: + id: "back-arrow" +- tapOn: + id: "back-arrow" +- tapOn: ", Explore" +- tapOn: "Music and Arts Festival" +- tapOn: "Participate" +- tapOn: + id: "back-arrow" +- tapOn: "Map View" +- tapOn: + id: "back-arrow" +- tapOn: "Announcements" +- tapOn: "Create an announcement" +- tapOn: "Chemistry x Python" +- inputText: "test Demo" +- tapOn: + point: "17%,33%" +- tapOn: "Photography" +- tapOn: + id: "WritingID" +- tapOn: "Search" +- inputText: "Gardening" +- "hideKeyboard" +- tapOn: + text: "Gardening" + index: 1 +- tapOn: "Add a location" +- tapOn: + point: "50%,53%" +- tapOn: "Confirm" +- tapOn: "Validate" +- tapOn: "Events" +- tapOn: "Music and Arts Festival" +- tapOn: "Withdraw" +- tapOn: + id: "back-arrow" +- tapOn: "Create an event" +- tapOn: + id: "back-arrow" +- tapOn: + point: "50%,93%" +- tapOn: ", Network" +- tapOn: "List" +- tapOn: "Gaël Conditos " +- tapOn: "Interests" +- tapOn: "Events" +- tapOn: + id: "back-arrow" +- tapOn: + id: "profile-button" +- tapOn: ", QR" +- tapOn: + id: "back-arrow" +- tapOn: "Map View" +- tapOn: + id: "back-arrow" +- tapOn: "Update" +- tapOn: "Enter your description here" +- tapOn: + text: "magnifiqueDemo" + index: 0 +- tapOn: + id: "com.google.android.inputmethod.latin:id/0_resource_name_obfuscated" + index: 48 +- tapOn: "Done" +- tapOn: + id: "back-button" +- tapOn: + id: "back-arrow" +- tapOn: + id: "settings-button" +- tapOn: "ABOUT" +- tapOn: + id: "back-arrow" +- tapOn: "LOG OUT" diff --git a/screens/Network/mockContacts.tsx b/screens/Network/mockContacts.tsx deleted file mode 100644 index fabaac78..00000000 --- a/screens/Network/mockContacts.tsx +++ /dev/null @@ -1,153 +0,0 @@ -import { Contact } from "../../types/Contact" - -const contact_1: Contact = { - uid: "0", - firstName: "Alice", - lastName: "Smith", - profilePictureUrl: - "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSoQ2C2f7eqsQvU6_T183x8ASGJv7mqJ2xy_KLDIZOJsA&s", - description: - "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed fermentum justo id nisl commodo, sit amet viverra massa convallis.", - location: "Los Angeles", - interests: ["1", "2"], - events: ["1", "2"], - friends: ["1", "2", "7", "8"], -} - -const contact_2: Contact = { - uid: "1", - firstName: "Bob", - lastName: "Johnson", - profilePictureUrl: - "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTYloKopOZ_oudmWTNK-xVmdVPxdKsgKniHbr8Vr0hk1g&s", - description: - "Nulla euismod ex at magna consequat, eget venenatis risus maximus.", - location: "Chicago", - interests: ["1", "2"], - events: ["1", "2"], - friends: ["3", "4"], -} - -const contact_3: Contact = { - uid: "2", - firstName: "Carol", - lastName: "Williams", - profilePictureUrl: - "https://img.fixthephoto.com/blog/images/gallery/news_preview_mob_image__preview_11368.png", - description: - "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", - location: "Houston", - interests: ["1", "2"], - events: ["1", "2"], - friends: ["4", "5", "6", "9"], -} - -const contact_4: Contact = { - uid: "3", - firstName: "David", - lastName: "Brown", - profilePictureUrl: - "https://img.freepik.com/premium-photo/profile-picture-happy-young-caucasian-man-spectacles-show-confidence-leadership-headshot-portrait-smiling-millennial-male-glasses-posing-indoors-home-employment-success-concept_774935-1446.jpg", - description: - "Vivamus non odio nec quam sollicitudin volutpat. Cras ullamcorper vehicula consequat.", - location: "Miami", - interests: ["1", "2"], - events: ["1", "2"], - friends: ["1"], -} - -const contact_5: Contact = { - uid: "4", - firstName: "Eva", - lastName: "Davis", - profilePictureUrl: - "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSwzqBOQU8-rmsHcEGZ1imKdw5fefN4G0gkyZdM6ydMNg&s", - description: - "Suspendisse potenti. Nullam dictum, velit a eleifend convallis, nibh turpis aliquam neque, a dictum urna orci quis dolor.", - location: "San Francisco", - interests: ["1", "2", "7", "8", "9", "10", "11"], - events: ["1", "2", "11", "12"], - friends: ["1", "2"], -} - -const contact_6: Contact = { - uid: "5", - firstName: "Frank", - lastName: "Wilson", - profilePictureUrl: - "https://t3.ftcdn.net/jpg/03/62/40/80/360_F_362408093_AlwyWJQbyc6edRlXGaGz3xquwzLGXhkX.jpg", - description: - "Donec tempus quam vitae felis ullamcorper, eget fringilla nulla commodo.", - location: "Seattle", - interests: ["1", "2", "7", "8", "9"], - events: ["1", "2", "7", "8"], - friends: ["2"], -} - -const contact_7: Contact = { - uid: "6", - firstName: "Grace", - lastName: "Martinez", - profilePictureUrl: - "https://media.licdn.com/dms/image/C5603AQG5Ex3k-bgPLw/profile-displayphoto-shrink_400_400/0/1621833595761?e=2147483647&v=beta&t=y2rONxfxxg-yKW5D1LqzHoeHFu7p_E3R6kHgTxcv0pc", - description: "Praesent eleifend dapibus odio, nec commodo est aliquet vitae.", - location: "Dallas", - interests: ["1", "2", "7", "8"], - events: ["1", "2", "7", "8"], - friends: ["2"], -} - -const contact_8: Contact = { - uid: "7", - firstName: "Henry", - lastName: "Taylor", - profilePictureUrl: - "https://mdbcdn.b-cdn.net/img/Photos/new-templates/bootstrap-profiles/avatar-1.webp", - description: - "Fusce rhoncus nunc eu arcu feugiat tincidunt. Proin vulputate tellus ac fermentum bibendum.", - location: "Atlanta", - interests: ["17", "18"], - events: [], - friends: ["0"], -} - -const contact_9: Contact = { - uid: "8", - firstName: "Isabella", - lastName: "Rodriguez", - profilePictureUrl: - "https://i.pinimg.com/236x/da/fd/f2/dafdf25168edcb2f0e1d8702797946cc.jpg", - description: - "Integer vel ultricies lorem. Curabitur sit amet quam non nisl eleifend convallis at non elit.", - location: "Phoenix", - interests: ["1"], - events: ["1"], - friends: ["0"], -} - -const contact_10: Contact = { - uid: "9", - firstName: "Jack", - lastName: "Garcia", - profilePictureUrl: - "https://headshots-inc.com/wp-content/uploads/2021/01/FINAL-Blog-Images.jpg", - description: - "Nam nec ullamcorper libero. Vestibulum in turpis in nunc fringilla pharetra.", - location: "Denver", - interests: ["1", "2"], - events: ["1", "78", "9", "10"], - friends: ["2"], -} - -export const mockContacts: Contact[] = [ - contact_1, - contact_2, - contact_3, - contact_4, - contact_5, - contact_6, - contact_7, - contact_8, - contact_9, - contact_10, -] From 6fc338759f6bf755f86de01c4c979ce2d1e3a367 Mon Sep 17 00:00:00 2001 From: Wepo Date: Sun, 2 Jun 2024 19:26:34 +0200 Subject: [PATCH 17/20] fix: dummy screen removed --- .../Notification/NotificationTest.test.tsx | 49 ---------- __test__/end-to-end/app-end-to-end.yaml | 3 +- .../NotificationsScreen.test.tsx | 94 ------------------- .../screens/Settings/SettingsScreen.test.tsx | 2 +- navigation/Main/MainStackNavigator.tsx | 7 +- .../NotificationsScreen.tsx | 61 ------------ .../Settings/NotificationsScreen/styles.ts | 72 -------------- screens/Settings/SettingsScreen.tsx | 5 +- 8 files changed, 4 insertions(+), 289 deletions(-) delete mode 100644 __test__/components/Notification/NotificationTest.test.tsx delete mode 100644 __test__/screens/Settings/NotificationScreen/NotificationsScreen.test.tsx delete mode 100644 screens/Settings/NotificationsScreen/NotificationsScreen.tsx delete mode 100644 screens/Settings/NotificationsScreen/styles.ts diff --git a/__test__/components/Notification/NotificationTest.test.tsx b/__test__/components/Notification/NotificationTest.test.tsx deleted file mode 100644 index 861964f4..00000000 --- a/__test__/components/Notification/NotificationTest.test.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import React from "react" -import { render } from "@testing-library/react-native" -import { - Notification, - NotificationProps, -} from "../../../components/Notification/Notification" - -describe("Notification", () => { - it("renders correctly with a profile image", () => { - const props: NotificationProps = { - id: "1", - name: "John Doe", - profileImage: "https://example.com/profile.jpg", - } - - const { getByText, getByTestId } = render() - - // Check that the name and message text are rendered - expect(getByText("John Doe")).toBeTruthy() - expect(getByText("Added you as a friend")).toBeTruthy() - - // Check that the profile image is rendered - const image = getByTestId("image") - expect(image.props.source.uri).toBe("https://example.com/profile.jpg") - }) - - it("renders correctly without a profile image", () => { - const props: NotificationProps = { - id: "2", - name: "Jane Doe", - } - - const { getByText, getByTestId, queryByRole } = render( - - ) - - // Check that the name and message text are rendered - expect(getByText("Jane Doe")).toBeTruthy() - expect(getByText("Added you as a friend")).toBeTruthy() - - // Check that the profile image is not rendered - const image = queryByRole("image") - expect(image).toBeNull() - - // Check that the placeholder circle is rendered - const placeholder = getByTestId("placeholder") - expect(placeholder).toBeTruthy() - }) -}) diff --git a/__test__/end-to-end/app-end-to-end.yaml b/__test__/end-to-end/app-end-to-end.yaml index 7cb07c69..b1f220cd 100644 --- a/__test__/end-to-end/app-end-to-end.yaml +++ b/__test__/end-to-end/app-end-to-end.yaml @@ -11,8 +11,7 @@ appId: com.epfl.uniconnect - tapOn: "Password" - inputText: "VeryHard6_" - tapOn: "Log In" -- tapOn: - point: "50%,25%" +- tapOn: "Save" - tapOn: "Search..." - inputText: "Pedro" - tapOn: diff --git a/__test__/screens/Settings/NotificationScreen/NotificationsScreen.test.tsx b/__test__/screens/Settings/NotificationScreen/NotificationsScreen.test.tsx deleted file mode 100644 index 853f87a8..00000000 --- a/__test__/screens/Settings/NotificationScreen/NotificationsScreen.test.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import React from "react" -import { render, fireEvent } from "@testing-library/react-native" -import NotificationsScreen from "../../../../screens/Settings/NotificationsScreen/NotificationsScreen" -import { NavigationContainer } from "@react-navigation/native" -import { SafeAreaProvider } from "react-native-safe-area-context" - -const mockGoBack = jest.fn() - -jest.mock("react-native-safe-area-context", () => { - const inset = { top: 10, right: 0, bottom: 0, left: 0 } - return { - SafeAreaProvider: jest.fn(({ children }) => children), - SafeAreaConsumer: jest.fn(({ children }) => children(inset)), - useSafeAreaInsets: jest.fn(() => inset), - useSafeAreaFrame: jest.fn(() => ({ x: 0, y: 0, width: 390, height: 844 })), - } -}) - -jest.mock("@react-navigation/native", () => { - return { - ...jest.requireActual("@react-navigation/native"), - useNavigation: () => ({ - goBack: mockGoBack, - }), - } -}) - -describe("NotificationsScreen", () => { - it("renders correctly", () => { - const { getByText, getByPlaceholderText } = render( - - - - - - ) - - // Check that the header text is rendered - expect(getByText("Notifications")).toBeTruthy() - - // Check that the search input is rendered - expect(getByPlaceholderText("Search...")).toBeTruthy() - }) - - it("renders a list of notifications", () => { - const { getByTestId, getAllByText } = render( - - - - - - ) - - // Check that the correct number of Notification components are rendered - const flatList = getByTestId("notifications-flatlist") - expect(flatList.props.data.length).toBe(2) - - // Check that both notification names are rendered - expect(getAllByText(/Jean Dujardin|Pierre Ninet/).length).toBe(2) - }) - - it("filters notifications based on search input", () => { - const { getByPlaceholderText, getAllByText, queryByText } = render( - - - - - - ) - const searchInput = getByPlaceholderText("Search...") - - // Simulate typing into the search input - fireEvent.changeText(searchInput, "Jean") - - // Check that only the filtered notification is rendered - expect(getAllByText("Jean Dujardin").length).toBe(1) - expect(queryByText("Pierre Ninet")).toBeNull() - }) - - test("navigates back when back button is pressed", () => { - const { getByTestId } = render( - - - - - - ) - - const backButton = getByTestId("back-arrow") - fireEvent.press(backButton) - - expect(mockGoBack).toHaveBeenCalled() - }) -}) diff --git a/__test__/screens/Settings/SettingsScreen.test.tsx b/__test__/screens/Settings/SettingsScreen.test.tsx index af02b31b..7bd3503d 100644 --- a/__test__/screens/Settings/SettingsScreen.test.tsx +++ b/__test__/screens/Settings/SettingsScreen.test.tsx @@ -78,7 +78,7 @@ describe("SettingsScreen", () => { // Assert that the menu items are rendered const menuItemTexts = [ "LANGUAGE", - "NOTIFICATIONS", + "HELP", "ABOUT", "LOG OUT", diff --git a/navigation/Main/MainStackNavigator.tsx b/navigation/Main/MainStackNavigator.tsx index b2845d32..75015f3d 100644 --- a/navigation/Main/MainStackNavigator.tsx +++ b/navigation/Main/MainStackNavigator.tsx @@ -23,7 +23,6 @@ import ViewEventScreen from "../../screens/ViewDetails/ViewEventScreen/ViewEvent import ViewAnnoucementScreen from "../../screens/ViewDetails/ViewAnnouncementScreen/ViewAnnouncementScreen" import { SelectLocationScreen } from "../../screens/SelectLocation/SelectLocationScreen" import { AboutScreen } from "../../screens/Settings/AboutScreen/AboutScreen" -import NotificationsScreen from "../../screens/Settings/NotificationsScreen/NotificationsScreen" const Stack = createStackNavigator() const MainStackNavigator: React.FC = () => { @@ -191,11 +190,7 @@ const MainStackNavigator: React.FC = () => { component={AboutScreen} options={{ headerShown: false }} /> - + { - const [search, setSearch] = useState("") - const insets = useSafeAreaInsets() - - // Filter the notifications based on the search input - const filteredMessages = messages.filter((message) => - message.name.toLowerCase().includes(search.toLowerCase()) - ) - - return ( - - - - - Notifications - - - - ( - - )} - keyExtractor={(item) => item.id} - testID="notifications-flatlist" - /> - - ) -} - -export default NotificationsScreen diff --git a/screens/Settings/NotificationsScreen/styles.ts b/screens/Settings/NotificationsScreen/styles.ts deleted file mode 100644 index 25b1abf4..00000000 --- a/screens/Settings/NotificationsScreen/styles.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { StyleSheet } from "react-native" -import { - gray, - lightGray, - lightPeach, - peach, - white, -} from "../../../assets/colors/colors" - -const styles = StyleSheet.create({ - backButton: { - left: 10, - position: "absolute", - top: 20, - }, - backButtonText: { - color: lightPeach, - fontSize: 24, - }, - - container: { - backgroundColor: white, - flex: 1, - paddingHorizontal: 20, - paddingTop: 40, - }, - - headerText: { - fontSize: 24, - marginVertical: 20, - textAlign: "center", - }, - - messageContainer: { - backgroundColor: lightPeach, - borderColor: peach, - borderRadius: 35, - borderWidth: 2, - flexDirection: "row", - marginBottom: 10, - }, - messageContent: { - flex: 1, - }, - messageText: { - color: gray, - }, - - nameText: { - fontSize: 16, - fontWeight: "bold", - }, - - profileImage: { - backgroundColor: peach, - borderRadius: 50, - height: 50, - marginRight: 10, - width: 50, - }, - - searchInput: { - borderColor: lightGray, - borderRadius: 20, - borderWidth: 1, - height: 50, - marginBottom: 20, - paddingLeft: 20, - }, -}) - -export default styles diff --git a/screens/Settings/SettingsScreen.tsx b/screens/Settings/SettingsScreen.tsx index dc23547b..4cfe829b 100644 --- a/screens/Settings/SettingsScreen.tsx +++ b/screens/Settings/SettingsScreen.tsx @@ -18,10 +18,7 @@ export const SettingsScreen = () => { const menuItems: MenuItem[] = [ { title: "LANGUAGE", action: pressPlaceholder }, - { - title: "NOTIFICATIONS", - action: () => navigation.navigate("Notifications" as never), - }, + { title: "HELP", action: pressPlaceholder }, { title: "ABOUT", action: () => navigation.navigate("About" as never) }, { title: "LOG OUT", action: Logout }, From 1f43fc93afdc70aa427f0048327298436c3d0eca Mon Sep 17 00:00:00 2001 From: Wepo Date: Sun, 2 Jun 2024 19:46:59 +0200 Subject: [PATCH 18/20] fix: dummy screen removed --- __test__/end-to-end/app-end-to-end.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/__test__/end-to-end/app-end-to-end.yaml b/__test__/end-to-end/app-end-to-end.yaml index b1f220cd..c9c1a8c4 100644 --- a/__test__/end-to-end/app-end-to-end.yaml +++ b/__test__/end-to-end/app-end-to-end.yaml @@ -2,16 +2,19 @@ appId: com.epfl.uniconnect -# need to have a connected user +## Can have some problem if the user is connectect to google and a pop up appears asking to save of note the google account --- - launchApp: clearState: true +- startRecording: end-to-end-demo + - tapOn: "Username or email" - inputText: "email@oui.com" - tapOn: "Password" - inputText: "VeryHard6_" - tapOn: "Log In" -- tapOn: "Save" +- tapOn: + point: "50%,53%" - tapOn: "Search..." - inputText: "Pedro" - tapOn: @@ -36,8 +39,10 @@ appId: com.epfl.uniconnect - tapOn: "Create an announcement" - tapOn: "Chemistry x Python" - inputText: "test Demo" +- hideKeyboard - tapOn: - point: "17%,33%" + text:  + index: 2 - tapOn: "Photography" - tapOn: id: "WritingID" @@ -96,4 +101,4 @@ appId: com.epfl.uniconnect - tapOn: id: "back-arrow" - tapOn: "LOG OUT" - +- stopRecording From 2e0d29924d2134fc5642d9d10e4b75fb73544d40 Mon Sep 17 00:00:00 2001 From: Wepo Date: Sun, 2 Jun 2024 20:04:26 +0200 Subject: [PATCH 19/20] fix: dummy screen removed --- __test__/screens/Settings/SettingsScreen.test.tsx | 11 +++++------ screens/Settings/SettingsScreen.tsx | 7 ++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/__test__/screens/Settings/SettingsScreen.test.tsx b/__test__/screens/Settings/SettingsScreen.test.tsx index 7bd3503d..e52b034f 100644 --- a/__test__/screens/Settings/SettingsScreen.test.tsx +++ b/__test__/screens/Settings/SettingsScreen.test.tsx @@ -2,7 +2,7 @@ import React from "react" import { render, fireEvent } from "@testing-library/react-native" import { SettingsScreen } from "../../../screens/Settings/SettingsScreen" import { NavigationContainer } from "@react-navigation/native" -import { Alert } from "react-native" + import { Auth } from "firebase/auth" import { SafeAreaProvider } from "react-native-safe-area-context" @@ -77,9 +77,9 @@ describe("SettingsScreen", () => { // Assert that the menu items are rendered const menuItemTexts = [ - "LANGUAGE", + + - "HELP", "ABOUT", "LOG OUT", ] @@ -104,7 +104,7 @@ describe("SettingsScreen", () => { expect(mockGoBack).toHaveBeenCalled() }) test("calls the correct action when a menu item is pressed", () => { - const alertSpy = jest.spyOn(Alert, "alert") + const { getByText } = render( @@ -113,10 +113,9 @@ describe("SettingsScreen", () => { ) - const menuItem = getByText("LANGUAGE") + const menuItem = getByText("ABOUT") fireEvent.press(menuItem) - expect(alertSpy).toHaveBeenCalledWith("Coming soon") }) test("calls the correct action when the logout menu item is pressed", () => { diff --git a/screens/Settings/SettingsScreen.tsx b/screens/Settings/SettingsScreen.tsx index 4cfe829b..edf5a7a6 100644 --- a/screens/Settings/SettingsScreen.tsx +++ b/screens/Settings/SettingsScreen.tsx @@ -1,5 +1,5 @@ import React from "react" -import { View, Text, TouchableOpacity, Alert } from "react-native" +import { View, Text, TouchableOpacity } from "react-native" import { styles } from "./styles" import { useNavigation } from "@react-navigation/native" import { Logout } from "../../firebase/Logout" @@ -14,12 +14,9 @@ export const SettingsScreen = () => { action: () => Promise | void } - const pressPlaceholder = () => Alert.alert("Coming soon") - + const menuItems: MenuItem[] = [ - { title: "LANGUAGE", action: pressPlaceholder }, - { title: "HELP", action: pressPlaceholder }, { title: "ABOUT", action: () => navigation.navigate("About" as never) }, { title: "LOG OUT", action: Logout }, ] From efc38f81c99465f576472893f272609a05e6eddd Mon Sep 17 00:00:00 2001 From: Wepo Date: Sun, 2 Jun 2024 20:14:10 +0200 Subject: [PATCH 20/20] fix: jest test --- .../ExternalProfileScreen/ExternalProfileScreen.test.tsx | 1 - __test__/screens/Settings/SettingsScreen.test.tsx | 1 + .../ExternalProfileScreen/ExternalProfileScreen.tsx | 8 -------- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/__test__/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.test.tsx b/__test__/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.test.tsx index 0df5170a..01a475b7 100644 --- a/__test__/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.test.tsx +++ b/__test__/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.test.tsx @@ -139,7 +139,6 @@ describe("ExternalProfileScreen", () => { await waitFor(() => { fireEvent.press(getByText("Network")) - expect(getByText("Message")).toBeTruthy() expect(getByText("Remove")).toBeTruthy() }) }) diff --git a/__test__/screens/Settings/SettingsScreen.test.tsx b/__test__/screens/Settings/SettingsScreen.test.tsx index e52b034f..4693628e 100644 --- a/__test__/screens/Settings/SettingsScreen.test.tsx +++ b/__test__/screens/Settings/SettingsScreen.test.tsx @@ -34,6 +34,7 @@ jest.mock("@react-navigation/native", () => { ...jest.requireActual("@react-navigation/native"), useNavigation: () => ({ goBack: mockGoBack, + navigate: jest.fn(), }), } }) diff --git a/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx b/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx index dc32eb05..417a3791 100644 --- a/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx +++ b/screens/Profile/ExternalProfileScreen/ExternalProfileScreen.tsx @@ -91,14 +91,6 @@ const ExternalProfileScreen = () => { {isFriend && ( - alert("To come")} - > - - Message - - {