Skip to content
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

feat: clean up deprecated items in api-mock of SDKs and protractor testing #2740

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions migration-guides/12.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ The following items are **deprecated** and **will be removed** in the version **

### From [@o3r/testing](https://npmjs.com/package/@o3r/testing)

The following items from `@o3r/testing/src/core/protractor` are deprecated and will be removed in v13:
The following items from `@o3r/testing/src/core/protractor` are deprecated and will be removed in v13:
- `ComponentFixtureProfile` is deprecated.</br>Note: *please use Playwright instead*
- `Constructable` is deprecated.</br>Note: *please use Playwright instead*
- `convertPromise` is deprecated.</br>Note: *please use Playwright instead*
- `ComponentFixtureProfile`, `Constructable`, and `FixtureWithCustom` are deprecated.</br>Note: *please use Playwright instead*
- `FixtureWithCustom` is deprecated.</br>Note: *please use Playwright instead*
- `MatAutocomplete` is deprecated.</br>Note: *please use Playwright instead*
- `MatSelect` is deprecated.</br>Note: *please use Playwright instead*
- `O3rCheckboxElement` is deprecated.</br>Note: *please use Playwright instead*
Expand Down
3 changes: 1 addition & 2 deletions packages/@ama-sdk/core/src/clients/api-fetch-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@
exception = new ResponseJSONParseError(e.message || 'Fail to parse response body', (response && response.status) || 0, body, { apiName, operationId, url, origin });
}

// eslint-disable-next-line no-console -- `console.error` is supposed to be the default value if the `options` argument is not provided, can be removed in Otter v12.
const reviver = getResponseReviver(revivers, response, operationId, { disableFallback: this.options.disableFallback, log: console.error });
const reviver = getResponseReviver(revivers, response, operationId, { disableFallback: this.options.disableFallback });

Check warning on line 187 in packages/@ama-sdk/core/src/clients/api-fetch-client.ts

View check run for this annotation

Codecov / codecov/patch

packages/@ama-sdk/core/src/clients/api-fetch-client.ts#L187

