Skip to content

Commit

Permalink
🏗 Enable import/order eslint rule in test/ and testing/ (#35601)
Browse files Browse the repository at this point in the history
* Enable import/order throughout test+testing

* Autofix test/

* Autofix testing/
  • Loading branch information
rcebulko committed Aug 10, 2021
1 parent 7dc536f commit 0587fd2
Show file tree
Hide file tree
Showing 162 changed files with 664 additions and 387 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ module.exports = {
},
},
{
'files': ['3p/**/*.js', 'src/**/*.js'],
'files': ['3p/**/*.js', 'src/**/*.js', 'test/**/*.js', 'testing/**/*.js'],
'rules': {'import/order': 2},
},
],
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/test-controller-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

import {ControllerPromise} from '../../build-system/tasks/e2e/controller-promise';
import sinon from /*OK*/ 'sinon';

import {ControllerPromise} from '../../build-system/tasks/e2e/controller-promise';

/**
* This is a unit test that is located with the E2E tests because it
* only tests the E2E features itself. It is not written like other E2E tests
Expand Down
4 changes: 3 additions & 1 deletion test/integration/builtins/test-amp-img.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/

import {AmpEvents} from '#core/constants/amp-events';
import {createCustomEvent} from '../../../src/event-helper';

import {
createFixtureIframe,
expectBodyToBecomeVisible,
poll,
} from '#testing/iframe';

import {createCustomEvent} from '../../../src/event-helper';

describes.sandboxed
.configure()
.enableIe()
Expand Down
4 changes: 3 additions & 1 deletion test/integration/builtins/test-amp-pixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*/

import {AmpPixel} from '#builtins/amp-pixel/amp-pixel';
import {BrowserController, RequestBank} from '#testing/test-helper';

import {createElementWithAttributes} from '#core/dom';

import {BrowserController, RequestBank} from '#testing/test-helper';

