* @param {{ * environment: *, * ampDriver: *, * controller: *, * }} param0 * @param {TestSpec} param1 * @return {Promise }
(
{ampDriver, controller, environment},
{experiments = [], initialRect, testUrl = '', version}
)
| 654 | * @return {Promise<void>} |
| 655 | */ |
| 656 | async function setUpTest( |
| 657 | {ampDriver, controller, environment}, |
| 658 | {experiments = [], initialRect, testUrl = '', version} |
| 659 | ) { |
| 660 | const url = new URL(testUrl); |
| 661 | |
| 662 | // When a component version is specified in the e2e spec, provide it as a |
| 663 | // request param. |
| 664 | if (version) { |
| 665 | url.searchParams.set('componentVersion', version); |
| 666 | } |
| 667 | |
| 668 | if (experiments.length > 0) { |
| 669 | if (environment.includes('inabox')) { |
| 670 | // inabox experiments are toggled at server side using <meta> tag |
| 671 | url.searchParams.set('exp', experiments.join(',')); |
| 672 | } else { |
| 673 | // AMP doc experiments are toggled via cookies |
| 674 | await toggleExperiments(ampDriver, url.href, experiments); |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | if (initialRect) { |
| 679 | const {height, width} = initialRect; |
| 680 | await controller.setWindowRect({width, height}); |
| 681 | } |
| 682 | |
| 683 | await ampDriver.navigateToEnvironment(environment, url.href); |
| 684 | } |
| 685 | |
| 686 | /** |
| 687 | * Toggle the given experiments for the given test URL domain. |
no test coverage detected