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

Add react router for navigation testing #2275

Open
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

alexneyman-MSFT
Copy link
Contributor

Description

This PR adds React Router to enable navigation between tabs when caching is enabled. There is no Nav component because tabs are populated in the appDefinition files. The onResume function is changed to navigate based on the URL provided.

Summarize the changes, including the goals and reasons for this change. Be sure to call out any technical or behavior changes that reviewers should be aware of.

If this Pull Request should close/resolve any issues when merged, use the special syntax for that here.

Main changes in the PR:

  1. add react router to the package
  2. add an empty page for testing
  3. enable routing in the app.tsx file
  4. update webpack config so the second page can be loaded by url

Validation performed:

  • change the URL to https://localhost:4000/second-page
  • ensure the content is an empty page
  • switch tabs with caching enabled in a test host and ensure the onResume function properly navigates to the empty page.

Unit Tests added:

Unit tests are required for all changes. If no unit tests were added as part of this change, please explain why they aren't necessary.

<Yes/No>

End-to-end tests added:

<Yes/No>

Additional Requirements

Change file added:

Ensure the change file meets the formatting requirements.

<Yes/No>

Related PRs:

Remove this section if n/a

Next/remaining steps:

List the next or remaining steps in implementing the overall feature in subsequent PRs (or is the feature 100% complete after this?).

Remove this section if n/a

  • Item 1
  • Item 2

Screenshots:

Remove this section if n/a

Before After
< image1 > < image2 >

@alexneyman-MSFT
Copy link
Contributor Author

@TrevorJoelHarris @lakhveerk, can you give this another look, had to remake the PR.

</>
}
/>
<Route path="/second-page" element={<EmptyPage />} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's your thoughts on renaming this route path to be /empty or /empty-page to be more descriptive.

I don't mind keeping it as second-page just wanted to get your opinion on this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i was thinking about the naming, maybe empty isn't right either because i'm including the appApi's in it since i want to use the getcontext call in e2e testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to go with secound-route here since i'm adding content to the page. open to suggestions still!