Added line #L187 was not covered by tests
const replyPlugins = this.options.replyPlugins
? this.options.replyPlugins.map((plugin) => plugin.load<T>({
dictionaries: root && root.dictionaries,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,6 @@ export interface Api {
{{/apis}}
}

/**
* Mock APIs
* @deprecated use `getMockedApi` with {@link ApiClient} instead, will be removed in v12.
*/
export const myApi: Api = {
{{#noEmptyLines}}{{#trimComma}}{{#apis}}
{{#operations}}
{{#camelize}}{{classname}}{{/camelize}}: new api.{{classname}}(MOCK_SERVER),
{{/operations}}
{{/apis}}{{/trimComma}}{{/noEmptyLines}}
};

/**
* Retrieve mocked SDK Apis
* @param config configuration of the Api Client
* @deprecated use `getMockedApi` with {@link ApiClient} instead, will be removed in v12.
*/
export function getMockedApi(config?: string | BaseApiFetchClientConstructor): Api;
/**
* Retrieve mocked SDK Apis
* @param apiClient Api Client instance
Expand All @@ -46,24 +28,11 @@ export function getMockedApi(config?: string | BaseApiFetchClientConstructor): A
* const mocks = getMockedApi(new ApiFetchClient({ basePath: MOCK_SERVER_BASE_PATH }));
* ```
*/
export function getMockedApi(apiClient: ApiClient): Api;
/**
* Retrieve mocked SDK Apis
* @param config configuration of the Api Client
*/
export function getMockedApi(config?: string | BaseApiFetchClientConstructor | ApiClient): Api {
let apiConfigObj: ApiClient = MOCK_SERVER;
if (typeof config === 'string') {
apiConfigObj = new ApiFetchClient({basePath: config});
} else if (isApiClient(config)) {
apiConfigObj = config;
} else if (config) {
apiConfigObj = new ApiFetchClient(config);
}
export function getMockedApi(apiClient: ApiClient): Api {
return {
{{#noEmptyLines}}{{#trimComma}}{{#apis}}
{{#operations}}
{{#camelize}}{{classname}}{{/camelize}}: new api.{{classname}}(apiConfigObj),
{{#camelize}}{{classname}}{{/camelize}}: new api.{{classname}}(apiClient),
{{/operations}}
{{/apis}}{{/trimComma}}{{/noEmptyLines}}
};
Expand Down
1 change: 0 additions & 1 deletion packages/@o3r-training/showcase-sdk/src/spec/api-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
} from '@ama-sdk/client-fetch';
import {
ApiClient,
isApiClient,
} from '@ama-sdk/core';
import * as api from '../api';

Expand Down
7 changes: 6 additions & 1 deletion packages/@o3r-training/training-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"default": "./structure/src.json"
},
"./structure/spec.json": {
"default": "./structure/src.json"
"default": "./structure/spec.json"
},
".": {
"main": "./cjs/index.js",
Expand Down Expand Up @@ -63,11 +63,15 @@
"tslib": "^2.6.2"
},
"peerDependenciesMeta": {
"@ama-sdk/client-fetch": {
"optional": true
},
"isomorphic-fetch": {
"optional": true
}
},
"devDependencies": {
"@ama-sdk/client-fetch": "workspace:^",
"@ama-sdk/core": "workspace:^",
"@ama-sdk/schematics": "workspace:^",
"@angular-devkit/core": "~19.0.0",
Expand Down Expand Up @@ -119,6 +123,7 @@
"yaml-eslint-parser": "^1.2.2"
},
"peerDependencies": {
"@ama-sdk/client-fetch": "workspace:^",
"@ama-sdk/core": "workspace:^",
"isomorphic-fetch": "~3.0.0"
},
Expand Down
40 changes: 8 additions & 32 deletions packages/@o3r-training/training-sdk/src/spec/api-mock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { type ApiClient, isApiClient } from '@ama-sdk/core';
import { ApiFetchClient, type BaseApiFetchClientConstructor } from '@ama-sdk/core';

import {
ApiFetchClient,
} from '@ama-sdk/client-fetch';
import type {
ApiClient,
} from '@ama-sdk/core';
import * as api from '../api';

/**
Expand All @@ -13,20 +16,6 @@ export interface Api {
dummyApi: api.DummyApi;
}

/**
* Mock APIs
* @deprecated use `getMockedApi` with {@link ApiClient} instead, will be removed in v12.
*/
export const myApi: Api = {
dummyApi: new api.DummyApi(MOCK_SERVER)
};

/**
* Retrieve mocked SDK Apis
* @param config configuration of the Api Client
* @deprecated use `getMockedApi` with {@link ApiClient} instead, will be removed in v12.
*/
export function getMockedApi(config?: string | BaseApiFetchClientConstructor): Api;
/**
* Retrieve mocked SDK Apis
* @param apiClient Api Client instance
Expand All @@ -37,21 +26,8 @@ export function getMockedApi(config?: string | BaseApiFetchClientConstructor): A
* const mocks = getMockedApi(new ApiFetchClient({ basePath: MOCK_SERVER_BASE_PATH }));
* ```
*/
export function getMockedApi(apiClient: ApiClient): Api;
/**
* Retrieve mocked SDK Apis
* @param config configuration of the Api Client
*/
export function getMockedApi(config?: string | BaseApiFetchClientConstructor | ApiClient): Api {
let apiConfigObj: ApiClient = MOCK_SERVER;
if (typeof config === 'string') {
apiConfigObj = new ApiFetchClient({basePath: config});
} else if (isApiClient(config)) {
apiConfigObj = config;
} else if (config) {
apiConfigObj = new ApiFetchClient(config);
}
export function getMockedApi(apiClient: ApiClient): Api {
return {
dummyApi: new api.DummyApi(apiConfigObj)
dummyApi: new api.DummyApi(apiClient)
};
}
17 changes: 15 additions & 2 deletions packages/@o3r/testing/src/core/protractor/component-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import {
FixtureUsageError,
} from '../../errors/index';
import type {
ComponentFixtureProfile,
ComponentFixtureProfile as ComponentFixtureProfileCore,
Constructable as ConstructableCore,
FixtureWithCustom as FixtureWithCustomCore,
} from '../component-fixture';
import {
withTimeout,
} from '../helpers';
import {
ElementProfile,
O3rElement,
O3rElementConstructor,
} from './element';
Expand All @@ -28,7 +31,17 @@ import {
/**
* @deprecated Will be removed in v13, please use Playwright instead
*/
export type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';
export interface ComponentFixtureProfile<V extends ElementProfile = ElementProfile> extends ComponentFixtureProfileCore<V> {}

/**
* @deprecated Will be removed in v13, please use Playwright instead
*/
export interface FixtureWithCustom extends FixtureWithCustomCore {}

/**
* @deprecated Will be removed in v13, please use Playwright instead
*/
export interface Constructable<T extends ComponentFixtureProfile, U extends FixtureWithCustom = FixtureWithCustom> extends ConstructableCore<T, U> {}

/**
* Implementation of the fixture dedicated to protractor, hence using the webdriver to interact with the dom.
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6938,6 +6938,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@o3r-training/training-sdk@workspace:packages/@o3r-training/training-sdk"
dependencies:
"@ama-sdk/client-fetch": "workspace:^"
"@ama-sdk/core": "workspace:^"
"@ama-sdk/schematics": "workspace:^"
"@angular-devkit/core": "npm:~19.0.0"
Expand Down Expand Up @@ -6990,9 +6991,12 @@ __metadata:
typescript-eslint: "npm:~8.21.0"
yaml-eslint-parser: "npm:^1.2.2"
peerDependencies:
"@ama-sdk/client-fetch": "workspace:^"
"@ama-sdk/core": "workspace:^"
isomorphic-fetch: ~3.0.0
peerDependenciesMeta:
"@ama-sdk/client-fetch":
optional: true
isomorphic-fetch:
optional: true
languageName: unknown
Expand Down
Loading