diff --git a/src/e2e/data/fakeUsers.ts b/src/e2e/data/fakeUsers.ts new file mode 100644 index 0000000..334d62b --- /dev/null +++ b/src/e2e/data/fakeUsers.ts @@ -0,0 +1,905 @@ +import User from "../../models/User.model"; + + +export default [ + { + user_id: 5, + first_name: "Pinkie", + last_name: "Fay", + password: "STgQZ4wKRZdYH4N", + signed_in: true, + last_signed_in: 1700733064846, + total_time: 1703853395539, + }, + { + user_id: 11, + first_name: "Trudie", + last_name: "Dach", + password: "WREw3QZKFSUix5", + signed_in: false, + last_signed_in: 1697656618708, + total_time: 1692458081220, + }, + { + user_id: 18, + first_name: "Marcia", + last_name: "Dare", + password: "8bNygvDNUgbbaoL", + signed_in: false, + last_signed_in: 1703119743526, + total_time: 1724612782088, + }, + { + user_id: 21, + first_name: "Eleanora", + last_name: "Breitenberg", + password: "6Pb5jb3sDFPPWL4", + signed_in: true, + last_signed_in: 1679839504314, + total_time: 1730843649914, + }, + { + user_id: 32, + first_name: "Giles", + last_name: "Hickle", + password: "YPhjq64wK3O8t7w", + signed_in: true, + last_signed_in: 1676574355975, + total_time: 1727261044865, + }, + { + user_id: 43, + first_name: "Dena", + last_name: "Carter", + password: "q20Cw2HLhB7Y620", + signed_in: false, + last_signed_in: 1704936670858, + total_time: 1683930909023, + }, + { + user_id: 44, + first_name: "Jonas", + last_name: "Brekke", + password: "Xpx1w92PubbmWM", + signed_in: false, + last_signed_in: 1682905575778, + total_time: 1736851466399, + }, + { + user_id: 49, + first_name: "Lue", + last_name: "Fritsch", + password: "rvW8qlDpExXyXxs", + signed_in: false, + last_signed_in: 1677158195071, + total_time: 1704243624417, + }, + { + user_id: 56, + first_name: "Elian", + last_name: "Lesch", + password: "nP4ZweXNQWUqJwc", + signed_in: false, + last_signed_in: 1675094202020, + total_time: 1698438249874, + }, + { + user_id: 65, + first_name: "Rachael", + last_name: "Kassulke", + password: "i4LSwI9FRnItVjU", + signed_in: true, + last_signed_in: 1704867567594, + total_time: 1676594552597, + }, + { + user_id: 66, + first_name: "Kory", + last_name: "McCullough", + password: "DAV0m1ihL3oHXCs", + signed_in: false, + last_signed_in: 1693034411871, + total_time: 1725244472099, + }, + { + user_id: 72, + first_name: "Rhoda", + last_name: "Kirlin", + password: "aXfeeSSIHAIhg0w", + signed_in: true, + last_signed_in: 1674860127659, + total_time: 1689244977509, + }, + { + user_id: 82, + first_name: "Elody", + last_name: "Effertz", + password: "9VvuZJEKbWVlKC5", + signed_in: false, + last_signed_in: 1698275742003, + total_time: 1682038711649, + }, + { + user_id: 88, + first_name: "Jarrett", + last_name: "Schoen", + password: "6ZjsqqfYHtOyJdy", + signed_in: true, + last_signed_in: 1677883278830, + total_time: 1717908480552, + }, + { + user_id: 94, + first_name: "Devyn", + last_name: "Rosenbaum", + password: "MEDIEMgyxaOxUbh", + signed_in: false, + last_signed_in: 1676326125809, + total_time: 1728033995836, + }, + { + user_id: 96, + first_name: "Howell", + last_name: "Botsford", + password: "9se8GBj5Gc3YC0", + signed_in: true, + last_signed_in: 1698612009690, + total_time: 1689566190511, + }, + { + user_id: 106, + first_name: "Reanna", + last_name: "KleinRoberts", + password: "dMBqKfumin9sKQU", + signed_in: false, + last_signed_in: 1697106783447, + total_time: 1722875763325, + }, + { + user_id: 110, + first_name: "Merle", + last_name: "Pouros", + password: "eWy1NL7eZHGtmu", + signed_in: true, + last_signed_in: 1681814773092, + total_time: 1691408943849, + }, + { + user_id: 119, + first_name: "Karelle", + last_name: "Deckow", + password: "oOISClTvqn9HIlQ", + signed_in: false, + last_signed_in: 1674244541607, + total_time: 1712633996634, + }, + { + user_id: 126, + first_name: "Juston", + last_name: "Towne", + password: "pFsVKnBWz19Gjns", + signed_in: true, + last_signed_in: 1692126115957, + total_time: 1701964272284, + }, + { + user_id: 136, + first_name: "Fritz", + last_name: "Block", + password: "uk44wCFHTsWBtJV", + signed_in: false, + last_signed_in: 1678282715330, + total_time: 1730805361850, + }, + { + user_id: 139, + first_name: "Morgan", + last_name: "Gibson", + password: "LXhMvxL4zvdl1bh", + signed_in: false, + last_signed_in: 1681704773993, + total_time: 1727853365123, + }, + { + user_id: 150, + first_name: "Archibald", + last_name: "Ratke", + password: "jHfWmBhl9tgnqtE", + signed_in: false, + last_signed_in: 1676235343683, + total_time: 1734204140489, + }, + { + user_id: 160, + first_name: "Trinity", + last_name: "Abernathy", + password: "tbo2EfTq7DtSd0h", + signed_in: false, + last_signed_in: 1703818326661, + total_time: 1699423874155, + }, + { + user_id: 168, + first_name: "Enrico", + last_name: "Steuber", + password: "McitijBQmS6Imy", + signed_in: true, + last_signed_in: 1675875758989, + total_time: 1727506606533, + }, + { + user_id: 173, + first_name: "Bradly", + last_name: "Stiedemann", + password: "z3l2A3JRF7oCuwe", + signed_in: false, + last_signed_in: 1699690941815, + total_time: 1734324388738, + }, + { + user_id: 183, + first_name: "Demetris", + last_name: "Rutherford", + password: "FUBXSsJOBqLcbe", + signed_in: false, + last_signed_in: 1701169784841, + total_time: 1719655448748, + }, + { + user_id: 192, + first_name: "Elias", + last_name: "Walter", + password: "rzoQafKwqXOTWQL", + signed_in: true, + last_signed_in: 1698684842691, + total_time: 1709354513463, + }, + { + user_id: 200, + first_name: "Hadley", + last_name: "Boyle", + password: "GKIUb0UURu2g4", + signed_in: false, + last_signed_in: 1678427636149, + total_time: 1704102414255, + }, + { + user_id: 208, + first_name: "Tracey", + last_name: "Dach", + password: "l739rdwa7qoDf", + signed_in: false, + last_signed_in: 1688775262393, + total_time: 1728082498016, + }, + { + user_id: 216, + first_name: "Meaghan", + last_name: "Sipes", + password: "TZhO6BN8CcHPI2f", + signed_in: false, + last_signed_in: 1703790160614, + total_time: 1709569001646, + }, + { + user_id: 218, + first_name: "Rudolph", + last_name: "Goyette", + password: "48kWjLMoBqsX1Wr", + signed_in: false, + last_signed_in: 1690857725292, + total_time: 1716184457907, + }, + { + user_id: 221, + first_name: "Lenny", + last_name: "Adams", + password: "cWtFLjPtfqBh0D", + signed_in: true, + last_signed_in: 1678387414367, + total_time: 1709088840399, + }, + { + user_id: 227, + first_name: "Queen", + last_name: "Jerde", + password: "Ouuz2BfDOlyKQt", + signed_in: true, + last_signed_in: 1688758605598, + total_time: 1697973231779, + }, + { + user_id: 234, + first_name: "Trey", + last_name: "Morar", + password: "Tc9eNSow13C90li", + signed_in: false, + last_signed_in: 1679982858345, + total_time: 1706079104758, + }, + { + user_id: 240, + first_name: "Darien", + last_name: "Tillman", + password: "O596SCsngIpm1SG", + signed_in: false, + last_signed_in: 1675567916364, + total_time: 1736488659029, + }, + { + user_id: 242, + first_name: "Lorena", + last_name: "Abernathy", + password: "yLOQGSPuTcZQjx9", + signed_in: true, + last_signed_in: 1676361975920, + total_time: 1699467494113, + }, + { + user_id: 251, + first_name: "Leatha", + last_name: "Collier", + password: "SQKhtc5X4XTcKwi", + signed_in: true, + last_signed_in: 1696975181819, + total_time: 1712929615676, + }, + { + user_id: 252, + first_name: "Tressie", + last_name: "Beier", + password: "HUkFI6pNupiSkdI", + signed_in: false, + last_signed_in: 1686461385338, + total_time: 1722226388027, + }, + { + user_id: 256, + first_name: "Royal", + last_name: "Brekke", + password: "dg9uHb4aoYjxVB5", + signed_in: false, + last_signed_in: 1678817841356, + total_time: 1723604769899, + }, + { + user_id: 261, + first_name: "Adriana", + last_name: "Roberts", + password: "DLgSbzHg43szfrA", + signed_in: true, + last_signed_in: 1677611296082, + total_time: 1709257419819, + }, + { + user_id: 265, + first_name: "Sarina", + last_name: "Runte", + password: "3yElpqPl8zcpAqV", + signed_in: true, + last_signed_in: 1676759591703, + total_time: 1703548536566, + }, + { + user_id: 271, + first_name: "Michaela", + last_name: "Boehm", + password: "RkNKSIMv023J3R9", + signed_in: false, + last_signed_in: 1699206552238, + total_time: 1729697235659, + }, + { + user_id: 276, + first_name: "Shirley", + last_name: "Barrows", + password: "ftYFC0rmDceJP4", + signed_in: false, + last_signed_in: 1674838487581, + total_time: 1733889925551, + }, + { + user_id: 285, + first_name: "Kareem", + last_name: "Zboncak", + password: "5L1IlKCWtYW2tJU", + signed_in: false, + last_signed_in: 1676868045806, + total_time: 1695790191264, + }, + { + user_id: 288, + first_name: "Peyton", + last_name: "Collins", + password: "Ueb5dSH0PCfeAxP", + signed_in: true, + last_signed_in: 1691432968967, + total_time: 1698214493592, + }, + { + user_id: 289, + first_name: "Bernie", + last_name: "MacGyver", + password: "oKZdrBEPedQwAZc", + signed_in: true, + last_signed_in: 1695408785883, + total_time: 1712095324966, + }, + { + user_id: 298, + first_name: "Hannah", + last_name: "Kunze", + password: "GZgL4P7glcjr7HK", + signed_in: false, + last_signed_in: 1675354624856, + total_time: 1716787257461, + }, + { + user_id: 303, + first_name: "Kieran", + last_name: "Armstrong", + password: "A8SwKVLPxADhnvg", + signed_in: true, + last_signed_in: 1705181868534, + total_time: 1717062232050, + }, + { + user_id: 314, + first_name: "Jermain", + last_name: "Hahn", + password: "JpKB5mqfio4hsPK", + signed_in: false, + last_signed_in: 1691899018104, + total_time: 1735349595795, + }, + { + user_id: 320, + first_name: "Malcolm", + last_name: "MorissetteBoyer", + password: "8mp9ONWiZEEmpwi", + signed_in: true, + last_signed_in: 1680461898187, + total_time: 1721679841153, + }, + { + user_id: 327, + first_name: "Heber", + last_name: "Kulas", + password: "9DLB7r42V8WVIyN", + signed_in: false, + last_signed_in: 1692858407572, + total_time: 1708581918256, + }, + { + user_id: 334, + first_name: "Kianna", + last_name: "Homenick", + password: "jNw8iTz5BL8G1V", + signed_in: false, + last_signed_in: 1676210934040, + total_time: 1689823012563, + }, + { + user_id: 339, + first_name: "Dangelo", + last_name: "Batz", + password: "1jy0HtfxVDnlwwI", + signed_in: true, + last_signed_in: 1680008222653, + total_time: 1691678044446, + }, + { + user_id: 345, + first_name: "Keshaun", + last_name: "Gleason", + password: "2YaZab6cMvyggfz", + signed_in: false, + last_signed_in: 1690206731593, + total_time: 1720683639596, + }, + { + user_id: 347, + first_name: "Faye", + last_name: "Schroeder", + password: "XKLKjoGChlBVi6a", + signed_in: false, + last_signed_in: 1698220477063, + total_time: 1696409352173, + }, + { + user_id: 355, + first_name: "Eugene", + last_name: "Weissnat", + password: "XmQWDRvvXcfVYqk", + signed_in: true, + last_signed_in: 1699268696414, + total_time: 1723179586680, + }, + { + user_id: 362, + first_name: "Vallie", + last_name: "Hoppe", + password: "YSvqojUjdN4oI1h", + signed_in: false, + last_signed_in: 1696585203534, + total_time: 1720240253923, + }, + { + user_id: 371, + first_name: "Joelle", + last_name: "Boyle", + password: "dVMrg1iH7CWaARs", + signed_in: false, + last_signed_in: 1676542870682, + total_time: 1708758973178, + }, + { + user_id: 374, + first_name: "Jeffrey", + last_name: "Rice", + password: "ADGo2HZNcZxNvD4", + signed_in: false, + last_signed_in: 1685650688893, + total_time: 1722137449032, + }, + { + user_id: 376, + first_name: "Eleanore", + last_name: "Marquardt", + password: "2BHEOPe3Zfarok", + signed_in: true, + last_signed_in: 1693354330968, + total_time: 1724838343775, + }, + { + user_id: 377, + first_name: "Shaniya", + last_name: "Rippin", + password: "PrMuupKWTeJbFc", + signed_in: false, + last_signed_in: 1695474028708, + total_time: 1706448444692, + }, + { + user_id: 382, + first_name: "Derek", + last_name: "Jast", + password: "8YJF5rLHTCxAxV3", + signed_in: true, + last_signed_in: 1675635837729, + total_time: 1676450210677, + }, + { + user_id: 383, + first_name: "Lynn", + last_name: "Lebsack", + password: "LKEqDiW5efBSa5K", + signed_in: false, + last_signed_in: 1702389269820, + total_time: 1714060627047, + }, + { + user_id: 388, + first_name: "Jaime", + last_name: "Spencer", + password: "k7HexcWPMMSYR44", + signed_in: true, + last_signed_in: 1686652541661, + total_time: 1699125534216, + }, + { + user_id: 397, + first_name: "Kayla", + last_name: "WaelchiConsidine", + password: "NYCWo0RNtEu6LP8", + signed_in: false, + last_signed_in: 1691645571160, + total_time: 1688845722030, + }, + { + user_id: 403, + first_name: "Ashlynn", + last_name: "Langworth", + password: "eObrVcgP230S51t", + signed_in: false, + last_signed_in: 1679326799603, + total_time: 1715949510290, + }, + { + user_id: 412, + first_name: "Johnson", + last_name: "Huel", + password: "GQk30RqVrF8xAmq", + signed_in: true, + last_signed_in: 1694739273847, + total_time: 1720851714877, + }, + { + user_id: 413, + first_name: "Bartholome", + last_name: "Wolff", + password: "mpFDSt2bDkYfX6d", + signed_in: true, + last_signed_in: 1676364258455, + total_time: 1718338334780, + }, + { + user_id: 417, + first_name: "Addie", + last_name: "Bergnaum", + password: "i9ZQYv8Pxzw7fLu", + signed_in: false, + last_signed_in: 1705035928835, + total_time: 1696715315145, + }, + { + user_id: 425, + first_name: "Casandra", + last_name: "Smith", + password: "c1HswNSJejirHX", + signed_in: false, + last_signed_in: 1688850540616, + total_time: 1698366612167, + }, + { + user_id: 430, + first_name: "Cindy", + last_name: "Leannon", + password: "h4vRgsoLzWZmPry", + signed_in: true, + last_signed_in: 1680911310433, + total_time: 1686730549310, + }, + { + user_id: 439, + first_name: "Stanley", + last_name: "Raynor", + password: "eTDXA3iwwyowxTQ", + signed_in: false, + last_signed_in: 1699013635703, + total_time: 1726533246775, + }, + { + user_id: 442, + first_name: "Dalton", + last_name: "Tromp", + password: "0JpVqbi7bklJD8m", + signed_in: false, + last_signed_in: 1682287803765, + total_time: 1721129317686, + }, + { + user_id: 447, + first_name: "Bailey", + last_name: "Towne", + password: "ZU6Kuoucza4N8o1", + signed_in: true, + last_signed_in: 1678931682211, + total_time: 1729424231504, + }, + { + user_id: 455, + first_name: "Ericka", + last_name: "Schroeder", + password: "O9aAMdzdubat9pH", + signed_in: true, + last_signed_in: 1696870489100, + total_time: 1674510112375, + }, + { + user_id: 465, + first_name: "Harold", + last_name: "GerholdSchneider", + password: "ZLAhlcW9wa9lPW6", + signed_in: false, + last_signed_in: 1700956515530, + total_time: 1676084576514, + }, + { + user_id: 471, + first_name: "Nels", + last_name: "Braun", + password: "Eg7mQaBnun19eUM", + signed_in: true, + last_signed_in: 1688514418760, + total_time: 1724810502041, + }, + { + user_id: 472, + first_name: "Mckayla", + last_name: "Schimmel", + password: "grYHVOsGpBgGJKo", + signed_in: false, + last_signed_in: 1691852973683, + total_time: 1682372078375, + }, + { + user_id: 474, + first_name: "Eliane", + last_name: "Littel", + password: "6OUG3drZzQxj93F", + signed_in: false, + last_signed_in: 1674932858548, + total_time: 1692543792642, + }, + { + user_id: 485, + first_name: "Rachel", + last_name: "Bergnaum", + password: "T8l3BiWm5DesbhR", + signed_in: false, + last_signed_in: 1684780456802, + total_time: 1734499500560, + }, + { + user_id: 488, + first_name: "Kale", + last_name: "Hane", + password: "cGuq94oDRdMFv7", + signed_in: false, + last_signed_in: 1702434628816, + total_time: 1712169610354, + }, + { + user_id: 490, + first_name: "Cicero", + last_name: "Corkery", + password: "bPYjzB1Wsuc4Hzq", + signed_in: true, + last_signed_in: 1682659423901, + total_time: 1714317926377, + }, + { + user_id: 494, + first_name: "Linda", + last_name: "Paucek", + password: "jDr977NItKSHlvS", + signed_in: true, + last_signed_in: 1684179063343, + total_time: 1704739043598, + }, + { + user_id: 501, + first_name: "Mavis", + last_name: "Jakubowski", + password: "xlO325YLccHefE", + signed_in: true, + last_signed_in: 1674893001155, + total_time: 1718919116312, + }, + { + user_id: 508, + first_name: "Javonte", + last_name: "DuBuque", + password: "CaACcZnQ4zAzGtC", + signed_in: false, + last_signed_in: 1694912144475, + total_time: 1707756402007, + }, + { + user_id: 513, + first_name: "Maci", + last_name: "Gottlieb", + password: "m3Bp12MWIubD0c", + signed_in: false, + last_signed_in: 1696712396060, + total_time: 1688199861786, + }, + { + user_id: 518, + first_name: "Jaeden", + last_name: "Greenfelder", + password: "BpfRGv2ShFymy0", + signed_in: true, + last_signed_in: 1704530692762, + total_time: 1735967509689, + }, + { + user_id: 519, + first_name: "Christina", + last_name: "Larkin", + password: "OGulvARIhoWLES", + signed_in: false, + last_signed_in: 1689903527242, + total_time: 1691181024256, + }, + { + user_id: 527, + first_name: "Jimmy", + last_name: "Trantow", + password: "e9tjAfsImMfeu2U", + signed_in: false, + last_signed_in: 1704365771551, + total_time: 1675507044912, + }, + { + user_id: 538, + first_name: "Gregoria", + last_name: "Thompson", + password: "Vbr4m4YEYmoPcKw", + signed_in: true, + last_signed_in: 1695065002006, + total_time: 1714235796037, + }, + { + user_id: 548, + first_name: "Rosalyn", + last_name: "Collier", + password: "xKTeYZlAxMBmhFf", + signed_in: true, + last_signed_in: 1698720513535, + total_time: 1707861113206, + }, + { + user_id: 549, + first_name: "Roman", + last_name: "Wisozk", + password: "gja62hne0YAHNB3", + signed_in: true, + last_signed_in: 1681015567735, + total_time: 1705702618958, + }, + { + user_id: 556, + first_name: "Mariano", + last_name: "Graham", + password: "yccu9CALNaMa4ol", + signed_in: false, + last_signed_in: 1689882294901, + total_time: 1700400996765, + }, + { + user_id: 564, + first_name: "Luciano", + last_name: "Gorczany", + password: "UcWZJS6tua05doG", + signed_in: true, + last_signed_in: 1697672944087, + total_time: 1705727722216, + }, + { + user_id: 574, + first_name: "Angus", + last_name: "ZemlakGreen", + password: "0iNCuDjBznPeSaJ", + signed_in: false, + last_signed_in: 1701230264572, + total_time: 1694621433316, + }, + { + user_id: 580, + first_name: "Oren", + last_name: "Hermann", + password: "qgWcyhLJmP5gMeU", + signed_in: true, + last_signed_in: 1690402290654, + total_time: 1726474217881, + }, + { + user_id: 581, + first_name: "Henriette", + last_name: "Anderson", + password: "cMfJwkuTBcSbLWI", + signed_in: true, + last_signed_in: 1699420141879, + total_time: 1702077550638, + }, + { + user_id: 588, + first_name: "Clinton", + last_name: "Bauch", + password: "j7W5CI8uJzurDN6", + signed_in: false, + last_signed_in: 1682552846670, + total_time: 1681265294695, + }, + { + user_id: 599, + first_name: "Shannon", + last_name: "Lakin", + password: "HGqIjZqOkeQQB2", + signed_in: true, + last_signed_in: 1685969663151, + total_time: 1709890390298, + }, +] as ReadonlyArray; \ No newline at end of file diff --git a/src/e2e/fake-data/users.json b/src/e2e/fake-data/users.json deleted file mode 100644 index 63071fe..0000000 --- a/src/e2e/fake-data/users.json +++ /dev/null @@ -1,902 +0,0 @@ -[ - { - "user_id": 3, - "first_name": "Monica", - "last_name": "Jerde", - "password": "vOOleb9ClHuE5qH", - "signed_in": true, - "last_signed_in": 1704533709591, - "total_time": 1696226703050 - }, - { - "user_id": 13, - "first_name": "Kelley", - "last_name": "Jacobson", - "password": "ocr4Onjmax_b_Cm", - "signed_in": true, - "last_signed_in": 1702647684723, - "total_time": 1677484007631 - }, - { - "user_id": 21, - "first_name": "Nasir", - "last_name": "Donnelly", - "password": "BwDORLc3eDTsaNM", - "signed_in": false, - "last_signed_in": 1674424959786, - "total_time": 1733134443441 - }, - { - "user_id": 24, - "first_name": "Mustafa", - "last_name": "Deckow", - "password": "VJO9UQGa92r1bMj", - "signed_in": false, - "last_signed_in": 1674415338847, - "total_time": 1708446454075 - }, - { - "user_id": 27, - "first_name": "Elisabeth", - "last_name": "McCullough", - "password": "ZO6xCiX7liZXnVM", - "signed_in": true, - "last_signed_in": 1703096851089, - "total_time": 1733802333017 - }, - { - "user_id": 30, - "first_name": "Lenny", - "last_name": "Larson", - "password": "2HRvA8MNHKwL2h6", - "signed_in": true, - "last_signed_in": 1704649840761, - "total_time": 1684096571281 - }, - { - "user_id": 36, - "first_name": "Una", - "last_name": "Hermiston-Abbott", - "password": "BuyO3cUdPzCrY0s", - "signed_in": false, - "last_signed_in": 1701199630561, - "total_time": 1693584768330 - }, - { - "user_id": 36, - "first_name": "Vance", - "last_name": "Gutkowski", - "password": "O42cIPuhatmgMY3", - "signed_in": false, - "last_signed_in": 1693686688161, - "total_time": 1684661467754 - }, - { - "user_id": 39, - "first_name": "Isac", - "last_name": "Hand", - "password": "WPJHMolPTbC28tF", - "signed_in": true, - "last_signed_in": 1682909641723, - "total_time": 1729592292847 - }, - { - "user_id": 46, - "first_name": "Lamont", - "last_name": "Lindgren", - "password": "QKxCZvbsSowhmGp", - "signed_in": false, - "last_signed_in": 1682996209911, - "total_time": 1721519593673 - }, - { - "user_id": 56, - "first_name": "Jalon", - "last_name": "Simonis", - "password": "2wZfZauJsg43RFd", - "signed_in": true, - "last_signed_in": 1693880524395, - "total_time": 1674367563105 - }, - { - "user_id": 61, - "first_name": "Waldo", - "last_name": "Weber", - "password": "nh9HXv2nTjht6PL", - "signed_in": true, - "last_signed_in": 1689090096188, - "total_time": 1685800363258 - }, - { - "user_id": 68, - "first_name": "Noah", - "last_name": "Beatty", - "password": "1XCHq6ipRPPNGYE", - "signed_in": false, - "last_signed_in": 1680980770457, - "total_time": 1688587353801 - }, - { - "user_id": 71, - "first_name": "Cary", - "last_name": "Kuhn", - "password": "UivxfVECpprQSRI", - "signed_in": true, - "last_signed_in": 1688279391864, - "total_time": 1694587581940 - }, - { - "user_id": 76, - "first_name": "Chadrick", - "last_name": "Lang", - "password": "uvgG0yoQTiegWRQ", - "signed_in": true, - "last_signed_in": 1688013485756, - "total_time": 1690685165656 - }, - { - "user_id": 81, - "first_name": "Roscoe", - "last_name": "Carroll", - "password": "AsQoscE25TDJB8f", - "signed_in": true, - "last_signed_in": 1694500505763, - "total_time": 1716035073947 - }, - { - "user_id": 88, - "first_name": "Jerod", - "last_name": "Kulas", - "password": "xN4mn8rBcRSFiqV", - "signed_in": true, - "last_signed_in": 1680517834319, - "total_time": 1694690207988 - }, - { - "user_id": 95, - "first_name": "Anibal", - "last_name": "Schmidt", - "password": "cfCjGrLTwHMLt28", - "signed_in": true, - "last_signed_in": 1683785661953, - "total_time": 1694284083230 - }, - { - "user_id": 102, - "first_name": "August", - "last_name": "Kub", - "password": "SrgyogfJ6bwhaDy", - "signed_in": false, - "last_signed_in": 1702883727321, - "total_time": 1722842488195 - }, - { - "user_id": 103, - "first_name": "Deshawn", - "last_name": "Turcotte", - "password": "L9p5nbyqIbaAY8f", - "signed_in": true, - "last_signed_in": 1681038670904, - "total_time": 1686922109787 - }, - { - "user_id": 110, - "first_name": "Wilson", - "last_name": "Nitzsche", - "password": "ovnvpAVhaSnjirG", - "signed_in": true, - "last_signed_in": 1695999923610, - "total_time": 1715651422347 - }, - { - "user_id": 114, - "first_name": "Freddie", - "last_name": "Schaefer", - "password": "77IK_SNIc9pXTNH", - "signed_in": true, - "last_signed_in": 1688952827625, - "total_time": 1682912958595 - }, - { - "user_id": 114, - "first_name": "Mary", - "last_name": "Ledner-Blanda", - "password": "nqkTnot4TC_mtwn", - "signed_in": true, - "last_signed_in": 1691931149141, - "total_time": 1729898688472 - }, - { - "user_id": 124, - "first_name": "Ella", - "last_name": "Rau", - "password": "Pg73QB3ANkfV4Ox", - "signed_in": false, - "last_signed_in": 1680004940300, - "total_time": 1676486502876 - }, - { - "user_id": 127, - "first_name": "Ted", - "last_name": "Nolan", - "password": "ZNgjlRc1WiMEusE", - "signed_in": false, - "last_signed_in": 1682917969773, - "total_time": 1730713597164 - }, - { - "user_id": 129, - "first_name": "Gregoria", - "last_name": "Mayert", - "password": "_RTrCpGhQkQB1NV", - "signed_in": true, - "last_signed_in": 1693427742715, - "total_time": 1728146478888 - }, - { - "user_id": 132, - "first_name": "Jany", - "last_name": "Konopelski", - "password": "WCLDCH7ho_3_Xps", - "signed_in": true, - "last_signed_in": 1701748297162, - "total_time": 1730578490273 - }, - { - "user_id": 139, - "first_name": "Fabian", - "last_name": "Willms", - "password": "doucyOfHhxUzpQt", - "signed_in": true, - "last_signed_in": 1682548850510, - "total_time": 1721517547012 - }, - { - "user_id": 148, - "first_name": "Eryn", - "last_name": "Lubowitz", - "password": "YIkVhlV78noYv6Q", - "signed_in": true, - "last_signed_in": 1696931969470, - "total_time": 1686739635580 - }, - { - "user_id": 156, - "first_name": "Ignacio", - "last_name": "Harvey", - "password": "ozlXxGt0RZJkOH0", - "signed_in": false, - "last_signed_in": 1698892828969, - "total_time": 1680592165624 - }, - { - "user_id": 157, - "first_name": "Rebeka", - "last_name": "Connelly", - "password": "fAY0m_xzvm3183l", - "signed_in": false, - "last_signed_in": 1692581313338, - "total_time": 1689886354015 - }, - { - "user_id": 160, - "first_name": "Bobbie", - "last_name": "Macejkovic", - "password": "o74HjPp9yctaW_X", - "signed_in": true, - "last_signed_in": 1682697838314, - "total_time": 1685526638885 - }, - { - "user_id": 166, - "first_name": "Mauricio", - "last_name": "Rath", - "password": "Q3PP333OIc14uCi", - "signed_in": true, - "last_signed_in": 1690598337817, - "total_time": 1730970964016 - }, - { - "user_id": 171, - "first_name": "Madisyn", - "last_name": "Hessel", - "password": "6XDoMQedOpV15_z", - "signed_in": false, - "last_signed_in": 1701463393146, - "total_time": 1703781816883 - }, - { - "user_id": 176, - "first_name": "Savanna", - "last_name": "Streich", - "password": "Ri94v5NJKrodS7X", - "signed_in": true, - "last_signed_in": 1681633881608, - "total_time": 1705589237781 - }, - { - "user_id": 183, - "first_name": "Zion", - "last_name": "Gorczany", - "password": "CWN10DzUDKx2AwI", - "signed_in": true, - "last_signed_in": 1685090780362, - "total_time": 1709099048817 - }, - { - "user_id": 192, - "first_name": "Kassandra", - "last_name": "Roob", - "password": "p37C1y8RMobD3G_", - "signed_in": true, - "last_signed_in": 1696678860621, - "total_time": 1730022977016 - }, - { - "user_id": 201, - "first_name": "Camren", - "last_name": "Walker", - "password": "glOUz01B1wYN7fL", - "signed_in": false, - "last_signed_in": 1685884086345, - "total_time": 1711580132397 - }, - { - "user_id": 210, - "first_name": "Marcelle", - "last_name": "Hills", - "password": "lkZ7dR17Jto5_CX", - "signed_in": true, - "last_signed_in": 1694155775938, - "total_time": 1690088287339 - }, - { - "user_id": 217, - "first_name": "Kasey", - "last_name": "Veum", - "password": "ftQynPdLw2ZRXAO", - "signed_in": false, - "last_signed_in": 1690514058162, - "total_time": 1687310392009 - }, - { - "user_id": 220, - "first_name": "Kamron", - "last_name": "Turner", - "password": "UTg3g2L7hAHVmQl", - "signed_in": true, - "last_signed_in": 1700580820950, - "total_time": 1676653381543 - }, - { - "user_id": 228, - "first_name": "Freddie", - "last_name": "Nolan", - "password": "16dzMjZ7Q8_JGs6", - "signed_in": true, - "last_signed_in": 1677177022775, - "total_time": 1678541896308 - }, - { - "user_id": 232, - "first_name": "Devon", - "last_name": "Sanford", - "password": "LkP0MzWkMZnChQr", - "signed_in": true, - "last_signed_in": 1686145583622, - "total_time": 1684516342414 - }, - { - "user_id": 240, - "first_name": "Louisa", - "last_name": "Lakin", - "password": "XbgrWvUV59XMXLn", - "signed_in": true, - "last_signed_in": 1705549002072, - "total_time": 1725116169270 - }, - { - "user_id": 247, - "first_name": "Ed", - "last_name": "Pouros", - "password": "MEaRMCo0THYBtQE", - "signed_in": false, - "last_signed_in": 1684013273604, - "total_time": 1730527388128 - }, - { - "user_id": 251, - "first_name": "Roberta", - "last_name": "Hintz", - "password": "6pZbJJKNAlKF_bk", - "signed_in": false, - "last_signed_in": 1697214123571, - "total_time": 1693830206835 - }, - { - "user_id": 259, - "first_name": "Dashawn", - "last_name": "Dach-Lindgren", - "password": "8epTiTpLAhoDoHm", - "signed_in": true, - "last_signed_in": 1687185068412, - "total_time": 1679112286989 - }, - { - "user_id": 265, - "first_name": "Danika", - "last_name": "Waters", - "password": "XacIKbhztD3QgRh", - "signed_in": true, - "last_signed_in": 1693688007229, - "total_time": 1719697409337 - }, - { - "user_id": 275, - "first_name": "Estel", - "last_name": "Ebert", - "password": "i5kYNEyCz7ifrX9", - "signed_in": false, - "last_signed_in": 1693995755135, - "total_time": 1678373683207 - }, - { - "user_id": 277, - "first_name": "Marcia", - "last_name": "Cartwright", - "password": "ov5HBCb6lEttuWT", - "signed_in": true, - "last_signed_in": 1682541416065, - "total_time": 1735129665126 - }, - { - "user_id": 283, - "first_name": "Cecil", - "last_name": "Stoltenberg", - "password": "QiPIL3eWpGw3ARS", - "signed_in": false, - "last_signed_in": 1695937671751, - "total_time": 1694652408585 - }, - { - "user_id": 285, - "first_name": "Deon", - "last_name": "Greenholt", - "password": "2WrIMOkgguRwbKt", - "signed_in": false, - "last_signed_in": 1685439324010, - "total_time": 1675731708499 - }, - { - "user_id": 287, - "first_name": "Audra", - "last_name": "Kovacek", - "password": "eUiOr6nRgpPMYSe", - "signed_in": true, - "last_signed_in": 1686225132445, - "total_time": 1736036517033 - }, - { - "user_id": 297, - "first_name": "Alfonso", - "last_name": "Haag", - "password": "Lkjxen7YSlEwmm4", - "signed_in": false, - "last_signed_in": 1688957842285, - "total_time": 1709043114512 - }, - { - "user_id": 300, - "first_name": "Kayden", - "last_name": "Becker", - "password": "DHbMUrm7PA0QoMP", - "signed_in": true, - "last_signed_in": 1686585128689, - "total_time": 1708357770998 - }, - { - "user_id": 303, - "first_name": "Isabel", - "last_name": "Kirlin", - "password": "_uh91EXNkcoYlS8", - "signed_in": false, - "last_signed_in": 1684176168353, - "total_time": 1702563186561 - }, - { - "user_id": 303, - "first_name": "Presley", - "last_name": "Gutmann", - "password": "akZHcrwDFNo38eK", - "signed_in": true, - "last_signed_in": 1678565963113, - "total_time": 1710809253848 - }, - { - "user_id": 312, - "first_name": "Gerda", - "last_name": "Pagac", - "password": "Ecuys8lTwDPRB7q", - "signed_in": false, - "last_signed_in": 1703417872295, - "total_time": 1719023001739 - }, - { - "user_id": 314, - "first_name": "Oren", - "last_name": "Tremblay", - "password": "sRNGOErELs1lyW5", - "signed_in": false, - "last_signed_in": 1684757736120, - "total_time": 1732782355178 - }, - { - "user_id": 316, - "first_name": "Cordie", - "last_name": "Hand", - "password": "OXNXlgJ5JMjr1jd", - "signed_in": false, - "last_signed_in": 1701434276945, - "total_time": 1718925212124 - }, - { - "user_id": 323, - "first_name": "Marcia", - "last_name": "Luettgen", - "password": "rYaLpfSxqRKKy3Y", - "signed_in": false, - "last_signed_in": 1704163677051, - "total_time": 1706336904338 - }, - { - "user_id": 328, - "first_name": "Tamia", - "last_name": "Koss", - "password": "SKSrfVRFiAT8XTH", - "signed_in": false, - "last_signed_in": 1697849579620, - "total_time": 1719612182527 - }, - { - "user_id": 332, - "first_name": "Emelia", - "last_name": "Botsford", - "password": "ZAOONNP5xBof5qC", - "signed_in": false, - "last_signed_in": 1692051658473, - "total_time": 1713113618222 - }, - { - "user_id": 334, - "first_name": "Devin", - "last_name": "Boehm", - "password": "l16W4N_t_SdBqGK", - "signed_in": false, - "last_signed_in": 1689706415321, - "total_time": 1733667523486 - }, - { - "user_id": 338, - "first_name": "Mossie", - "last_name": "Farrell", - "password": "X1UgvC8rqPH8eOW", - "signed_in": false, - "last_signed_in": 1693315728741, - "total_time": 1733949338480 - }, - { - "user_id": 348, - "first_name": "Hardy", - "last_name": "O'Reilly", - "password": "Xxp8T2Hau9PzGR1", - "signed_in": false, - "last_signed_in": 1686462761834, - "total_time": 1694235901144 - }, - { - "user_id": 351, - "first_name": "Odie", - "last_name": "Cormier", - "password": "0MBXisQBvQ5G81h", - "signed_in": false, - "last_signed_in": 1686875795159, - "total_time": 1699110773980 - }, - { - "user_id": 354, - "first_name": "Roberta", - "last_name": "Lowe", - "password": "HMBDyWs779gAFMw", - "signed_in": true, - "last_signed_in": 1682787078456, - "total_time": 1702887934971 - }, - { - "user_id": 354, - "first_name": "Precious", - "last_name": "Ullrich", - "password": "vehpPbP3bnfSL8q", - "signed_in": false, - "last_signed_in": 1679545513394, - "total_time": 1730799140293 - }, - { - "user_id": 358, - "first_name": "Freddy", - "last_name": "Kris", - "password": "GAoWIv_GGfxmE5d", - "signed_in": false, - "last_signed_in": 1676600775154, - "total_time": 1683131720024 - }, - { - "user_id": 365, - "first_name": "Dudley", - "last_name": "Schuster", - "password": "OU_iTvNwQRMQ760", - "signed_in": true, - "last_signed_in": 1696191874780, - "total_time": 1675644951063 - }, - { - "user_id": 365, - "first_name": "Harry", - "last_name": "Lehner", - "password": "JZX43HOpI4bIycf", - "signed_in": false, - "last_signed_in": 1689085533862, - "total_time": 1720033537799 - }, - { - "user_id": 371, - "first_name": "Josianne", - "last_name": "Spinka", - "password": "SMscHsz_lYKastO", - "signed_in": false, - "last_signed_in": 1683231017935, - "total_time": 1701729779042 - }, - { - "user_id": 371, - "first_name": "Anibal", - "last_name": "Wunsch", - "password": "3DoC1Fp3baLV5Br", - "signed_in": false, - "last_signed_in": 1677086323400, - "total_time": 1728935343509 - }, - { - "user_id": 373, - "first_name": "Toy", - "last_name": "Bins", - "password": "X2z6U81HXzjl8KM", - "signed_in": true, - "last_signed_in": 1691706189878, - "total_time": 1693074796639 - }, - { - "user_id": 382, - "first_name": "Brenda", - "last_name": "Bailey", - "password": "Knk5ak8yXC4UXV0", - "signed_in": true, - "last_signed_in": 1692523353955, - "total_time": 1724475611314 - }, - { - "user_id": 384, - "first_name": "Nick", - "last_name": "Bode", - "password": "gyP5bfIxpc0gOVO", - "signed_in": true, - "last_signed_in": 1700202146692, - "total_time": 1674563799789 - }, - { - "user_id": 391, - "first_name": "Krystina", - "last_name": "Pollich", - "password": "_ukDtkuTo3P2Cvr", - "signed_in": false, - "last_signed_in": 1685801131485, - "total_time": 1679683745557 - }, - { - "user_id": 397, - "first_name": "Osbaldo", - "last_name": "Mosciski", - "password": "L1iGvY2ivNvdO5y", - "signed_in": false, - "last_signed_in": 1679200151383, - "total_time": 1734342068273 - }, - { - "user_id": 406, - "first_name": "Jackson", - "last_name": "Schuster", - "password": "R2qlJWhz8ynTe94", - "signed_in": false, - "last_signed_in": 1702636308823, - "total_time": 1709986191919 - }, - { - "user_id": 415, - "first_name": "Donnie", - "last_name": "Mohr", - "password": "XyzwHvP55DWL2Xv", - "signed_in": false, - "last_signed_in": 1679704640910, - "total_time": 1730227569019 - }, - { - "user_id": 415, - "first_name": "Georgianna", - "last_name": "Jaskolski", - "password": "VFURoONGINp2Zkm", - "signed_in": false, - "last_signed_in": 1689939511773, - "total_time": 1732553573759 - }, - { - "user_id": 422, - "first_name": "Evert", - "last_name": "Stiedemann", - "password": "2Bx7Y6fyA_YRZny", - "signed_in": false, - "last_signed_in": 1684992523583, - "total_time": 1705690518221 - }, - { - "user_id": 427, - "first_name": "Beverly", - "last_name": "Pfannerstill", - "password": "DElzzWy_0WQa5Pw", - "signed_in": true, - "last_signed_in": 1695323704277, - "total_time": 1704236103377 - }, - { - "user_id": 431, - "first_name": "Danika", - "last_name": "Zieme", - "password": "uPeKUoz0PytxI_Y", - "signed_in": false, - "last_signed_in": 1691120108647, - "total_time": 1702328752717 - }, - { - "user_id": 432, - "first_name": "Aylin", - "last_name": "Collier", - "password": "yiv9k0Qz38_dRHO", - "signed_in": true, - "last_signed_in": 1699964363368, - "total_time": 1687755638520 - }, - { - "user_id": 441, - "first_name": "Alexandre", - "last_name": "Lemke", - "password": "xlOAeqZHutXpba8", - "signed_in": false, - "last_signed_in": 1678087843411, - "total_time": 1718229630060 - }, - { - "user_id": 449, - "first_name": "Vernice", - "last_name": "Runolfsson", - "password": "FIODtIqzvAyfWfC", - "signed_in": false, - "last_signed_in": 1693837876962, - "total_time": 1699637065294 - }, - { - "user_id": 459, - "first_name": "Josh", - "last_name": "MacGyver", - "password": "cmXRPpRgzR448gw", - "signed_in": true, - "last_signed_in": 1704222887813, - "total_time": 1722422058998 - }, - { - "user_id": 462, - "first_name": "Barry", - "last_name": "Towne", - "password": "yDZlWNLSOxzIuW_", - "signed_in": false, - "last_signed_in": 1693514075708, - "total_time": 1731054913166 - }, - { - "user_id": 467, - "first_name": "Clark", - "last_name": "Denesik", - "password": "DsnOuGIHdFchMLN", - "signed_in": false, - "last_signed_in": 1691912005537, - "total_time": 1721665632901 - }, - { - "user_id": 468, - "first_name": "Adam", - "last_name": "Schumm", - "password": "1h2WvYTIA5g4uEg", - "signed_in": true, - "last_signed_in": 1698808470948, - "total_time": 1714189073105 - }, - { - "user_id": 473, - "first_name": "Brook", - "last_name": "Blanda", - "password": "j8tHArbrYGclzlQ", - "signed_in": false, - "last_signed_in": 1685184860932, - "total_time": 1724286165109 - }, - { - "user_id": 481, - "first_name": "Sigurd", - "last_name": "Pagac", - "password": "SAxxsTPN17_FjP0", - "signed_in": false, - "last_signed_in": 1700099346673, - "total_time": 1732458747435 - }, - { - "user_id": 482, - "first_name": "Tyree", - "last_name": "Rippin-Cartwright", - "password": "olo9ms7hONESlzP", - "signed_in": true, - "last_signed_in": 1701258757504, - "total_time": 1719255556716 - }, - { - "user_id": 485, - "first_name": "Roosevelt", - "last_name": "Rutherford", - "password": "kiDRxKQFKafzkIO", - "signed_in": false, - "last_signed_in": 1704474424653, - "total_time": 1721583016367 - }, - { - "user_id": 495, - "first_name": "Edythe", - "last_name": "Gutmann", - "password": "OmInPB99JloQTRb", - "signed_in": false, - "last_signed_in": 1696196498045, - "total_time": 1725880092903 - }, - { - "user_id": 498, - "first_name": "Sasha", - "last_name": "Terry", - "password": "oxEMgh7Nhut0jkT", - "signed_in": false, - "last_signed_in": 1683051472956, - "total_time": 1700854596526 - }, - { - "user_id": 502, - "first_name": "Art", - "last_name": "Hahn", - "password": "nYfrV2gyAQuYE2O", - "signed_in": true, - "last_signed_in": 1692855778099, - "total_time": 1729850467251 - }, - { - "user_id": 508, - "first_name": "Lamont", - "last_name": "Kris", - "password": "pQAgg31JIA2jRph", - "signed_in": false, - "last_signed_in": 1689759078463, - "total_time": 1676084458874 - } -] diff --git a/src/e2e/get-all-users.e2e-spec.ts b/src/e2e/get-all-users.e2e-spec.ts index 0ba4ede..e6c9cc2 100644 --- a/src/e2e/get-all-users.e2e-spec.ts +++ b/src/e2e/get-all-users.e2e-spec.ts @@ -4,24 +4,44 @@ dotenv.config(); import request from "supertest"; import app from "../app"; +import { cleanUpDatabase, resetTables, setupDatabase } from "./helpers/database"; +import fakeUsers from "./data/fakeUsers"; +import User from "../models/User.model"; describe("/api/v1/info/users", () => { - beforeEach(() => { - + before(async () => { + await cleanUpDatabase(); + await setupDatabase(); + }); + + after(async () => { + await cleanUpDatabase(); + }); + + beforeEach(async () => { + await resetTables(); }); describe("GET request", () => { it("should return all users when database is not empty", () => { request(app) - .GET("/api/v1/info/users") + .get("/api/v1/info/users") .set("Accept", "application/json") .send() .expect(200) - .expect({ description: "Returning all users" }); - + .expect({ + description: "Returning all users", + users: structuredClone(fakeUsers).map((user: Partial) => { + delete user.password; + user.signed_in = (user.signed_in) ? 1 : 0 as any; + return user; + }), + }) + .end((err) => { + if (err) { + throw err; + } + }); }); - it("should return no users when database is empty", () => { - - }) }); -}); \ No newline at end of file +}); diff --git a/src/e2e/helpers/create-fake-data.ts b/src/e2e/helpers/create-fake-data.ts index 0d1545e..76f2317 100644 --- a/src/e2e/helpers/create-fake-data.ts +++ b/src/e2e/helpers/create-fake-data.ts @@ -1,12 +1,16 @@ import { faker } from "@faker-js/faker"; import fs from "fs"; +function removeSpecialCharacters(s: string): string { // TODO: Untested + return s.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, ""); +} + function generateFakeUser(userId: number) { return { user_id: userId, - first_name: faker.person.firstName(), - last_name: faker.person.lastName(), - password: faker.internet.password(), + first_name: removeSpecialCharacters(faker.person.firstName()), + last_name: removeSpecialCharacters(faker.person.lastName()), + password: removeSpecialCharacters(faker.internet.password()), signed_in: faker.datatype.boolean(), last_signed_in: faker.date.past().valueOf(), total_time: faker.date.anytime().valueOf(), @@ -17,9 +21,9 @@ export default () => { // UNUSED (ONLY USE ONCE AND SAVE THE DATA) let userData = []; let id = 1; for (let i = 0; i < 100; i++) { - id += faker.number.int(10); + id += faker.number.int(10) + 1; userData.push(generateFakeUser(id)); } - console.log(userData); - fs.writeFile(__dirname + "/fakeData.json", JSON.stringify(userData), () => {}); + + fs.writeFile("fakeData.ts", "export default " + JSON.stringify(userData), "utf-8", () => {}); } \ No newline at end of file diff --git a/src/e2e/helpers/database.ts b/src/e2e/helpers/database.ts new file mode 100644 index 0000000..f9ce0a0 --- /dev/null +++ b/src/e2e/helpers/database.ts @@ -0,0 +1,45 @@ +import db from "../../database"; +import User from "../../models/User.model"; +import fakeUsers from "../data/fakeUsers"; + +async function setupDatabase() { + await db.query(` + CREATE TABLE users ( + user_id INT(11) PRIMARY KEY, + first_name VARCHAR(200) NOT NULL, + last_name VARCHAR(200) NOT NULL, + password VARCHAR(200) UNIQUE NOT NULL, + signed_in BOOL NOT NULL, + last_signed_in BIGINT(20) NOT NULL, + total_time BIGINT(20) NOT NULL + ) + `); +} + +async function cleanUpDatabase() { + await db.query("DROP TABLE IF EXISTS users, sessions, configs"); +} + +async function resetTables() { + let usersParamList: any[][] = []; + fakeUsers.forEach((user: User) => { + usersParamList.push([ + user.user_id, + user.first_name, + user.last_name, + user.password, + user.signed_in, + user.last_signed_in, + user.total_time, + ]); + }); + + await db.query("TRUNCATE TABLE users"); + + const sql = `INSERT INTO users + (user_id, first_name, last_name, password, signed_in, last_signed_in, total_time) + VALUES ?`; + await db.query(sql, [usersParamList]); +} + +export { setupDatabase, cleanUpDatabase, resetTables }; diff --git a/src/e2e/helpers/setup-database.ts b/src/e2e/helpers/setup-database.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/models/Session.model.ts b/src/models/Session.model.ts index d2ebad1..f7a259b 100644 --- a/src/models/Session.model.ts +++ b/src/models/Session.model.ts @@ -23,9 +23,7 @@ async function getAllSessions(): Promise { async function getSessionsByUserId(user_id: number): Promise { const sql = "SELECT * FROM `sessions` WHERE user_id = ?"; - const [sessions] = await database.query(sql, [ - user_id, - ]); + const [sessions] = await database.query(sql, [user_id]); if (sessions.length < 1) { throw new RowNotFoundError("Session not found in table: sessions!"); @@ -34,14 +32,8 @@ async function getSessionsByUserId(user_id: number): Promise { return sessions; } -async function createSession( - user_id: number, - start_time: number, - end_time: number, - amended: boolean -): Promise { - const sql = - "INSERT INTO `sessions` (user_id, start_time, end_time, amended) SELECT user_id, ?, ?, ? FROM users WHERE user_id = ?)"; +async function createSession(user_id: number, start_time: number, end_time: number, amended: boolean): Promise { + const sql = "INSERT INTO `sessions` (user_id, start_time, end_time, amended) SELECT user_id, ?, ?, ? FROM users WHERE user_id = ?)"; const params = [start_time, end_time, amended, user_id]; const [resHeader] = await database.query(sql, params); @@ -49,44 +41,26 @@ async function createSession( return resHeader.affectedRows === 1; } -async function updateSession( - session_id: number, - values: Partial -): Promise { +async function updateSession(session_id: number, values: Partial): Promise { const update = updateBuilder("sessions", values, { session_id }); - const [resHeader] = await database.query( - update.query, - update.params - ); + const [resHeader] = await database.query(update.query, update.params); return resHeader.affectedRows === 1; } async function deleteSession(session_id: number): Promise { const sql = "DELETE FROM `sessions` WHERE session_id = ?"; - const [resHeader] = await database.query(sql, [ - session_id, - ]); + const [resHeader] = await database.query(sql, [session_id]); return resHeader.affectedRows === 1; } -async function deleteSessionsByUserPassword( - password: number -): Promise { - const sql = - "DELETE FROM `sessions` WHERE user_id = (SELECT user_id from users WHERE password = ?)"; +async function deleteSessionsByUserPassword(password: number): Promise { + const sql = "DELETE FROM `sessions` WHERE user_id = (SELECT user_id from users WHERE password = ?)"; const [resHeader] = await database.query(sql, [password]); return resHeader.affectedRows > 0; } export default Session; -export { - getAllSessions, - getSessionsByUserId, - createSession, - updateSession, - deleteSession, - deleteSessionsByUserPassword, -}; +export { getAllSessions, getSessionsByUserId, createSession, updateSession, deleteSession, deleteSessionsByUserPassword }; diff --git a/src/utils/update-builder.ts b/src/utils/update-builder.ts index b8feff1..2faa262 100644 --- a/src/utils/update-builder.ts +++ b/src/utils/update-builder.ts @@ -11,14 +11,11 @@ function updateBuilder(table: string, updates: { [key: string]: any }, condition }); } - let query = "UPDATE ? SET ?" - let params = [ - table, - updateList.join(", "), - ]; + let query = "UPDATE ? SET ?"; + let params = [table, updateList.join(", ")]; if (conditionList.length > 0) { - query += " WHERE ?" + query += " WHERE ?"; params.push(conditionList.join(" AND ")); } @@ -28,4 +25,4 @@ function updateBuilder(table: string, updates: { [key: string]: any }, condition }; } -export default updateBuilder; \ No newline at end of file +export default updateBuilder;