jadahiya-MSFT
jadahiya-MSFT previously approved these changes Apr 17, 2024
path="/"
element={
<>
<div className="App-container">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you feel about extracting this entire div into a separate file called TeamsTestApp.tsx and then just having this route render that

<Route
  path="/"
  element = {
    <TeamsTestApp/>
    }
    ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that!


const EmptyPage = (): ReactElement => (
<div>
This is an empty page.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a big deal, but it's sort of funny to see "This is an empty page" next to a component that makes it not an empty page (<AppApis />). Is there a reason the text is helpful?

Copy link
Contributor

@TrevorJoelHarris TrevorJoelHarris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one question

vikramtha and others added 19 commits May 9, 2024 11:26
* Removed beta tage on Pages.currentApp namespace and APIs

* Added changefile

* Update change/@microsoft-teams-js-51421b73-089f-43de-9076-75563e1f064c.json

---------

Co-authored-by: Trevor Harris <trharris@microsoft.com>
…yerPort (#2277)

Update Message Channel capability to support sub capabilities, add data layer capability with getDataLayerPort
---------

Co-authored-by: sumathin <sum_nat1@yahoo.com>
Co-authored-by: sumathin <sunatara@microsoft.com>
Co-authored-by: Trevor Harris <trharris@microsoft.com>
* backed out all exported const enums
* add sdf release yaml

---------

Co-authored-by: jadahiya-MSFT <95651173+jadahiya-MSFT@users.noreply.github.com>
Co-authored-by: Trevor Harris <trharris@microsoft.com>
* Update comment

* Update changefile
…onnector Plugins (#2272)

* Adding PPC auth

* Adding PPCauth UTs

* adding change file

* Resolving comments

* Resolving comments

* Modify hasScriptTags function to handle encoded Input

* Modify hasScriptTags function to handle encoded Input

* updating default input

* Modify hasScriptTags function to handle encoded Input

* adding telemetry tag for ppc auth

* Removing pluginId and adding unit tests

* Changing url to string before passign to psotmessage

* Removing regualr expression for html entities

* Removing regualr expression for html entities

* Modifying comments

* Modifying comments

* Resolving comments

* Resolving comments

---------

Co-authored-by: Lakhveer Kaur <lakhveerkaur@microsoft.com>
Co-authored-by: Erin <erinha@microsoft.com>
* Webstorage becomes capability

* Update webstorage in test app

* Update webstorage test json

* Add changefile

* Test updates

* Test updates

* Final test updates

* Helpful util

* Empty json test file
* Publish android artifacts

* Use 1ES publishing steps

* task names

* Use updated artifact location

* Add job attempt
* Added in new valid domains for Copilot Chat

* Added in changefile

---------

Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>
* Restrict authentication.authenticate to only accept https urls

* Create @microsoft-teams-js-40968a44-8220-4162-a289-038e99f5bee3.json

* Updated based on PR feedback

* Updated to use new validation functions and added(?) support for URL encoded strings

* abstract out the auth code's use of the a tag and then add tests to make sure URL encoded partial urls work correctly

* Re-order imports

* Updated based on PR feedback

---------

Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>
* Fix incorrect API telemetry label for Pages_NavigateToApp API

* update

* Update @microsoft-teams-js-d2040181-a9a1-42d2-9080-35acb3a380cd.json

---------

Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>
* Update sdf-release.yml for Azure Pipelines

* Update sdf-release.yml for Azure Pipelines
Co-authored-by: sthousto <sthousto@microsoft.com_odspmdb>
Co-authored-by: Trevor Harris <trharris@microsoft.com>
* Initial commit

* Update ci

* Update ci

* remove deprecated sub dependencies

* Specify exact version in ci
* Update .npmrc location

* Changefile

* Update @microsoft-teams-js-b63da2d9-3e02-4b83-9664-78aa8f49c713.json

* use new scripts for onebranch pipelines

---------

Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>
jekloudaMSFT and others added 2 commits May 9, 2024 11:27
* add prod pipeline

* restrict branches for prod pipeline

* add DDL pipeline
alexneyman-MSFT and others added 18 commits May 17, 2024 15:29
* Releasing 2.23.0 (#2309)

* Releasing 2.23.0

* Updated CHANGELOG

* Added changefile
* clear telemetryPort and dataLayerPort every time app._uninitialize is called

* Create @microsoft-teams-js-ace1fe2b-0c05-48f6-b3b4-bdecfe1fb665.json
* Adding dialogParentComm to test app

* nit fix

* nit changes

* fixing e2e
* Adding UUIDs to MessageRequests and MessageResponses

* Committing changefile

* Added in MessageID and MessageUUID types, added in testing for UUID communication and id as numbers communication

* Changing waitForResponse to have input of type MessageUUID

* Updated references to use MessageID and MessageUUID

* Fixed lint error

* Created BaseUUID type

* Added validation for uuid to handleParentMessage

* Only validate UUIDs if there is one

* Added in MessageUUID object

* Testing new changes to UUID

* Added in serialization of objects

* Updated to address PR feedback

* Added comment describing MessageID vs MessageUUID

* Added in helper function

* Removing comment since map.delete was verified to work correctly

* Moved uuid object to interfaces.ts for more general use

* Replaced Function in Map declarations

* Updated to use serialized and deserialized Message Response objects

* Added in unit tests for UUID class

* Fixed lint error

* Updating tests

* Moved uuid object to new file uuidObject.ts, edited changefile verbage

* Added in unit tests for testing callback map deletion and functionality

* Removed unnused import

* Added in logging for when a callbackID fails to be generated

* Fixed a typo in communication spec

* Updated serialization and deserialization and uuid toString function

* Reverted toString() change due to compatibility issues

* Removing unnecessary map clear due to already clearing in uninitialize and removeHandlers

* Fixed an issue with removing message ids

* Reverting uuid back to private

---------

Co-authored-by: Trevor Harris <trharris@microsoft.com>
Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>
* Add isBackgroundLoad for pageInfo context

* Added isBackgroundLoad property under page for app context.

The property indicates that the app is loading in the background as part
of an opt-in performance enhancement.

---------

Co-authored-by: jadahiya-MSFT <95651173+jadahiya-MSFT@users.noreply.github.com>
* Releasing 2.23.0 (#2309)

* Releasing 2.23.0

* Updated CHANGELOG

* Added changefile
* clear telemetryPort and dataLayerPort every time app._uninitialize is called

* Create @microsoft-teams-js-ace1fe2b-0c05-48f6-b3b4-bdecfe1fb665.json
* Adding dialogParentComm to test app

* nit fix

* nit changes

* fixing e2e
* Adding UUIDs to MessageRequests and MessageResponses

* Committing changefile

* Added in MessageID and MessageUUID types, added in testing for UUID communication and id as numbers communication

* Changing waitForResponse to have input of type MessageUUID

* Updated references to use MessageID and MessageUUID

* Fixed lint error

* Created BaseUUID type

* Added validation for uuid to handleParentMessage

* Only validate UUIDs if there is one

* Added in MessageUUID object

* Testing new changes to UUID

* Added in serialization of objects

* Updated to address PR feedback

* Added comment describing MessageID vs MessageUUID

* Added in helper function

* Removing comment since map.delete was verified to work correctly

* Moved uuid object to interfaces.ts for more general use

* Replaced Function in Map declarations

* Updated to use serialized and deserialized Message Response objects

* Added in unit tests for UUID class

* Fixed lint error

* Updating tests

* Moved uuid object to new file uuidObject.ts, edited changefile verbage

* Added in unit tests for testing callback map deletion and functionality

* Removed unnused import

* Added in logging for when a callbackID fails to be generated

* Fixed a typo in communication spec

* Updated serialization and deserialization and uuid toString function

* Reverted toString() change due to compatibility issues

* Removing unnecessary map clear due to already clearing in uninitialize and removeHandlers

* Fixed an issue with removing message ids

* Reverting uuid back to private

---------

Co-authored-by: Trevor Harris <trharris@microsoft.com>
Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>
name: 'RegisterOnResumeHandler',
title: 'Register On Resume Handler',
onClick: async (setResult) => {
app.lifecycle.registerOnResumeHandler((context: ResumeContext): void => {
setResult('successfully called with context:' + JSON.stringify(context));
app.notifySuccess();
window.setTimeout(() => {
app.notifySuccess();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should send notifySuccess after routing to a different location

@@ -128,74 +70,23 @@ export const generateRegistrationMsg = (changeCause: string): string => {
return `Registration attempt has been initiated. If successful, this message will change when ${changeCause}.`;
};

// button to route to the second route
export const SecondRouteButton = (): ReactElement => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the buttons for new static tabs show up through host code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet