diff --git a/quirknotes/backend/data/db/WiredTiger.turtle b/quirknotes/backend/data/db/WiredTiger.turtle index e920c89..529d05c 100644 --- a/quirknotes/backend/data/db/WiredTiger.turtle +++ b/quirknotes/backend/data/db/WiredTiger.turtle @@ -3,4 +3,4 @@ WiredTiger 11.2.0: (November 10, 2022) WiredTiger version major=11,minor=2,patch=0 file:WiredTiger.wt -access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=0),value_format=S,verbose=[],version=(major=1,minor=1),write_timestamp_usage=none,checkpoint=(WiredTigerCheckpoint.80=(addr="018381e4546d63488481e41f4fdcd18581e4e5dfaccc808080e3010fc0e23fc0",order=80,time=1708023407,size=28672,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=54,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=239,run_write_gen=96)),checkpoint_backup_info=,checkpoint_lsn=(2,31104) +access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=0),value_format=S,verbose=[],version=(major=1,minor=1),write_timestamp_usage=none,checkpoint=(WiredTigerCheckpoint.132=(addr="018381e424a0fcf28481e41f4fdcd18581e4b1d5bf34808080e3010fc0e23fc0",order=132,time=1708027302,size=28672,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=489,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=395,run_write_gen=243)),checkpoint_backup_info=,checkpoint_lsn=(3,161408) diff --git a/quirknotes/backend/data/db/WiredTiger.wt b/quirknotes/backend/data/db/WiredTiger.wt index 3d0966a..407429a 100644 Binary files a/quirknotes/backend/data/db/WiredTiger.wt and b/quirknotes/backend/data/db/WiredTiger.wt differ diff --git a/quirknotes/backend/data/db/collection-2-5500651194477838497.wt b/quirknotes/backend/data/db/collection-2-5500651194477838497.wt index 4560aff..8701ded 100644 Binary files a/quirknotes/backend/data/db/collection-2-5500651194477838497.wt and b/quirknotes/backend/data/db/collection-2-5500651194477838497.wt differ diff --git a/quirknotes/backend/data/db/collection-4-5500651194477838497.wt b/quirknotes/backend/data/db/collection-4-5500651194477838497.wt index 3323773..7244fa6 100644 Binary files a/quirknotes/backend/data/db/collection-4-5500651194477838497.wt and b/quirknotes/backend/data/db/collection-4-5500651194477838497.wt differ diff --git a/quirknotes/backend/data/db/collection-7-5500651194477838497.wt b/quirknotes/backend/data/db/collection-7-5500651194477838497.wt index 0648862..e944399 100644 Binary files a/quirknotes/backend/data/db/collection-7-5500651194477838497.wt and b/quirknotes/backend/data/db/collection-7-5500651194477838497.wt differ diff --git a/quirknotes/backend/data/db/diagnostic.data/metrics.2024-02-15T19-10-33Z-00000 b/quirknotes/backend/data/db/diagnostic.data/metrics.2024-02-15T19-10-33Z-00000 new file mode 100644 index 0000000..e5c195f Binary files /dev/null and b/quirknotes/backend/data/db/diagnostic.data/metrics.2024-02-15T19-10-33Z-00000 differ diff --git a/quirknotes/backend/data/db/diagnostic.data/metrics.interim b/quirknotes/backend/data/db/diagnostic.data/metrics.interim index fdf5626..ada4207 100644 Binary files a/quirknotes/backend/data/db/diagnostic.data/metrics.interim and b/quirknotes/backend/data/db/diagnostic.data/metrics.interim differ diff --git a/quirknotes/backend/data/db/index-3-5500651194477838497.wt b/quirknotes/backend/data/db/index-3-5500651194477838497.wt index aff29b8..43a996e 100644 Binary files a/quirknotes/backend/data/db/index-3-5500651194477838497.wt and b/quirknotes/backend/data/db/index-3-5500651194477838497.wt differ diff --git a/quirknotes/backend/data/db/index-5-5500651194477838497.wt b/quirknotes/backend/data/db/index-5-5500651194477838497.wt index 9a33de5..50f1108 100644 Binary files a/quirknotes/backend/data/db/index-5-5500651194477838497.wt and b/quirknotes/backend/data/db/index-5-5500651194477838497.wt differ diff --git a/quirknotes/backend/data/db/index-6-5500651194477838497.wt b/quirknotes/backend/data/db/index-6-5500651194477838497.wt index eb8dbcf..d699a6d 100644 Binary files a/quirknotes/backend/data/db/index-6-5500651194477838497.wt and b/quirknotes/backend/data/db/index-6-5500651194477838497.wt differ diff --git a/quirknotes/backend/data/db/index-8-5500651194477838497.wt b/quirknotes/backend/data/db/index-8-5500651194477838497.wt index 07f908b..fdad288 100644 Binary files a/quirknotes/backend/data/db/index-8-5500651194477838497.wt and b/quirknotes/backend/data/db/index-8-5500651194477838497.wt differ diff --git a/quirknotes/backend/data/db/journal/WiredTigerLog.0000000002 b/quirknotes/backend/data/db/journal/WiredTigerLog.0000000003 similarity index 99% rename from quirknotes/backend/data/db/journal/WiredTigerLog.0000000002 rename to quirknotes/backend/data/db/journal/WiredTigerLog.0000000003 index 03d4275..0d524c1 100644 Binary files a/quirknotes/backend/data/db/journal/WiredTigerLog.0000000002 and b/quirknotes/backend/data/db/journal/WiredTigerLog.0000000003 differ diff --git a/quirknotes/backend/data/db/mongod.lock b/quirknotes/backend/data/db/mongod.lock index 7b60c07..55a950e 100644 --- a/quirknotes/backend/data/db/mongod.lock +++ b/quirknotes/backend/data/db/mongod.lock @@ -1 +1 @@ -27516 +28804 diff --git a/quirknotes/backend/data/db/sizeStorer.wt b/quirknotes/backend/data/db/sizeStorer.wt index 2b11dee..4b44b81 100644 Binary files a/quirknotes/backend/data/db/sizeStorer.wt and b/quirknotes/backend/data/db/sizeStorer.wt differ diff --git a/quirknotes/backend/server.js b/quirknotes/backend/server.js index 96c7894..775c413 100644 --- a/quirknotes/backend/server.js +++ b/quirknotes/backend/server.js @@ -44,7 +44,7 @@ app.get("/getAllNotes", express.json(), async (req, res) => { // Find notes with username attached to them const collection = db.collection(COLLECTIONS.notes); const data = await collection.find().toArray(); - res.json({ response: [] }); + res.json({ response: data }); } catch (error) { res.status(500).json({error: error.message}) } @@ -71,7 +71,7 @@ app.post("/postNote", express.json(), async (req, res) => { createdAt }); res.json({ - response: "Note added succesfully.", + response: "Note added successfully.", insertedId: result.insertedId, }); diff --git a/quirknotes/backend/tests/status200.test.js b/quirknotes/backend/tests/status200.test.js index 11d2019..2a8bb1f 100644 --- a/quirknotes/backend/tests/status200.test.js +++ b/quirknotes/backend/tests/status200.test.js @@ -5,6 +5,7 @@ test("1+2=3, empty array is empty", () => { const SERVER_URL = "http://localhost:4000"; + test("/postNote - Post a note", async () => { const title = "NoteTitleTest"; const content = "NoteTitleContent"; @@ -23,5 +24,262 @@ test("/postNote - Post a note", async () => { const postNoteBody = await postNoteRes.json(); expect(postNoteRes.status).toBe(200); - expect(postNoteBody.response).toBe("Note added succesfully."); -}); \ No newline at end of file + expect(postNoteBody.response).toBe("Note added successfully."); + +}); + +test("/getAllNotes - Return list of zero notes for getAllNotes", async () => { + const deleteAllRes = await fetch(`${SERVER_URL}/deleteAllNotes`, { + method: "DELETE" + }); + const getAllNotesRes = await fetch(`${SERVER_URL}/getAllNotes`, { + method: "GET" + }); + + const getAllNotesBody = await getAllNotesRes.json(); + + expect(getAllNotesRes.status).toBe(200); + expect(getAllNotesBody.response.length).toBe(0); +}); + + test("/getAllNotes - Return list of two notes for getAllNotes", async () => { + const deleteAllRes = await fetch(`${SERVER_URL}/deleteAllNotes`, { + method: "DELETE" + }); + const title = "NoteTitleTest"; + const content = "NoteTitleContent"; + + const postNoteRes1 = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: title + "1", + content: content + "1", + }), + }); + const postNoteRes2 = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: title + "2", + content: content + "2", + }), + }); + + const getAllNotesRes = await fetch(`${SERVER_URL}/getAllNotes`, { + method: "GET" + }); + + const getAllNotesBody = await getAllNotesRes.json(); + + expect(getAllNotesRes.status).toBe(200); + expect(getAllNotesBody.response.length).toBe(2); + }); + + test("/deleteNote - Delete a note", async () => { + const postNoteRes = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: "Title to delete", + content: "Content to delete", + }), + }); + const postNoteBody = await postNoteRes.json(); + + const deleteNoteRes = await fetch(`${SERVER_URL}/deleteNote/${postNoteBody.insertedId}`, { + method: "DELETE", + }); + const deleteNoteBody = await deleteNoteRes.json(); + expect(deleteNoteRes.status).toBe(200); + expect(deleteNoteBody.response).toBe(`Document with ID ${postNoteBody.insertedId} deleted.`); + }); + + test("/patchNote - Patch with content and title", async () => { + const postNoteRes = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: "Title to patch oops", + content: "Content to patch oops", + }), + }); + const postNoteBody = await postNoteRes.json(); + + const patchNoteRes = await fetch(`${SERVER_URL}/patchNote/${postNoteBody.insertedId}`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: "Title to patch", + content: "Content to patch", + }), + }); + + const patchNoteBody = await patchNoteRes.json(); + expect(patchNoteRes.status).toBe(200); + expect(patchNoteBody.response).toBe(`Document with ID ${postNoteBody.insertedId} patched.`); + }); + + test("/patchNote - Patch with just title", async () => { + const postNoteRes = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: "Title to patch oops", + content: "Content to patch", + }), + }); + const postNoteBody = await postNoteRes.json(); + + const patchNoteRes = await fetch(`${SERVER_URL}/patchNote/${postNoteBody.insertedId}`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: "Title to patch", + }), + }); + + const patchNoteBody = await patchNoteRes.json(); + expect(patchNoteRes.status).toBe(200); + expect(patchNoteBody.response).toBe(`Document with ID ${postNoteBody.insertedId} patched.`); + }); + + test("/patchNote - Patch with just content", async () => { + const postNoteRes = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: "Title to patch", + content: "Content to patch oops", + }), + }); + const postNoteBody = await postNoteRes.json(); + + const patchNoteRes = await fetch(`${SERVER_URL}/patchNote/${postNoteBody.insertedId}`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + content: "Content to patch", + }), + }); + + const patchNoteBody = await patchNoteRes.json(); + expect(patchNoteRes.status).toBe(200); + expect(patchNoteBody.response).toBe(`Document with ID ${postNoteBody.insertedId} patched.`); + }); + + test("/deleteAllNotes - Delete one note", async () => { + const deleteAllResFirst = await fetch(`${SERVER_URL}/deleteAllNotes`, { + method: "DELETE" + }); + const title = "NoteTitleTest"; + const content = "NoteTitleContent"; + + const postNoteRes = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: title, + content: content, + }), + }); + + const deleteAllRes = await fetch(`${SERVER_URL}/deleteAllNotes`, { + method: "DELETE" + }); + const deleteAllNotesBody = await deleteAllRes.json(); + expect(deleteAllRes.status).toBe(200); + expect(deleteAllNotesBody.response).toBe("1 note(s) deleted."); + }); + + test("/deleteAllNotes - Delete three notes", async () => { + const deleteAllResFirst = await fetch(`${SERVER_URL}/deleteAllNotes`, { + method: "DELETE" + }); + const title = "NoteTitleTest"; + const content = "NoteTitleContent"; + + const postNoteRes1 = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: title + "1", + content: content + "1", + }), + }); + const postNoteRes2 = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: title + "2", + content: content + "2", + }), + }); + const postNoteRes3 = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: title + "3", + content: content + "3", + }), + }); + const deleteAllRes = await fetch(`${SERVER_URL}/deleteAllNotes`, { + method: "DELETE" + }); + const deleteAllNotesBody = await deleteAllRes.json(); + expect(deleteAllRes.status).toBe(200); + expect(deleteAllNotesBody.response).toBe("3 note(s) deleted."); + }); + + test("/updateNoteColor - Update color of a note to red (#FF0000)", async () => { + const postNoteRes = await fetch(`${SERVER_URL}/postNote`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: "Title to patch", + content: "Content to patch oops", + }), + }); + const postNoteBody = await postNoteRes.json(); + + const updateNoteColorRes = await fetch(`${SERVER_URL}/updateNoteColor/${postNoteBody.insertedId}`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + color: "#FF0000", + }), + }); + const updateNoteColorBody = await updateNoteColorRes.json(); + expect(updateNoteColorRes.status).toBe(200); + expect(updateNoteColorBody.message).toBe("Note color updated successfully."); + }); \ No newline at end of file