Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
Remove teams section from Firebase
Liyas Thomas774853af7a44
diff --git a/helpers/__tests__/fb.spec.js b/helpers/__tests__/fb.spec.jsindex f7d2c3886..ead98b043 100644--- a/helpers/__tests__/fb.spec.js+++ b/helpers/__tests__/fb.spec.js@@ -121,35 +121,6 @@ beforeEach(async () => {value: true,})- await mocksdk- .firestore()- .collection("users")- .doc(testuser.uid)- .collection("settings")- .doc("syncTeams")- .set({- author: testuser.uid,- author_image: testuser.photoURL,- author_name: testuser.displayName,- name: "syncTeams",- updatedOn: new Date(1598703948000),- value: true,- })-- await mocksdk- .firestore()- .collection("users")- .doc(testuser.uid)- .collection("teams")- .doc("sync")- .set({- author: testuser.uid,- author_image: testuser.photoURL,- author_name: testuser.displayName,- team: [],- updatedOn: new Date(1598703948000),- })-await mocksdk.firestore().collection("users")@@ -1232,78 +1203,4 @@ describe("FirebaseInstance", () => {)})})-- describe("writeTeams", () => {- test("resolves for proper authenticated request", async () => {- const fb = new FirebaseInstance(mocksdk)-- signInUser()-- await expect(fb.writeTeams([])).resolves.toBeUndefined()- })-- test("rejects for non-authenticated request", async () => {- const fb = new FirebaseInstance(mocksdk)-- signOutUser()-- await expect(fb.writeTeams([])).rejects.toBeDefined()- })-- test("stores data on firestore with proper structure", async () => {- const fb = new FirebaseInstance(mocksdk)-- signInUser()-- await fb.writeTeams([])-- const doc = (- await mocksdk- .firestore()- .collection("users")- .doc(testuser.uid)- .collection("teams")- .doc("sync")- .get()- ).data()-- expect(doc).toEqual(- expect.objectContaining({- updatedOn: expect.any(Date),- author: expect.any(String),- author_name: expect.any(String),- author_image: expect.any(String),- team: expect.anything(),- })- )- })-- test("stores data on firestore with fields having proper values", async () => {- const fb = new FirebaseInstance(mocksdk)-- signInUser()-- await fb.writeTeams([])-- const doc = (- await mocksdk- .firestore()- .collection("users")- .doc(testuser.uid)- .collection("teams")- .doc("sync")- .get()- ).data()-- expect(doc).toEqual(- expect.objectContaining({- updatedOn: expect.any(Date),- author: testuser.uid,- author_name: testuser.displayName,- author_image: testuser.photoURL,- team: expect.anything(),- })- )- })- })})diff --git a/helpers/fb.js b/helpers/fb.jsindex f564448d8..30c3dd7d8 100644--- a/helpers/fb.js+++ b/helpers/fb.js@@ -32,7 +32,6 @@ export class FirebaseInstance {this.currentHistory = []this.currentCollections = []this.currentEnvironments = []- this.currentTeams = []this.app.auth().onAuthStateChanged((user) => {if (user) {@@ -121,19 +120,6 @@ export class FirebaseInstance {this.currentEnvironments = environments[0].environment}})-- this.usersCollection- .doc(this.currentUser.uid)- .collection("teams")- .onSnapshot((teamsRef) => {- const teams = []- teamsRef.forEach((doc) => {- const team = doc.data()- team.id = doc.id- teams.push(team)- })- this.currentTeams = teams[0].team- })} else {this.currentUser = null}@@ -302,24 +288,6 @@ export class FirebaseInstance {throw e}}-- async writeTeams(team) {- const ev = {- updatedOn: new Date(),- author: this.currentUser.uid,- author_name: this.currentUser.displayName,- author_image: this.currentUser.photoURL,- team,- }-- try {- await this.usersCollection.doc(this.currentUser.uid).collection("teams").doc("sync").set(ev)- } catch (e) {- console.error("error updating", ev, e)-- throw e- }- }}export const fb = new FirebaseInstance(firebase.initializeApp(firebaseConfig), authProviders)