-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
amp-list: Hide placeholder et al. after re-render with local data #17209
amp-list: Hide placeholder et al. after re-render with local data #17209
Conversation
@@ -362,15 +363,17 @@ describes.realWin('amp-list component', { | |||
}); | |||
}); | |||
|
|||
it('should fail to load b/c data array is absent', () => { | |||
// TODO: This test passes but causes all following tests to be ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rsimha Are async throws still an issue? We may be silently skipping other tests too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@choumx Seems like there's an uncaught error originating from this test. I don't know if this is an async throw (rethrowAsync
is no longer asynchronous during tests). I suspect it's a case of #15658 being triggered.
Note: This sort of silent skipping should only happen during local development, where we surface unhandled errors.
Edit: I'm working on a more general fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amp-list doesn't use rethrowAsync
but it does throw errors asynchronously in some cases.
@@ -22,7 +22,8 @@ import {Deferred} from '../../../../src/utils/promise'; | |||
import {createCustomEvent} from '../../../../src/event-helper'; | |||
import {poll} from '../../../../testing/iframe'; | |||
|
|||
describes.realWin('amp-selector amp-list interaction', { | |||
// TODO(kevinkassimo): These tests appear to be failing at HEAD. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevinkassimo These tests are failing locally for me on master. Am I missing something?
willchou$ gulp test --nobuild --watch --files=extensions/amp-selector/0.1/test/test-selector-list.js
[01:00:01] Using gulpfile ~/Documents/amphtml/gulpfile.js
[01:00:01] Starting 'test'...
[01:00:01] Run gulp help to see a list of all test flags.
[01:00:01] ⤷ Use --nohelp to silence these messages.
[01:00:01] ⤷ Use --headless to run tests in a headless Chrome window.
[01:00:01] Running tests against unminified code.
[01:00:01] --nobuild: Skipping build.
[01:00:01] --watch: Enabling watch mode. Editing and saving a file will cause the tests for that file to be re-run in the same browser instance.
[01:00:01] --files: Running tests in the file(s): extensions/amp-selector/0.1/test/test-selector-list.js
[01:00:01] Setting the runtime's AMP config to prod
[01:00:01] Removed existing config from dist/amp.js
[01:00:01] Enabled local development mode in dist/amp.js
[01:00:01] Wrote prod AMP config to dist/amp.js
[01:00:01] Removed existing config from dist/v0.js
[01:00:01] Enabled local development mode in dist/v0.js
[01:00:01] Wrote prod AMP config to dist/v0.js
[01:00:01] Webserver started at http://localhost:31862
[01:00:01] Started test responses server on localhost:31862
[01:00:01] Running test. Press Ctrl + C to cancel...
[01:00:14] Running tests locally...
START:
amp-selector amp-list interaction
● should load selector options correctly with template
● "before each" hook
● "after each" hook for "should not call init again if no actual option is changed"
● "before each" hook
● "after each" hook
Finished in 1.437 secs / 0.149 secs @ 01:00:16 GMT-0400 (EDT)
SUMMARY:
● 1 test completed
● 4 tests failed
FAILED TESTS:
amp-selector amp-list interaction
● "before each" hook
Chrome 68.0.3440 (Mac OS X 10.13.5)
ReferenceError: sandbox is not defined
at Context.<anonymous> (Users/willchou/Documents/amphtml/extensions/amp-selector/0.1/test/test-selector-list.js:58:35)
● "after each" hook
Chrome 68.0.3440 (Mac OS X 10.13.5)
TypeError: Cannot read property 'call' of undefined
● "before each" hook
Chrome 68.0.3440 (Mac OS X 10.13.5)
Error: Uncaught Error: Missing resource prop on [object HTMLDivElement]
The test "amp-selector amp-list interaction should load selector options correctly with template" resulted in a call to console.error. (See above line.)
⤷ If the error is not expected, fix the code that generated the error.
⤷ If the error is expected (and synchronous), use the following pattern to wrap the test code that generated the error:
'allowConsoleError(() => { <code that generated the error> });'
⤷ If the error is expected (and asynchronous), use the following pattern at the top of the test:
'expectAsyncConsoleError(<string or regex>[, number of times the error message repeats]);' (/Users/willchou/Documents/amphtml/src/error.js:211:6 <- /var/folders/5m/xk80sl9x2sd131c_vz9dpmpr006wch/T/ddb86c6c1c0f0fad2e99960e10a22fea.browserify:39872)
● "after each" hook for "should not call init again if no actual option is changed"
Chrome 68.0.3440 (Mac OS X 10.13.5)
TypeError: Cannot read property 'customElements' of undefined
at AmpFixture.teardown (Users/willchou/Documents/amphtml/testing/describes.js:799:13)
at http://localhost:9876/Users/willchou/Documents/amphtml/testing/describes.js:347:19
at Array.forEach (<anonymous>)
at Context.<anonymous> (Users/willchou/Documents/amphtml/testing/describes.js:346:37)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be complaining undefined sandbox
. Have you tried adding sandbox = env.sandbox;
or sandbox = sinon.sandbox.create();
at the beginning of beforeEach
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might fix the first one... I'll let you figure out the others since you wrote it. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Seems to be cause by missing Resource registration. Explicitly added through Service and seems now the error messages are gone. Sending a PR to your branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@choumx Opened a PR on your fork. Sorry for the trouble. Ping me if it still does not work
Codecov Report
@@ Coverage Diff @@
## master #17209 +/- ##
==========================================
- Coverage 77.85% 77.82% -0.03%
==========================================
Files 562 562
Lines 41169 41164 -5
==========================================
- Hits 32052 32037 -15
- Misses 9117 9127 +10
Continue to review full report at Codecov.
|
Fix test-selector-list.js tests
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
…7209) * Hide placeholder/fallback/loading after rerender with local data. * Add comments. * Skip failing test-selector-list tests. * Fix test-selector-list.js tests
Fixes #17202.
This was caused by #16843. Previously, the placeholder was only shown and hidden in
fetchList_()
. The PR moved the "showing" to all re-render triggers, but did not copy the "hiding" to corresponding places. This causes the placeholder/fallback/loading to fail to be hidden when re-rendering with local data.Other things I noticed that I'd like to fix:
resetIfNecessary_
,hideFallbackAndPlaceholder_
,showFallback_
into a single function that takes a tri-state enum: FETCHING, SUCCESS, FAIL/to @aghassemi