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

[No QA] Remove managerEmail and ownerEmail from Onyx #31664

Merged
merged 2 commits into from
Nov 29, 2023
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
12 changes: 12 additions & 0 deletions src/libs/migrations/PersonalDetailsByAccountID.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ export default function () {
delete newReport.participants;
}

if (lodashHas(newReport, ['ownerEmail'])) {
reportWasModified = true;
Log.info(`[Migrate Onyx] PersonalDetailsByAccountID migration: removing ownerEmail from report ${newReport.reportID}`);
delete newReport.ownerEmail;
}

if (lodashHas(newReport, ['managerEmail'])) {
reportWasModified = true;
Log.info(`[Migrate Onyx] PersonalDetailsByAccountID migration: removing managerEmail from report ${newReport.reportID}`);
delete newReport.managerEmail;
}

if (reportWasModified) {
onyxData[onyxKey] = newReport;
}
Expand Down
50 changes: 50 additions & 0 deletions tests/unit/MigrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,56 @@ describe('Migrations', () => {
},
});
}));

it('Should remove any instances of ownerEmail found in a report', () =>
Onyx.multiSet({
[`${ONYXKEYS.COLLECTION.REPORT}1`]: {
reportID: 1,
ownerEmail: 'fake@test.com',
ownerAccountID: 5,
},
})
.then(PersonalDetailsByAccountID)
.then(() => {
expect(LogSpy).toHaveBeenCalledWith('[Migrate Onyx] PersonalDetailsByAccountID migration: removing ownerEmail from report 1');
const connectionID = Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (allReports) => {
Onyx.disconnect(connectionID);
const expectedReport = {
reportID: 1,
ownerAccountID: 5,
};
expect(allReports[`${ONYXKEYS.COLLECTION.REPORT}1`]).toMatchObject(expectedReport);
},
});
}));

it('Should remove any instances of managerEmail found in a report', () =>
Onyx.multiSet({
[`${ONYXKEYS.COLLECTION.REPORT}1`]: {
reportID: 1,
managerEmail: 'fake@test.com',
managerID: 5,
},
})
.then(PersonalDetailsByAccountID)
.then(() => {
expect(LogSpy).toHaveBeenCalledWith('[Migrate Onyx] PersonalDetailsByAccountID migration: removing managerEmail from report 1');
const connectionID = Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (allReports) => {
Onyx.disconnect(connectionID);
const expectedReport = {
reportID: 1,
managerID: 5,
};
expect(allReports[`${ONYXKEYS.COLLECTION.REPORT}1`]).toMatchObject(expectedReport);
},
});
}));
});

describe('CheckForPreviousReportActionID', () => {
Expand Down
Loading