Skip to content
Open

Test #2897

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
30 changes: 13 additions & 17 deletions apps/teams-test-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ export const urlParams = new URLSearchParams(window.location.search);
const getOriginsParam = urlParams.has('origins') && urlParams.get('origins') ? urlParams.get('origins') : '';
const validMessageOrigins: string[] | undefined = getOriginsParam ? getOriginsParam.split(',') : undefined;

// This is added for custom initialization when app can be initialized based upon a trigger/click.
if (
(!urlParams.has('customInit') || !urlParams.get('customInit')) &&
(!urlParams.has('precacheApp') || !urlParams.get('precacheApp'))
) {
const hasCustomInit = urlParams.has('customInit') && urlParams.get('customInit');
const hasPrecacheApp = urlParams.has('precacheApp') && urlParams.get('precacheApp');
const hasAppInitTest =
urlParams.has(appInitializationTestQueryParameter) && urlParams.get(appInitializationTestQueryParameter);

const noCustomInit = !hasCustomInit;
const noPrecacheApp = !hasPrecacheApp;

if (noCustomInit && noPrecacheApp) {
if (isTestBackCompat()) {
initialize(undefined, validMessageOrigins);
} else {
Expand All @@ -30,18 +34,10 @@ if (

// for AppInitialization tests we need a way to stop the Test App from sending these
// we do it by adding appInitializationTest=true to query string
if (
(urlParams.has('customInit') && urlParams.get('customInit')) ||
(urlParams.has(appInitializationTestQueryParameter) &&
urlParams.get(appInitializationTestQueryParameter) &&
(!urlParams.has('precacheApp') || !urlParams.get('precacheApp')))
) {
if (hasCustomInit || (hasAppInitTest && noPrecacheApp)) {
window.addEventListener('message', handleMessageFromMockedHost);
console.info('Not calling appInitialization because part of App Initialization Test run');
} else if (
(!urlParams.has('precacheApp') || !urlParams.get('precacheApp')) &&
(!urlParams.has('customInit') || !urlParams.get('customInit'))
) {
} else if (noPrecacheApp && noCustomInit) {
if (isTestBackCompat()) {
appInitialization.notifyAppLoaded();
appInitialization.notifySuccess();
Expand All @@ -51,7 +47,7 @@ if (
}
}

if (urlParams.has('precacheApp') && urlParams.get('precacheApp')) {
if (hasPrecacheApp) {
app.initialize(validMessageOrigins).then(() => {
app.notifyAppLoaded();
app.lifecycle.registerBeforeSuspendOrTerminateHandler(() => {
Expand All @@ -62,7 +58,7 @@ if (urlParams.has('precacheApp') && urlParams.get('precacheApp')) {
app.lifecycle.registerOnResumeHandler((context: ResumeContext): void => {
// get the route from the context
console.log(context.contentUrl);
if (!urlParams.has('customInit') || !urlParams.get('customInit')) {
if (noCustomInit) {
app.notifySuccess();
}
});
Expand Down
Loading