Skip to content

Move e2etest pages into rntester#5555

Merged
kmelmon merged 18 commits into
microsoft:masterfrom
kmelmon:rntester-phase1-take2
Jul 21, 2020
Merged

Move e2etest pages into rntester#5555
kmelmon merged 18 commits into
microsoft:masterfrom
kmelmon:rntester-phase1-take2

Conversation

@kmelmon

@kmelmon kmelmon commented Jul 18, 2020

Copy link
Copy Markdown
Contributor

Fixes #5484

This change prepares us to use RNTester as the primary app for end-to-end UI integration tests. Currently we use our own app inside E2ETest. This will limit us as we'd need to create test pages from scratch. We already have a lot of potential test coverage with RNTester, and we can add whatever pages we want to it as well, so let's use RNTester instead.

This change moves the 6 existing test pages over to RNTester and makes the necessary changes to the test app to load RNTester instead of the current app.

Microsoft Reviewers: Open in CodeFlow

@kmelmon kmelmon marked this pull request as ready for review July 20, 2020 20:27
@kmelmon kmelmon requested a review from a team as a code owner July 20, 2020 20:27
"HorizontalAlignment": "Stretch",
"Margin": "0,0,0,0",
"RenderSize": [800, 360],
"RenderSize": [759, 360],

@kmelmon kmelmon Jul 20, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

759 [](start = 17, length = 3)

These smaller widths are expected. RNTester has a container component that has margins on it, and this pages stretches across the entire available space, which is now smaller. #Resolved

@asklar asklar Jul 20, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the e2etest app had some code on startup which set the window size to 800x600 I believe, to ensure we get a consistent size. We should do that here too, otherwise the masters may not match if people ever resize/maximize etc #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That code in the app side is still there. Also the tree dumper control has code to resize to 800x600.


In reply to: 457682484 [](ancestors = 457682484)

Comment thread vnext/src/tsconfig.json Outdated
"strict": true,
"rootDir": "."
"rootDir": ".",
"esModuleInterop": true

@NickGerleman NickGerleman Jul 20, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could be breaking for code relying on previous esModule CommonJS interop behavior (e.g. import * is not callable with this enabled). What led to the need for the change and is it possible to change imports/exports to get the same effect? Note that TS has some special syntax for CommonJS interop as well.

The rest of the packages in the repo have this turned off, so having consistent behavior would be nice. #Pending

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All the tests were originally authored over in packages\e2etest with this turned on. So for example this line of code in AccessibilityTestPage.tsx won't compile without it turned on:

import React, { useState } from 'react'; => error TS1259: Module '"D:/rnw/node_modules/@types/react/index"' can only be default-imported using the 'esModuleInterop' flag

I honestly don't understand the error so I went the easy route and turned the option on. I'm happy to change the import if only I could understand, it's quite bizarre!


In reply to: 457675352 [](ancestors = 457675352)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reading this article over: https://itnext.io/great-import-schism-typescript-confusion-around-imports-explained-d512fc6769c2

The author recommends turning this option on: "...So I really advocate the usage of esModuleInterop option, cause it not only allows you to write less code, easier to read and spec-complaint code (and it's not just ranting, rollup for example won't allow you to use star imports in such way), but also mitigates some friction between typescript and babel communities."


In reply to: 457727708 [](ancestors = 457727708,457675352)

@NickGerleman NickGerleman Jul 20, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, Babel having it on by default and Typescript having it off by default is annoying. I'd kind of rather we have it off everywhere or on everywhere personally, and the risk of runtime issues makes me hesitant to turn it on anywhere where it used to be off.

The root cause of the issue is that CommonJS is still used internally for React, and Node, but ES6 modules added default imports which don't really have a commonJS equivalent. The interop setting sort of changes how Typescript or Babel projects a default import. My own preference has been to just avoid default import/export with anything interfacing with CommonJS since behavior is settings dependent.

I think the non esModuleInterop way to do this would be to have "import * as React from 'react'" on its own line instead of the default import. #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip. I turned the option off and fixed up all the imports to do it the "non-esModuleInterop" way. Would love to read an article that actually explains all of this, I feel like I came to the party after everyone else already is in the club, leaving me feeling rather clueless.


In reply to: 457742505 [](ancestors = 457742505)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the historical context of being used to CommonJS before ES6 helps. Finding an article explaining CommonJS, then looking at the ES6 article on MDN should give some context on the different models, and why default imports (or setting module.exports to a single function) are wonky.

The basic idea is that CommonJS modules export a single value. This is often an object that's an aggregate of exports, which maps directly to most of ES6, but ES6 default imports don't really have a CommonJS equivalent. Without esModuleInterop, a default import will look for the ".default" property of the CommonJS export, and agregate imports are callable, since CommonJS allows exporting single functions.

With interop on, idefault imports will import the entire aggregate object IIRC, and calling a CommonJS export requires doing a default import instead of importing all.


beforeAll(() => {
HomePage.backToHomePage();
// HomePage.backToHomePage();

@NickGerleman NickGerleman Jul 20, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we leave a comment about why this is commented out? #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the reminder. This code will never be necessary so I just removed it from all the tests.


In reply to: 457675832 [](ancestors = 457675832)

Comment thread vnext/overrides.json Outdated
},
{
"type": "platform",
"file": "src/RNTester/js/examples-win/LegacyTests/AccessibilityTestPage.tsx"

@NickGerleman NickGerleman Jul 20, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you want, you could also add "examples-win" to the list of unenforced directories at the top of the file and remove the overrides listed for it. Nothing in that directory should need three-way-merge, so it seems safe. #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


In reply to: 457676898 [](ancestors = 457676898)

@kmelmon kmelmon added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Jul 21, 2020
@ghost

ghost commented Jul 21, 2020

Copy link
Copy Markdown

Hello @kmelmon!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@kmelmon kmelmon removed the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Jul 21, 2020
@kmelmon kmelmon merged commit 59a2dcf into microsoft:master Jul 21, 2020
asklar pushed a commit to asklar/react-native-windows that referenced this pull request Jul 21, 2020
* first batch of changes

* Change files

* lint

* fix test failures, all due to margin within RNTester

* move (?) files

* refactor consts

* remove unused strings

* remove unreliable test

* increase app launch wait, removed unnecessary code

* exclude examples-win

* turn off esModuleInterop

* lint fix

* experimenting with sleep before test starts

* troubleshooting instability with first test:  try --no-launch param as test already launches the app

* test instability continued: issue may be due to FlatList virtualization.  Reordering items.

* revert --no-launch, this is unrelated

* it looks like the first test reliability issue is caused by killing/re-launching the test app.  Trying --no-launch option
facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Oct 21, 2020
Summary:
This change adds a testID to each item in the RNTester list.  This helps Appium find items in the list for automated tests.  The change was added in react-native-windows as part of end-to-end test infrastructure changes.    See microsoft/react-native-windows#5555

We'd like to remove this forked file, upstreaming this change will enable us to do that.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Changed] - add testID to items in RNTester test list, helps test automation tools find the items

Pull Request resolved: #30138

Test Plan: Change is currently running in react-native-windows CI loop.

Reviewed By: cpojer

Differential Revision: D24434352

Pulled By: appden

fbshipit-source-id: 998916d8fe4e4e4cd6ac764baabb9fd5f2e312c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert existing E2E test pages to RNTester pages

3 participants