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

Tests fixed for "beaman-continueMigration" branch #20351

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
2 changes: 1 addition & 1 deletion src/libs/UserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function getDefaultAvatar(accountID = -1) {
/**
* Helper method to return default avatar URL associated with login
*
* @param {String} [login]
* @param {String} [accountID]
* @param {Boolean} [isNewDot]
* @returns {String}
*/
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/sidebar/SidebarLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ const chatReportSelector = (report) =>
const personalDetailsSelector = (personalDetails) =>
_.reduce(
personalDetails,
(finalPersonalDetails, personalData, login) => {
(finalPersonalDetails, personalData, accountID) => {
// It's OK to do param-reassignment in _.reduce() because we absolutely know the starting state of finalPersonalDetails
// eslint-disable-next-line no-param-reassign
finalPersonalDetails[login] = {
finalPersonalDetails[accountID] = {
login: personalData.login,
displayName: personalData.displayName,
firstName: personalData.firstName,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/SidebarFilterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as Localize from '../../src/libs/Localize';
jest.mock('../../src/libs/Permissions');

const ONYXKEYS = {
PERSONAL_DETAILS: 'personalDetails',
PERSONAL_DETAILS_LIST: 'personalDetailsList',
NVP_PRIORITY_MODE: 'nvp_priorityMode',
SESSION: 'session',
BETAS: 'betas',
Expand Down
92 changes: 46 additions & 46 deletions tests/unit/SidebarOrderTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Sidebar', () => {

it('contains one report when a report is in Onyx', () => {
// Given a single report
const report = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']);
const report = LHNTestUtils.getFakeReport([1, 2]);
LHNTestUtils.getDefaultRenderedSidebarLinks(report.reportID);

return (
Expand All @@ -101,13 +101,13 @@ describe('Sidebar', () => {

// Given three unread reports in the recently updated order of 3, 2, 1
const report1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 3),
...LHNTestUtils.getFakeReport([1, 2], 3),
};
const report2 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 2),
...LHNTestUtils.getFakeReport([3, 4], 2),
};
const report3 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 1),
...LHNTestUtils.getFakeReport([5, 6], 1),
};

return (
Expand Down Expand Up @@ -140,11 +140,11 @@ describe('Sidebar', () => {
// And the first report has a draft
// And the currently viewed report is the first report
const report1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 3),
...LHNTestUtils.getFakeReport([1, 2], 3),
hasDraft: true,
};
const report2 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 2);
const report3 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 1);
const report2 = LHNTestUtils.getFakeReport([3, 4], 2);
const report3 = LHNTestUtils.getFakeReport([5, 6], 1);
const reportIDFromRoute = report1.reportID;
LHNTestUtils.getDefaultRenderedSidebarLinks(reportIDFromRoute);
return (
Expand Down Expand Up @@ -180,9 +180,9 @@ describe('Sidebar', () => {
LHNTestUtils.getDefaultRenderedSidebarLinks();

// Given three reports in the recently updated order of 3, 2, 1
const report1 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 3);
const report2 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 2);
const report3 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 1);
const report1 = LHNTestUtils.getFakeReport([1, 2], 3);
const report2 = LHNTestUtils.getFakeReport([3, 4], 2);
const report3 = LHNTestUtils.getFakeReport([5, 6], 1);

return (
waitForPromisesToResolve()
Expand Down Expand Up @@ -221,12 +221,12 @@ describe('Sidebar', () => {
// Given three reports in the recently updated order of 3, 2, 1
// And the second report has a draft
// And the currently viewed report is the second report
const report1 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 3);
const report1 = LHNTestUtils.getFakeReport([1, 2], 3);
const report2 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 2),
...LHNTestUtils.getFakeReport([3, 4], 2),
hasDraft: true,
};
const report3 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 1);
const report3 = LHNTestUtils.getFakeReport([5, 6], 1);
const reportIDFromRoute = report2.reportID;
LHNTestUtils.getDefaultRenderedSidebarLinks(reportIDFromRoute);

Expand Down Expand Up @@ -270,7 +270,7 @@ describe('Sidebar', () => {
// Given a single report
// And the report has a draft
const report = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([1, 2]),
hasDraft: true,
};

Expand Down Expand Up @@ -306,7 +306,7 @@ describe('Sidebar', () => {
// Given a single report
// And the report is pinned
const report = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([1, 2]),
isPinned: true,
};

Expand Down Expand Up @@ -342,22 +342,22 @@ describe('Sidebar', () => {
// with a report that has a draft, a report that is pinned, and
// an outstanding IOU report that doesn't belong to the current user
const report1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 3),
...LHNTestUtils.getFakeReport([1, 2], 3),
isPinned: true,
};
const report2 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 2),
...LHNTestUtils.getFakeReport([3, 4], 2),
hasDraft: true,
};
const report3 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 1),
...LHNTestUtils.getFakeReport([5, 6], 1),
hasOutstandingIOU: true,

// This has to be added after the IOU report is generated
iouReportID: null,
};
const iouReport = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([7, 8]),
type: CONST.REPORT.TYPE.IOU,
ownerEmail: '[email protected]',
managerEmail: '[email protected]',
Expand Down Expand Up @@ -407,19 +407,19 @@ describe('Sidebar', () => {
// Given three reports in the recently updated order of 3, 2, 1
// and they are all pinned
const report1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 3),
...LHNTestUtils.getFakeReport([1, 2], 3),
isPinned: true,
};
const report2 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 2),
...LHNTestUtils.getFakeReport([3, 4], 2),
isPinned: true,
};
const report3 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 1),
...LHNTestUtils.getFakeReport([5, 6], 1),
isPinned: true,
};
const report4 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 0),
...LHNTestUtils.getFakeReport([7, 8], 0),
isPinned: true,
};
LHNTestUtils.getDefaultRenderedSidebarLinks('0');
Expand Down Expand Up @@ -466,19 +466,19 @@ describe('Sidebar', () => {
// Given three reports in the recently updated order of 3, 2, 1
// and they all have drafts
const report1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 3),
...LHNTestUtils.getFakeReport([1, 2], 3),
hasDraft: true,
};
const report2 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 2),
...LHNTestUtils.getFakeReport([3, 4], 2),
hasDraft: true,
};
const report3 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 1),
...LHNTestUtils.getFakeReport([5, 6], 1),
hasDraft: true,
};
const report4 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 0),
...LHNTestUtils.getFakeReport([7, 8], 0),
hasDraft: true,
};
LHNTestUtils.getDefaultRenderedSidebarLinks('0');
Expand Down Expand Up @@ -524,13 +524,13 @@ describe('Sidebar', () => {
it('puts archived chats last', () => {
// Given three reports, with the first report being archived
const report1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([1, 2]),
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
statusNum: CONST.REPORT.STATUS.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
};
const report2 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']);
const report3 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']);
const report2 = LHNTestUtils.getFakeReport([3, 4]);
const report3 = LHNTestUtils.getFakeReport([5, 6]);

// Given the user is in all betas
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
Expand Down Expand Up @@ -566,10 +566,10 @@ describe('Sidebar', () => {
it('alphabetizes chats', () => {
LHNTestUtils.getDefaultRenderedSidebarLinks();

const report1 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 3, true);
const report2 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 2, true);
const report3 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 1, true);
const report4 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 0, true);
const report1 = LHNTestUtils.getFakeReport([1, 2], 3, true);
const report2 = LHNTestUtils.getFakeReport([3, 4], 2, true);
const report3 = LHNTestUtils.getFakeReport([5, 6], 1, true);
const report4 = LHNTestUtils.getFakeReport([7, 8], 0, true);

return (
waitForPromisesToResolve()
Expand Down Expand Up @@ -614,13 +614,13 @@ describe('Sidebar', () => {
it('puts archived chats last', () => {
// Given three unread reports, with the first report being archived
const report1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 3, true),
...LHNTestUtils.getFakeReport([1, 2], 3, true),
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
statusNum: CONST.REPORT.STATUS.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
};
const report2 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 2, true);
const report3 = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 1, true);
const report2 = LHNTestUtils.getFakeReport([3, 4], 2, true);
const report3 = LHNTestUtils.getFakeReport([5, 6], 1, true);

// Given the user is in all betas
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
Expand Down Expand Up @@ -654,28 +654,28 @@ describe('Sidebar', () => {
it('orders IOU reports by displayName if amounts are the same', () => {
// Given three IOU reports containing the same IOU amounts
const report1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([1, 2]),
hasOutstandingIOU: true,

// This has to be added after the IOU report is generated
iouReportID: null,
};
const report2 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([3, 4]),
hasOutstandingIOU: true,

// This has to be added after the IOU report is generated
iouReportID: null,
};
const report3 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([5, 6]),
hasOutstandingIOU: true,

// This has to be added after the IOU report is generated
iouReportID: null,
};
const iouReport1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([7, 8]),
type: CONST.REPORT.TYPE.IOU,
ownerEmail: '[email protected]',
managerEmail: '[email protected]',
Expand All @@ -685,7 +685,7 @@ describe('Sidebar', () => {
chatReportID: report3.reportID,
};
const iouReport2 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([9, 10]),
type: CONST.REPORT.TYPE.IOU,
ownerEmail: '[email protected]',
managerEmail: '[email protected]',
Expand All @@ -695,7 +695,7 @@ describe('Sidebar', () => {
chatReportID: report3.reportID,
};
const iouReport3 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([11, 12]),
type: CONST.REPORT.TYPE.IOU,
ownerEmail: '[email protected]',
managerEmail: '[email protected]',
Expand Down Expand Up @@ -746,15 +746,15 @@ describe('Sidebar', () => {
// Given three nonArchived reports created at the same time
const lastVisibleActionCreated = DateUtils.getDBTime();
const report1 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([1, 2]),
lastVisibleActionCreated,
};
const report2 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([3, 4]),
lastVisibleActionCreated,
};
const report3 = {
...LHNTestUtils.getFakeReport(['[email protected]', '[email protected]']),
...LHNTestUtils.getFakeReport([5, 6]),
lastVisibleActionCreated,
};

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/SidebarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.mock('../../src/libs/Permissions');
jest.mock('../../src/components/Icon/Expensicons');

const ONYXKEYS = {
PERSONAL_DETAILS: 'personalDetails',
PERSONAL_DETAILS_LIST: 'personalDetailsList',
NVP_PRIORITY_MODE: 'nvp_priorityMode',
SESSION: 'session',
BETAS: 'betas',
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/LHNTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ let lastFakeReportID = 0;
let lastFakeReportActionID = 0;

/**
* @param {String[]} participants
* @param {Number[]} participants
* @param {Number} millisecondsInThePast the number of milliseconds in the past for the last message timestamp (to order reports by most recent messages)
* @param {boolean} isUnread
* @returns {Object}
*/
function getFakeReport(participants = ['[email protected]', '[email protected]'], millisecondsInThePast = 0, isUnread = false) {
function getFakeReport(participants = [1, 2], millisecondsInThePast = 0, isUnread = false) {
const lastVisibleActionCreated = DateUtils.getDBTime(Date.now() - millisecondsInThePast);
return {
type: CONST.REPORT.TYPE.CHAT,
Expand Down