Skip to content

Commit

Permalink
preloaded linking
Browse files Browse the repository at this point in the history
  • Loading branch information
perunt committed Jun 24, 2024
1 parent 037cdc1 commit 7fe8f3e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libs/E2E/reactNativeLaunchingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const tests: Tests = {
[E2EConfig.TEST_NAMES.ChatOpening]: require('./tests/chatOpeningTest.e2e').default,
[E2EConfig.TEST_NAMES.ReportTyping]: require('./tests/reportTypingTest.e2e').default,
[E2EConfig.TEST_NAMES.Linking]: require('./tests/linkingTest.e2e').default,
[E2EConfig.TEST_NAMES.PreloadedLinking]: require('./tests/preloadedLinkingTest.e2e').default,
};

// Once we receive the TII measurement we know that the app is initialized and ready to be used:
Expand Down
77 changes: 77 additions & 0 deletions src/libs/E2E/tests/preloadedLinkingTest.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import {DeviceEventEmitter} from 'react-native';
import type {NativeConfig} from 'react-native-config';
import Config from 'react-native-config';
import Timing from '@libs/actions/Timing';
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';
import ROUTES from '@src/ROUTES';

const test = (config: NativeConfig) => {
console.debug('[E2E] Logging in for comment linking');

const reportID = getConfigValueOrThrow('reportID', config);
const linkedReportActionID = getConfigValueOrThrow('linkedReportActionID', config);

E2ELogin().then((neededLogin) => {
if (neededLogin) {
return waitForAppLoaded().then(() => E2EClient.submitTestDone());
}

const [appearMessagePromise, appearMessageResolve] = getPromiseWithResolve();
const [switchReportPromise, switchReportResolve] = getPromiseWithResolve();

Promise.all([appearMessagePromise, switchReportPromise])
.then(() => {
console.debug('[E2E] Test completed successfully, exiting…');
E2EClient.submitTestDone();
})
.catch((err) => {
console.debug('[E2E] Error while submitting test results:', err);
});

const subscription = DeviceEventEmitter.addListener('onViewableItemsChanged', (res) => {
console.debug('[E2E] Viewable items retrieved, verifying correct message…', res);
if (!!res && res[0]?.item?.reportActionID === linkedReportActionID) {
appearMessageResolve();
subscription.remove();
} else {
console.debug(`[E2E] Provided message id '${res?.[0]?.item?.reportActionID}' doesn't match to an expected '${linkedReportActionID}'. Waiting for a next one…`);
}
});

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

if (entry.name === CONST.TIMING.REPORT_INITIAL_RENDER) {
console.debug('[E2E] Navigating to linked report action…');
Timing.start(CONST.TIMING.SWITCH_REPORT);
Performance.markStart(CONST.TIMING.SWITCH_REPORT);

Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID, linkedReportActionID));
return;
}

if (entry.name === CONST.TIMING.CHAT_RENDER) {
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Comment linking',
duration: entry.duration,
});

switchReportResolve();
}
});
});
};

export default test;
10 changes: 10 additions & 0 deletions tests/e2e/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const TEST_NAMES = {
ReportTyping: 'Report typing',
ChatOpening: 'Chat opening',
Linking: 'Linking',
PreloadedLinking: 'Preloaded linking',
};

/**
Expand Down Expand Up @@ -96,6 +97,15 @@ export default {
linkedReportID: '5421294415618529',
linkedReportActionID: '2845024374735019929',
},
[TEST_NAMES.PreloadedLinking]: {
name: TEST_NAMES.PreloadedLinking,
reportScreen: {
autoFocus: true,
},
// Crowded Policy (Do Not Delete) Report, has a input bar available:
reportID: '5421294415618529',
linkedReportActionID: '8984197495983183608', // Message 4897
},
},
};

Expand Down

0 comments on commit 7fe8f3e

Please sign in to comment.