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

[NoQA] E2E test. Linking, same page #44286

Merged
merged 7 commits into from
Jul 10, 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
1 change: 1 addition & 0 deletions src/libs/E2E/reactNativeLaunchingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const tests: Tests = {
[E2EConfig.TEST_NAMES.ChatOpening]: require<TestModule>('./tests/chatOpeningTest.e2e').default,
[E2EConfig.TEST_NAMES.ReportTyping]: require<TestModule>('./tests/reportTypingTest.e2e').default,
[E2EConfig.TEST_NAMES.Linking]: require<TestModule>('./tests/linkingTest.e2e').default,
[E2EConfig.TEST_NAMES.PreloadedLinking]: require<TestModule>('./tests/preloadedLinkingTest.e2e').default,
};

// Once we receive the TII measurement we know that the app is initialized and ready to be used:
Expand Down
82 changes: 82 additions & 0 deletions src/libs/E2E/tests/preloadedLinkingTest.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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';

type ViewableItem = {
reportActionID?: string;
};
type ViewableItemResponse = Array<{item?: ViewableItem}>;

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: ViewableItemResponse) => {
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',
metric: entry.duration,
});

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

export default test;
12 changes: 12 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 @@ -89,6 +90,7 @@ export default {
// #announce Chat with many messages
reportID: '5421294415618529',
},
// linking from chat A to a specific message in chat B
[TEST_NAMES.Linking]: {
name: TEST_NAMES.Linking,
reportScreen: {
Expand All @@ -99,6 +101,16 @@ export default {
linkedReportID: '5421294415618529',
linkedReportActionID: '2845024374735019929',
},
// linking from chat A to a specific message in the same chat A
[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
Loading