Skip to content

Commit

Permalink
fix: internal tests by replacing google.com to bing.com
Browse files Browse the repository at this point in the history
  • Loading branch information
uid11 committed Jan 22, 2025
1 parent d34234f commit 026825b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 38 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ to correct the path to `autotests` directory accordingly:
},
```

After that you can run pack with tests in the project locally (sample tests are run on `google.com`):
After that you can run pack with tests in the project locally (sample tests are run on `bing.com`):

```sh
E2ED_ORIGIN=https://google.com npx e2ed ./autotests/packs/allTests.ts
E2ED_ORIGIN=https://bing.com npx e2ed ./autotests/packs/allTests.ts
```

Now you can edit tests, pageObject-s and other files in the `autotests` directory as you need.
Expand All @@ -109,10 +109,10 @@ Packs are usually stored in the `autotests/packs` directory.

### Run local

To run pack with tests locally for `https://google.com`:
To run pack with tests locally for `https://bing.com`:

```sh
E2ED_ORIGIN=https://google.com npx e2ed ./autotests/packs/allTests.ts
E2ED_ORIGIN=https://bing.com npx e2ed ./autotests/packs/allTests.ts
```

For convenience, you can add a command to run concrete pack in the `scripts` field
Expand All @@ -128,14 +128,14 @@ of the `package.json`:
After that, you can run the pack like this:

```sh
E2ED_ORIGIN=https://google.com npm run e2ed:allTests
E2ED_ORIGIN=https://bing.com npm run e2ed:allTests
```

Also, when running locally, you can pass additional
command-line arguments, such as the path to a specific test file from a pack, to run just that test:

```sh
E2ED_ORIGIN=https://google.com npm run e2ed:allTests ./autotests/tests/main/exists.ts
E2ED_ORIGIN=https://bing.com npm run e2ed:allTests ./autotests/tests/main/exists.ts
```

### Run in docker
Expand All @@ -146,10 +146,10 @@ You can download the latest `e2ed` docker image from https://hub.docker.com/r/e2
docker pull e2edhub/e2ed
```

And run tests for `https://google.com` in docker container:
And run tests for `https://bing.com` in docker container:

```sh
E2ED_ORIGIN=https://google.com ./autotests/bin/runDocker.sh ./autotests/packs/allTests.ts
E2ED_ORIGIN=https://bing.com ./autotests/bin/runDocker.sh ./autotests/packs/allTests.ts
```

For convenience, you can add a command to run concrete pack in docker in the `scripts` field
Expand All @@ -165,7 +165,7 @@ of the `package.json`:
After that, you can run the pack in docker like this:

```sh
E2ED_ORIGIN=https://google.com npm run e2ed:docker:allTests
E2ED_ORIGIN=https://bing.com npm run e2ed:docker:allTests
```

### Personal local pack for development
Expand Down Expand Up @@ -415,7 +415,7 @@ for both the application code and the autotest code.

You can pass the following optional environment variables to the `e2ed` process in any standard way:

`E2ED_ORIGIN`: origin-part of the url (`protocol` + `host`) on which the tests will be run. For example, `https://google.com`.
`E2ED_ORIGIN`: origin-part of the url (`protocol` + `host`) on which the tests will be run. For example, `https://bing.com`.

`E2ED_DEBUG`: run `e2ed` in `nodejs` debug mode (`--inspect-brk=0.0.0.0`) if this variable is not empty.

Expand Down
10 changes: 8 additions & 2 deletions autotests/configurator/mapBackendResponseToLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ export const mapBackendResponseToLog: MapBackendResponseToLog = ({
return undefined;
}

if (request.url.includes('&key=')) {
const {url} = request;

if (
url.startsWith('https://r.bing.com/rp/') ||
url.startsWith('https://www.bing.com/fd/') ||
url.includes('&key=')
) {
return undefined;
}

return {duration, statusCode, url: request.url};
return {duration, statusCode, url};
};
9 changes: 4 additions & 5 deletions autotests/pageObjects/pages/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Main extends Page<CustomPageParams> {
/**
* Header selector.
*/
readonly header: Selector = createSelector('[role=navigation]');
readonly header: Selector = createSelector('header');

/**
* Page language.
Expand Down Expand Up @@ -62,12 +62,11 @@ export class Main extends Page<CustomPageParams> {
}

override async waitForPageLoaded(): Promise<void> {
await this.waitForDomContentLoaded();

await waitForAllRequestsComplete(
({url}) => {
if (
url.startsWith('https://play.google.com/') ||
url.startsWith('https://www.youtube.com/embed/')
) {
if (url.startsWith('https://www.bing.com/th?id=')) {
return false;
}

Expand Down
19 changes: 1 addition & 18 deletions autotests/pageObjects/pages/Search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {MobilePage} from 'autotests/pageObjects';
import {Search as SearchRoute} from 'autotests/routes/pageRoutes';
import {waitForAllRequestsComplete} from 'e2ed/actions';
import {setReadonlyProperty} from 'e2ed/utils';

import type {GetParamsType} from 'e2ed/types';
Expand Down Expand Up @@ -35,22 +34,6 @@ export class Search extends MobilePage<CustomPageParams> {
}

override async waitForPageLoaded(): Promise<void> {
await waitForAllRequestsComplete(
({url}) => {
if (
url.startsWith('https://encrypted-tbn0.gstatic.com/') ||
url.startsWith('https://www.google.com/gen_204?') ||
url.startsWith('https://lh5.googleusercontent.com/') ||
url.startsWith('https://play.google.com/') ||
url.startsWith('https://www.googleadservices.com/') ||
url.startsWith('https://www.youtube.com/embed/')
) {
return false;
}

return true;
},
{maxIntervalBetweenRequestsInMs: this.maxIntervalBetweenRequestsInMs, timeout: 8_000},
);
await this.waitForDomContentLoaded();
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
"pretest:docker:copy": "rm -rf ./build/docker && mkdir --parents ./build/docker/node_modules/e2ed",
"test:docker:copy": "cp -R ./build/autotests ./build/docker/autotests && cp ./build/tsconfig.json ./build/docker",
"posttest:docker:copy": "rm -rf ./build/docker/autotests/reports && ./bin/addPackageJsonToBuildDocker.sh",
"test:docker": "(cd ./build/docker && E2ED_ORIGIN=https://google.com ./autotests/bin/runDocker.sh ./autotests/packs/allTests.ts)",
"test:local": "(cd ./build && E2ED_ORIGIN=https://google.com ./node_modules/e2ed/bin/localEntrypoint.sh ./autotests/packs/allTests.ts)"
"test:docker": "(cd ./build/docker && E2ED_ORIGIN=https://bing.com ./autotests/bin/runDocker.sh ./autotests/packs/allTests.ts)",
"test:local": "(cd ./build && E2ED_ORIGIN=https://bing.com ./node_modules/e2ed/bin/localEntrypoint.sh ./autotests/packs/allTests.ts)"
},
"sideEffects": false,
"types": "index.d.ts"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/report/render/locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {renderAttributes} from '../client';

import type {SafeHtml} from '../../../types/internal';

const isProduction = e2edEnvironment.E2ED_ORIGIN !== 'https://google.com';
const isProduction = e2edEnvironment.E2ED_ORIGIN !== 'https://bing.com';

const createLocatorOptions: CreateLocatorOptions = {attributesOptions, isProduction};

Expand Down

0 comments on commit 026825b

Please sign in to comment.