Skip to content

Commit cda6616

Browse files
committed
PRO-10170 fix: replace reqres.in with dummyjson.com
1 parent 6692550 commit cda6616

26 files changed

Lines changed: 283 additions & 109 deletions

.eslintrc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ rules:
193193
'@typescript-eslint/no-loop-func': error
194194
'@typescript-eslint/no-magic-numbers':
195195
- error
196-
- ignore: [-2, -1, 0, 1, 2, 1024]
196+
- ignore: [-2, -1, 0, 1, 2, 1000, 1024]
197197
ignoreArrayIndexes: true
198198
ignoreDefaultValues: true
199199
ignoreEnums: true

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- run: npm run build
4040
- run: npm run test:local
4141
- uses: actions/upload-artifact@v4
42+
if: ${{ always() }}
4243
with:
4344
name: reports
4445
path: build/autotests/reports

autotests/entities/device.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const createDevice = async ({
1616
cookies,
1717
input: 7,
1818
model,
19+
title: model,
1920
version,
2021
});
2122

autotests/entities/product.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import type {ClientFunction} from 'e2ed/types';
88
*/
99
export const addProduct: ClientFunction<[Product], Promise<ApiProduct>> = createClientFunction(
1010
(product: Product) =>
11-
fetch(`https://reqres.in/api/product/${product.id}?size=${product.size}`, {
11+
fetch(`https://dummyjson.com/products/add?id=${product.id}&size=${product.size}`, {
1212
body: JSON.stringify({
1313
cookies: [],
1414
input: product.input,
1515
model: product.model,
16+
title: product.model,
1617
version: product.version,
1718
}),
18-
headers: {'Content-Type': 'application/json; charset=UTF-8', 'x-api-key': 'reqres-free-v1'},
19+
headers: {'Content-Type': 'application/json; charset=UTF-8'},
1920
method: 'POST',
2021
}).then((res) => res.json() as Promise<ApiProduct>),
2122
{name: 'addProduct', timeout: 2_000},

autotests/entities/worker.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ let clientGetUsersRetries: number | undefined;
1212
/**
1313
* Adds user-worker.
1414
*/
15-
export const addUser: ClientFunction<[UserWorker, number?], Promise<object>> = createClientFunction(
16-
(user: UserWorker, delay?: number) =>
17-
fetch(`https://reqres.in/api/users${delay !== undefined ? `?delay=${delay}` : ''}`, {
15+
export const addUser: ClientFunction<
16+
[Readonly<{delay?: number; user: UserWorker}>],
17+
Promise<object>
18+
> = createClientFunction(
19+
({delay, user}) =>
20+
fetch(`https://dummyjson.com/users/add${delay !== undefined ? `?delay=${delay}` : ''}`, {
1821
body: JSON.stringify(user),
19-
headers: {
20-
'Content-Type': 'application/json; charset=UTF-8',
21-
...(delay !== undefined && delay > 0 ? {'x-api-key': 'reqres-free-v1'} : undefined),
22-
},
22+
headers: {'Content-Type': 'application/json; charset=UTF-8'},
2323
method: 'POST',
24-
}),
24+
})
25+
.then((res) => res.json())
26+
.then((result: UserWorker) => {
27+
// eslint-disable-next-line no-console
28+
console.log('addUser return', result);
29+
30+
return result;
31+
}),
32+
2533
{name: 'addUser', timeout: 3_000},
2634
);
2735

@@ -36,7 +44,7 @@ export const getUsers = ({delay = 0, retries = 0}: GetUsersOptions = {}): Promis
3644

3745
clientGetUsers = createClientFunction(
3846
(clientDelay: number) =>
39-
fetch(`https://reqres.in/api/users?delay=${clientDelay}`, {method: 'GET'}).then(
47+
fetch(`https://dummyjson.com/users?delay=${clientDelay}`, {method: 'GET'}).then(
4048
(res) => res.json() as unknown,
4149
),
4250
{name: 'getUsers', retries, timeout: 6_000},

autotests/packs/allTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const pack: Pack = {
5252
deviceScaleFactor: 1,
5353
doAfterPack,
5454
doBeforePack,
55-
enableCsp: false,
55+
enableCsp: true,
5656
enableHeadlessMode: true,
5757
enableMobileDeviceMode: false,
5858
enableTouchEventEmulation: false,

autotests/pageObjects/pages/Main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class Main extends Page<CustomPageParams> {
6868
({url}) => {
6969
if (
7070
url.startsWith('https://img-s-msn-com.akamaized.net/') ||
71+
url.startsWith('https://rewards.bing.com/widget/') ||
7172
url.startsWith('https://www.bing.com/th?id=')
7273
) {
7374
return false;

autotests/routes/apiRoutes/AddUser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {Url} from 'e2ed/types';
66

77
type Params = Readonly<{delay?: number}>;
88

9-
const pathStart = '/api/users';
9+
const pathStart = '/users/add';
1010

1111
/**
1212
* Client API route for adding user-worker.
@@ -37,7 +37,7 @@ export class AddUser extends ApiRoute<Params, ApiAddUserRequest, ApiAddUserRespo
3737
}
3838

3939
override getOrigin(): Url {
40-
return 'https://reqres.in' as Url;
40+
return 'https://dummyjson.com' as Url;
4141
}
4242

4343
getPath(): string {

autotests/routes/apiRoutes/CreateProduct.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {Url} from 'e2ed/types';
88

99
type Params = Readonly<{id: ProductId; size: number}>;
1010

11-
const pathStart = '/api/product/';
11+
const pathStart = '/products/add';
1212

1313
/**
1414
* Test API route for creating a product.
@@ -27,7 +27,7 @@ export class CreateProduct extends ApiRoute<
2727
{urlObject},
2828
);
2929

30-
const id = Number(urlObject.pathname.slice(pathStart.length)) as ProductId;
30+
const id = Number(urlObject.searchParams.get('id')) as ProductId;
3131
const size = Number(urlObject.searchParams.get('size'));
3232

3333
assertValueIsTrue(Number.isInteger(id), 'url has correct id', {id, size, urlObject});
@@ -43,6 +43,6 @@ export class CreateProduct extends ApiRoute<
4343
getPath(): string {
4444
const {id, size} = this.routeParams;
4545

46-
return `${pathStart}${id}?size=${size}`;
46+
return `${pathStart}?id=${id}&size=${size}`;
4747
}
4848
}

autotests/routes/apiRoutes/GetUsers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {Url} from 'e2ed/types';
66

77
type Params = Readonly<{delay?: number}> | undefined;
88

9-
const pathStart = '/api/users';
9+
const pathStart = '/users';
1010

1111
/**
1212
* Client API route for getting users list.
@@ -37,7 +37,7 @@ export class GetUsers extends ApiRoute<Params, ApiGetUsersRequest, ApiGetUsersRe
3737
}
3838

3939
override getOrigin(): Url {
40-
return 'https://reqres.in' as Url;
40+
return 'https://dummyjson.com' as Url;
4141
}
4242

4343
getPath(): string {

0 commit comments

Comments
 (0)