Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test cases for activity feed backend #1976

Merged
merged 17 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions controllers/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ const fetchAllLogs = async (req, res) => {
return res.boom.badRequest("Please use feature flag to make this request!");
}
const logs = await logsQuery.fetchAllLogs(query);
if (!logs) {
if (logs.length === 0) {
return res.status(204).send();
}
const { allLogs, next, prev, page } = logs;
if (allLogs.length === 0) {
return res.status(204).send();
}

if (page) {
const pageLink = `/logs?page=${page}&dev=${query.dev}`;
return res.status(200).json({
Expand Down
2 changes: 1 addition & 1 deletion models/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const fetchAllLogs = async (query) => {
const usersMap = mapify(userList, "id");

if (allLogs.length === 0) {
return null;
return [];
}
if (format === "feed") {
let logsData = [];
Expand Down
5 changes: 1 addition & 4 deletions test/fixtures/logs/archievedUsers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const archivedUserDetailsModal = [
export const archivedUserDetailsModal = [
{
type: "archived-details",
meta: {},
Expand Down Expand Up @@ -63,6 +63,3 @@ const archivedUserDetailsModal = [
},
},
];
module.exports = {
archivedUserDetailsModal,
};
26 changes: 17 additions & 9 deletions test/fixtures/logs/extensionRequests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const extensionRequestLogs = [
export const extensionRequestLogs = [
{
meta: {
extensionRequestId: "y79PXir0s82qNAzeIn8S",
Expand Down Expand Up @@ -33,10 +33,16 @@ const extensionRequestLogs = [
},
{
meta: {
oldETA: 1695832836,
newETA: 1695832936,
taskId: "mZB0akqPUa1GQQdrgsx7",
createdBy: "XBucw7nHW1wOxdWrmLVa",
username: "joygupta",
},
body: {
assignee: "XBucw7nHW1wOxdWrmLVa",
extensionRequestId: "y79PXir0s82qNAzeIn8S",
userId: "XBucw7nHW1wOxdWrmLVa",
oldEndsOn: 1707264000,
newEndsOn: 1706918400,
status: "PENDING",
},
type: "extensionRequests",
timestamp: {
Expand All @@ -46,10 +52,16 @@ const extensionRequestLogs = [
},
{
meta: {
taskId: "mZB0akqPUa1GQQdrgsx7",
createdBy: "XBucw7nHW1wOxdWrmLVa",
username: "joygupta",
},
body: {
assignee: "XBucw7nHW1wOxdWrmLVa",
oldTitle: "Hello World",
newTitle: "Hello JS",
extensionRequestId: "y79PXir0s82qNAzeIn8S",
userId: "XBucw7nHW1wOxdWrmLVa",
status: "PENDING",
},
type: "extensionRequests",
timestamp: {
Expand All @@ -58,7 +70,3 @@ const extensionRequestLogs = [
},
},
];

module.exports = {
extensionRequestLogs,
};
50 changes: 50 additions & 0 deletions test/fixtures/logs/requests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export const requestsLogs = [
{
meta: {
createdAt: 1709175284035,
createdBy: "iODXB6ns8jaZB9p0XlBw",
requestId: "CNExxpR1F4UPbtYIpxFP",
action: "create",
},
type: "REQUEST_CREATED",
body: {
createdAt: 1709175282967,
requestedBy: "iODXB6ns8jaZB9p0XlBw",
from: 1711676421000,
until: 1714354821000,
id: "CNExxpR1F4UPbtYIpxFP",
state: "PENDING",
type: "OOO",
message: "Out of office for personal reasons.",
updatedAt: 1709175282967,
},
timestamp: {
_seconds: 1709175284,
_nanoseconds: 35000000,
},
},
{
meta: {
createdAt: 1709170848580,
createdBy: "iODXB6ns8jaZB9p0XlBw",
requestId: "K7ioni8arDgRCBAWwYxp",
action: "create",
},
type: "REQUEST_CREATED",
body: {
createdAt: 1709170848318,
requestedBy: "iODXB6ns8jaZB9p0XlBw",
from: 1711676421000,
until: 1714354821000,
id: "K7ioni8arDgRCBAWwYxp",
state: "PENDING",
type: "OOO",
message: "Out of office for personal reasons.",
updatedAt: 1709170848318,
},
timestamp: {
_seconds: 1709170848,
_nanoseconds: 580000000,
},
},
];
56 changes: 56 additions & 0 deletions test/fixtures/logs/tasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
export const taskLogs = [
{
meta: {
userId: "aaL1MXrpmnUNfLkhgXRj",
taskId: "P8ZZX2ef8heTs0erA6a8",
username: "shubham-sharma",
},
type: "task",
yesyash marked this conversation as resolved.
Show resolved Hide resolved
body: {
new: {
status: "NEEDS_REVIEW",
},
subType: "update",
},
timestamp: {
_seconds: 1710731591,
_nanoseconds: 323000000,
},
},
{
meta: {
userId: "aaL1MXrpmnUNfLkhgXRj",
taskId: "P8ZZX2ef8heTs0erA6a8",
username: "shubham-sharma",
},
type: "task",
body: {
new: {
status: "IN_PROGRESS",
},
subType: "update",
},
timestamp: {
_seconds: 1710731469,
_nanoseconds: 274000000,
},
},
{
meta: {
userId: "aaL1MXrpmnUNfLkhgXRj",
taskId: "P8ZZX2ef8heTs0erA6a8",
username: "shubham-sharma",
},
type: "task",
body: {
new: {
status: "BLOCKED",
},
subType: "update",
},
timestamp: {
_seconds: 1710731408,
_nanoseconds: 684000000,
},
},
];
Loading
Loading