describes.sandboxed('amp-pixel', {}, function () {
describes.integration(
'amp-pixel macro integration test',
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import {BrowserController} from '#testing/test-helper';
import {poll} from '#testing/iframe';
import {BrowserController} from '#testing/test-helper';

describes.integration(
'on="..."',
Expand Down
12 changes: 8 additions & 4 deletions test/integration/test-amp-ad-3p.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
* limitations under the License.
*/

import {layoutRectLtwh} from '#core/dom/layout/rect';

import {forceExperimentBranch} from '#experiments';
import {ADS_INITIAL_INTERSECTION_EXP} from '#experiments/ads-initial-intersection-exp';

import {Services} from '#service';
import {createCustomEvent} from '../../src/event-helper';
import {createFixtureIframe, poll} from '#testing/iframe';
import {forceExperimentBranch} from '#experiments';
import {installPlatformService} from '#service/platform-impl';
import {layoutRectLtwh} from '#core/dom/layout/rect';

import {createFixtureIframe, poll} from '#testing/iframe';

import {createCustomEvent} from '../../src/event-helper';

const IFRAME_HEIGHT = 3000;
function createFixture() {
Expand Down
3 changes: 2 additions & 1 deletion test/integration/test-amp-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

import {BrowserController, RequestBank} from '#testing/test-helper';
import {parseQueryString} from '#core/types/string/url';

import {BrowserController, RequestBank} from '#testing/test-helper';

// TODO(wg-analytics): These tests time out on Firefox and Safari.
describes.sandboxed
.configure()
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test-amp-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {BrowserController} from '#testing/test-helper';
import {poll as classicPoll} from '#testing/iframe';
import {BrowserController} from '#testing/test-helper';

const TIMEOUT = 10000;

Expand Down
1 change: 1 addition & 0 deletions test/integration/test-amp-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {CommonSignals} from '#core/constants/common-signals';

import {whenUpgradedToCustomElement} from '../../src/amp-element-helpers';

const t = describes.sandboxed.configure().ifChrome();
Expand Down
3 changes: 2 additions & 1 deletion test/integration/test-amp-recaptcha-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

import {BrowserController, RequestBank} from '#testing/test-helper';
import {Deferred} from '#core/data-structures/promise';

import {poll} from '#testing/iframe';
import {BrowserController, RequestBank} from '#testing/test-helper';

// TODO(wg-components): These tests are broken on Firefox (as of v77). They
// also fail on Safari.
Expand Down
4 changes: 3 additions & 1 deletion test/integration/test-amp-skimlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
* limitations under the License.
*/

import {parseQueryString} from '#core/types/string/url';

import {BrowserController, RequestBank} from '#testing/test-helper';

import {PLATFORM_NAME} from '../../extensions/amp-skimlinks/0.1/constants';
import {parseQueryString} from '#core/types/string/url';

// Create fake test urls to replace skimlinks API urls.
// RequestBank allow us to check if an API request has been made
Expand Down
3 changes: 2 additions & 1 deletion test/integration/test-amp-story-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

import {BrowserController, RequestBank} from '#testing/test-helper';
import {parseQueryString} from '#core/types/string/url';

import {BrowserController, RequestBank} from '#testing/test-helper';

const config = describes.sandboxed.configure().skipEdge().skipSafari();

config.run('amp-story analytics', {}, () => {
Expand Down
6 changes: 4 additions & 2 deletions test/integration/test-amphtml-ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
* limitations under the License.
*/

import {RequestBank} from '#testing/test-helper';
import {maybeSwitchToCompiledJs} from '#testing/iframe';
import {parseQueryString} from '#core/types/string/url';

import {xhrServiceForTesting} from '#service/xhr-impl';

import {maybeSwitchToCompiledJs} from '#testing/iframe';
import {RequestBank} from '#testing/test-helper';

// TODO(wg-monetization, #29112): Unskip on Safari.
const t = describes.sandboxed.configure().skipSafari();

Expand Down
3 changes: 2 additions & 1 deletion test/integration/test-boilerplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* limitations under the License.
*/

import {createFixtureIframe, expectBodyToBecomeVisible} from '#testing/iframe';
import {getStyle} from '#core/dom/style';

import {createFixtureIframe, expectBodyToBecomeVisible} from '#testing/iframe';
import {isAnimationNone} from '#testing/test-helper';

const timeout = window.ampTestRuntimeConfig.mochaTimeout;
Expand Down
1 change: 1 addition & 0 deletions test/integration/test-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {AmpEvents} from '#core/constants/amp-events';

import {createFixtureIframe} from '#testing/iframe';

describes.sandboxed('Configuration', {}, function () {
Expand Down
1 change: 1 addition & 0 deletions test/integration/test-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import {AmpEvents} from '#core/constants/amp-events';
import {computedStyle} from '#core/dom/style';

import {createFixtureIframe, expectBodyToBecomeVisible} from '#testing/iframe';

describes.sandboxed.configure().run('CSS', {}, () => {
Expand Down
1 change: 1 addition & 0 deletions test/integration/test-double-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {AmpEvents} from '#core/constants/amp-events';

import {createFixtureIframe} from '#testing/iframe';

function checkElementUpgrade(element) {
Expand Down
1 change: 1 addition & 0 deletions test/integration/test-extensions-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {AmpEvents} from '#core/constants/amp-events';

import {createFixtureIframe} from '#testing/iframe';

// Checks if an amp element gets upgraded.
Expand Down
4 changes: 3 additions & 1 deletion test/integration/test-shadow-dom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
* limitations under the License.
*/

import {createFixtureIframe} from '#testing/iframe';
import {toggleExperiment} from '#experiments';

import {createFixtureIframe} from '#testing/iframe';

import {whenUpgradedToCustomElement} from '../../src/amp-element-helpers';

describes.sandboxed
Expand Down
3 changes: 2 additions & 1 deletion test/integration/test-toggle-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

import {BrowserController} from '#testing/test-helper';
import {setInitialDisplay, toggle} from '#core/dom/style';

import {BrowserController} from '#testing/test-helper';

describes.integration
.configure()
.enableIe()
Expand Down
15 changes: 9 additions & 6 deletions test/integration/test-video-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@
* limitations under the License.
*/

import {PlayingStates, VideoEvents} from '../../src/video-interface';
import {Services} from '#service';
import {dispatchCustomEvent, waitForChildPromise} from '#core/dom';
import {installVideoManagerForDoc} from '#service/video-manager-impl';
import {isAutoplaySupported, resetIsAutoplaySupported} from '#core/dom/video';
import {isLayoutSizeDefined} from '#core/dom/layout';
import {listenOncePromise} from '../../src/event-helper';
import {runVideoPlayerIntegrationTests} from './test-video-players-helper';
import {isAutoplaySupported, resetIsAutoplaySupported} from '#core/dom/video';
import {toArray} from '#core/types/array';

import {Services} from '#service';
import {installVideoManagerForDoc} from '#service/video-manager-impl';

import {runVideoPlayerIntegrationTests} from './test-video-players-helper';

import {listenOncePromise} from '../../src/event-helper';
import {PlayingStates, VideoEvents} from '../../src/video-interface';

// TODO(dvoytenko): These tests time out when run with the prod AMP config.
// See #11588.
describes.sandboxed
Expand Down
20 changes: 12 additions & 8 deletions test/integration/test-video-players-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,25 @@
* limitations under the License.
*/

import {removeElement} from '#core/dom';
import {detectIsAutoplaySupported} from '#core/dom/video';

import {toggleExperiment} from '#experiments';

import {Services} from '#service';
import {
VideoAnalyticsEvents,
VideoEvents,
VideoInterface,
} from '../../src/video-interface';

import {
createFixtureIframe,
expectBodyToBecomeVisible,
poll,
} from '#testing/iframe';
import {detectIsAutoplaySupported} from '#core/dom/video';

import {getData, listenOncePromise} from '../../src/event-helper';
import {removeElement} from '#core/dom';
import {toggleExperiment} from '#experiments';
import {
VideoAnalyticsEvents,
VideoEvents,
VideoInterface,
} from '../../src/video-interface';

function skipIfAutoplayUnsupported(win) {
return detectIsAutoplaySupported(win).then((isSupported) => {
Expand Down
6 changes: 4 additions & 2 deletions test/integration/test-visibility-states.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
* limitations under the License.
*/

import {Services} from '#service';
import {VisibilityState} from '#core/constants/visibility-state';
import {createCustomEvent} from '../../src/event-helper';
import {getVendorJsPropertyName} from '#core/dom/style';

import {Services} from '#service';

import {whenUpgradedToCustomElement} from '../../src/amp-element-helpers';
import {createCustomEvent} from '../../src/event-helper';

const t = describes.sandboxed
.configure()
Expand Down
7 changes: 5 additions & 2 deletions test/unit/3p/test-3p-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
*/

import {DomFingerprint} from '#core/dom/fingerprint';
import {Services} from '#service';
import {WindowInterface} from '#core/window/interface';

import {toggleExperiment} from '#experiments';

import {Services} from '#service';

import {
addDataAndJsonAttributes_,
applySandbox,
Expand All @@ -33,7 +37,6 @@ import {
serializeMessage,
} from '../../../src/3p-frame-messaging';
import {dev} from '../../../src/log';
import {toggleExperiment} from '#experiments';

describes.realWin('3p-frame', {amp: true}, (env) => {
let window, document;
Expand Down
5 changes: 4 additions & 1 deletion test/unit/3p/test-3p-messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

/* eslint-disable import/no-deprecated */

import {listenParent} from '#3p/messaging';

import {Services} from '#service';

import {createIframePromise} from '#testing/iframe';
import {listenParent} from '#3p/messaging';

import {postMessage} from '../../../src/iframe-helper';

describes.sandboxed('3p messaging', {}, () => {
Expand Down
1 change: 1 addition & 0 deletions test/unit/3p/test-iframe-messaging-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {IframeMessagingClient} from '#3p/iframe-messaging-client';

import {serializeMessage} from '../../../src/3p-frame-messaging';

describes.realWin('iframe-messaging-client', {}, (env) => {
Expand Down
3 changes: 2 additions & 1 deletion test/unit/3p/test-recaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/

import {doesOriginDomainMatchIframeSrc, initRecaptcha} from '#3p/recaptcha';
import {parseUrlDeprecated} from '../../../src/url';

import {urls} from '../../../src/config';
import {parseUrlDeprecated} from '../../../src/url';

describes.sandboxed('3p recaptcha.js', {}, () => {
it('should require a window.name', () => {
Expand Down
1 change: 1 addition & 0 deletions test/unit/ads/test-adplugg.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {adplugg} from '#ads/vendors/adplugg';

import {createIframePromise} from '#testing/iframe';

describes.fakeWin('amp-ad-adplugg-impl', {}, (env) => {
Expand Down
2 changes: 2 additions & 0 deletions test/unit/ads/test-aduptech.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
* limitations under the License.
*/
import * as _3p from '#3p/3p';

import {
ADUPTECH_API_URL,
ADUPTECH_ELEMENT_ID,
aduptech,
} from '#ads/vendors/aduptech';

import {createIframePromise} from '#testing/iframe';

describes.fakeWin('amp-ad-aduptech-impl', {}, (env) => {
Expand Down

0 comments on commit 0587fd2

Please sign in to comment.