Skip to content

Commit

Permalink
Merge pull request #39394 from margelo/feat/chat-tti-mark
Browse files Browse the repository at this point in the history
feat: chat TTI
  • Loading branch information
mountiny authored Apr 9, 2024
2 parents 0424a94 + 4b8e5f3 commit bf1f86a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ const CONST = {
CALCULATE_MOST_RECENT_LAST_MODIFIED_ACTION: 'calc_most_recent_last_modified_action',
SEARCH_RENDER: 'search_render',
CHAT_RENDER: 'chat_render',
OPEN_REPORT: 'open_report',
HOMEPAGE_INITIAL_RENDER: 'homepage_initial_render',
REPORT_INITIAL_RENDER: 'report_initial_render',
SWITCH_REPORT: 'switch_report',
Expand Down
3 changes: 3 additions & 0 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import useWindowDimensions from '@hooks/useWindowDimensions';
import DateUtils from '@libs/DateUtils';
import DomUtils from '@libs/DomUtils';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import Performance from '@libs/Performance';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import * as ReportUtils from '@libs/ReportUtils';
import * as ReportActionContextMenu from '@pages/home/report/ContextMenu/ReportActionContextMenu';
Expand Down Expand Up @@ -123,6 +124,8 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
<PressableWithSecondaryInteraction
ref={popoverAnchor}
onPress={(event) => {
Performance.markStart(CONST.TIMING.OPEN_REPORT);

event?.preventDefault();
// Enable Composer to focus on clicking the same chat after opening the context menu.
ReportActionComposeFocusManager.focus();
Expand Down
54 changes: 41 additions & 13 deletions src/libs/E2E/tests/chatOpeningTest.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Config from 'react-native-config';
import type {NativeConfig} from 'react-native-config';
import E2ELogin from '@libs/E2E/actions/e2eLogin';
import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded';
import E2EClient from '@libs/E2E/client';
import getConfigValueOrThrow from '@libs/E2E/utils/getConfigValueOrThrow';
import getPromiseWithResolve from '@libs/E2E/utils/getPromiseWithResolve';
import Navigation from '@libs/Navigation/Navigation';
import Performance from '@libs/Performance';
import CONST from '@src/CONST';
Expand All @@ -23,29 +25,55 @@ const test = (config: NativeConfig) => {
}

console.debug('[E2E] Logged in, getting chat opening metrics and submitting them…');

const [renderChatPromise, renderChatResolve] = getPromiseWithResolve();
const [chatTTIPromise, chatTTIResolve] = getPromiseWithResolve();

Promise.all([renderChatPromise, chatTTIPromise]).then(() => {
console.debug(`[E2E] Submitting!`);

E2EClient.submitTestDone();
});

Performance.subscribeToMeasurements((entry) => {
if (entry.name === CONST.TIMING.SIDEBAR_LOADED) {
console.debug(`[E2E] Sidebar loaded, navigating to report…`);
Performance.markStart(CONST.TIMING.OPEN_REPORT);
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID));
return;
}

console.debug(`[E2E] Entry: ${JSON.stringify(entry)}`);
if (entry.name !== CONST.TIMING.CHAT_RENDER) {
return;

if (entry.name === CONST.TIMING.CHAT_RENDER) {
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Chat opening',
duration: entry.duration,
})
.then(() => {
console.debug('[E2E] Done with chat opening, exiting…');
renderChatResolve();
})
.catch((err) => {
console.debug('[E2E] Error while submitting test results:', err);
});
}

console.debug(`[E2E] Submitting!`);
E2EClient.submitTestResults({
name: 'Chat opening',
duration: entry.duration,
})
.then(() => {
console.debug('[E2E] Done with chat opening, exiting…');
E2EClient.submitTestDone();
if (entry.name === CONST.TIMING.OPEN_REPORT) {
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Chat TTI',
duration: entry.duration,
})
.catch((err) => {
console.debug('[E2E] Error while submitting test results:', err);
});
.then(() => {
console.debug('[E2E] Done with chat TTI tracking, exiting…');
chatTTIResolve();
})
.catch((err) => {
console.debug('[E2E] Error while submitting test results:', err);
});
}
});
});
};
Expand Down
9 changes: 9 additions & 0 deletions src/libs/E2E/utils/getPromiseWithResolve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function getPromiseWithResolve<T>(): [Promise<T | undefined>, (value?: T) => void] {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let resolveFn = (_value?: T) => {};
const promise = new Promise<T | undefined>((resolve) => {
resolveFn = resolve;
});

return [promise, resolveFn];
}
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ function ReportActionsView({
didLayout.current = true;
// Capture the init measurement only once not per each chat switch as the value gets overwritten
if (!ReportActionsView.initMeasured) {
Performance.markEnd(CONST.TIMING.OPEN_REPORT);
Performance.markEnd(CONST.TIMING.REPORT_INITIAL_RENDER);
Timing.end(CONST.TIMING.REPORT_INITIAL_RENDER);
ReportActionsView.initMeasured = true;
Expand Down

0 comments on commit bf1f86a

Please sign in to comment.