Skip to content

Commit

Permalink
Code clean-ups (#1035)
Browse files Browse the repository at this point in the history
* chore: move Che definitions

Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>

* chore: update mock paths in 'spec' files

Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>

* fixup! chore: move Che definitions

* fixup! fixup! chore: move Che definitions

---------

Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
  • Loading branch information
akurinnoy authored Jan 17, 2024
1 parent 4d050a2 commit fb4e0c6
Show file tree
Hide file tree
Showing 93 changed files with 310 additions and 275 deletions.
5 changes: 3 additions & 2 deletions .deps/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
| [`@csstools/selector-specificity@3.0.0`](https://github.com/csstools/postcss-plugins.git) | MIT-0 | transitive dependency |
| [`@devfile/api@2.2.2-1700686170`](https://github.com/GIT_USER_ID/GIT_REPO_ID.git) | Apache-2.0 | N/A |
| [`@discoveryjs/json-ext@0.5.7`](https://github.com/discoveryjs/json-ext.git) | MIT | clearlydefined |
| `@eclipse-che/api@7.80.0` | EPL-2.0 | ecd.che |
| [`@eslint-community/eslint-utils@4.4.0`](https://github.com/eslint-community/eslint-utils) | MIT | #8032 |
| [`@eslint-community/regexpp@4.10.0`](https://github.com/eslint-community/regexpp) | MIT | clearlydefined |
| [`@eslint/eslintrc@2.1.3`](https://github.com/eslint/eslintrc.git) | MIT | #9908 |
Expand Down Expand Up @@ -808,7 +809,7 @@
| [`safe-regex-test@1.0.0`](git+https://github.com/ljharb/safe-regex-test.git) | MIT | clearlydefined |
| [`saxes@6.0.0`](https://github.com/lddubeau/saxes.git) | ISC | clearlydefined |
| [`schema-utils@4.2.0`](https://github.com/webpack/schema-utils.git) | MIT | #8986 |
| [`serialize-javascript@6.0.1`](git+https://github.com/yahoo/serialize-javascript.git) | BSD-3-Clause | clearlydefined |
| [`serialize-javascript@6.0.1`](git+https://github.com/yahoo/serialize-javascript.git) | BSD-3-Clause | #12680 |
| [`set-blocking@2.0.0`](git+https://github.com/yargs/set-blocking.git) | ISC | #5899 |
| [`set-function-name@2.0.1`](git+https://github.com/ljharb/set-function-name.git) | MIT | #10590 |
| [`shallow-clone@3.0.1`](https://github.com/jonschlinkert/shallow-clone.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -852,7 +853,7 @@
| [`strip-final-newline@2.0.0`](https://github.com/sindresorhus/strip-final-newline.git) | MIT | clearlydefined |
| [`strip-indent@3.0.0`](https://github.com/sindresorhus/strip-indent.git) | MIT | clearlydefined |
| [`strong-log-transformer@2.1.0`](git://github.com/strongloop/strong-log-transformer) | Apache-2.0 | #1138 |
| [`style-loader@3.3.3`](https://github.com/webpack-contrib/style-loader.git) | MIT | clearlydefined |
| [`style-loader@3.3.3`](https://github.com/webpack-contrib/style-loader.git) | MIT | #12669 |
| [`style-search@0.1.0`](git+https://github.com/davidtheclark/style-search.git) | ISC | clearlydefined |
| [`stylehacks@6.0.0`](https://github.com/cssnano/cssnano.git) | MIT | clearlydefined |
| [`stylelint-config-clean-order@5.2.0`](https://github.com/kutsan/stylelint-config-clean-order.git) | MIT | clearlydefined |
Expand Down
6 changes: 3 additions & 3 deletions .deps/prod.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
| [`@devfile/api@2.2.0-alpha-1637255314`](https://github.com/devfile/api.git) | EPL-2.0 | clearlydefined |
| `@eclipse-che/api@7.76.0` | EPL-2.0 | ecd.che |
| [`@eclipse-che/che-devworkspace-generator@7.79.0-next-1427c19`](git+https://github.com/eclipse-che/che-devfile-registry.git) | EPL-2.0 | ecd.che |
| [`@eclipse-che/common@7.79.0-next`](https://github.com/eclipse-che/che-dashboard) | EPL-2.0 | ecd.che |
| [`@eclipse-che/dashboard-backend@7.79.0-next`](https://github.com/eclipse-che/che-dashboard) | EPL-2.0 | ecd.che |
| [`@eclipse-che/dashboard-frontend@7.79.0-next`](git://github.com/eclipse/che-dashboard.git) | EPL-2.0 | ecd.che |
| [`@eclipse-che/common@7.81.0-next`](https://github.com/eclipse-che/che-dashboard) | EPL-2.0 | ecd.che |
| [`@eclipse-che/dashboard-backend@7.81.0-next`](https://github.com/eclipse-che/che-dashboard) | EPL-2.0 | ecd.che |
| [`@eclipse-che/dashboard-frontend@7.81.0-next`](git://github.com/eclipse/che-dashboard.git) | EPL-2.0 | ecd.che |
| [`@eclipse-che/devfile-converter@0.0.1-0751ad2`](git+https://github.com/che-incubator/devfile-converter.git) | EPL-2.0 | ecd.che |
| [`@fastify/accept-negotiator@1.1.0`](git+https://github.com/fastify/accept-negotiator.git) | MIT | clearlydefined |
| [`@fastify/ajv-compiler@3.5.0`](git+https://github.com/fastify/ajv-compiler.git) | MIT | clearlydefined |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { CustomObjectsApi } from '@kubernetes/client-node';
import { CheClusterCustomResource, CustomResourceDefinitionList } from '@/devworkspaceClient';
import { ServerConfigApiService } from '@/devworkspaceClient/services/serverConfigApi';

jest.mock('../../../helpers/getUserName.ts');
jest.mock('@/helpers/getUserName.ts');

describe('Server Config API Service', () => {
const env = process.env;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CoreV1Api, V1Secret } from '@kubernetes/client-node';

import { UserProfileApiService } from '@/devworkspaceClient/services/userProfileApi';

jest.mock('../../../helpers/getUserName.ts');
jest.mock('@/helpers/getUserName.ts');

const userNamespace = 'user1-che';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { IncomingMessage } from 'http';

import { GitConfigApiService } from '..';

jest.mock('../../helpers/retryableExec');
jest.mock('@/devworkspaceClient/services/helpers/retryableExec.ts');

const namespace = 'user-che';
const responseBody = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jest.mock('../const', () => ({
}));

const mockDelay = jest.fn().mockImplementation(() => Promise.resolve());
jest.mock('../../../../services/helpers', () => ({
jest.mock('@/services/helpers', () => ({
delay: (ms: number) => mockDelay(ms),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jest.mock('../helpers', () => {
toSecret: (...args: Parameters<(typeof originalModule)['toSecret']>) => mockToSecret(...args),
};
});
jest.mock('../../helpers/retryableExec');
jest.mock('@/devworkspaceClient/services/helpers/retryableExec.ts');

const namespace = 'user-che';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jest.mock('../helpers', () => {
toSecret: (...args: Parameters<(typeof originalModule)['toSecret']>) => mockToSecret(...args),
};
});
jest.mock('../../helpers/retryableExec');
jest.mock('@/devworkspaceClient/services/helpers/retryableExec.ts');

const namespace = 'user-che';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

import { DwClientProvider } from '@/services/kubeclient/dwClientProvider';

jest.mock('../../../devworkspaceClient');
jest.mock('../kubeConfigProvider.ts');
jest.mock('../../kubeclient/helpers/index.ts', () => {
jest.mock('@/devworkspaceClient');
jest.mock('@/services/kubeclient/kubeConfigProvider.ts');
jest.mock('@/services/kubeclient/helpers/index.ts', () => {
return {
isOpenShift: () => true,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"devDependencies": {
"@devfile/api": "2.2.2-1700686170",
"@eclipse-che/api": "^7.18.1",
"@eclipse-che/api": "^7.80.0",
"@kubernetes/client-node": "^0.18.1",
"@react-mock/state": "^0.1.8",
"@testing-library/dom": "^7.30.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
* Red Hat, Inc. - initial API and implementation
*/

import { api } from '@eclipse-che/common';
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
import { Provider } from 'react-redux';
import renderer from 'react-test-renderer';
import { Action, Store } from 'redux';

import { BRANDING_DEFAULT, BrandingData } from '@/services/bootstrap/branding.constant';
import { che } from '@/services/models';
import { AppThunk } from '@/store';
import { FakeStoreBuilder } from '@/store/__mocks__/storeBuilder';
import { selectBranding } from '@/store/Branding/selectors';
Expand All @@ -30,7 +32,7 @@ jest.mock('gravatar-url', () => {
};
});

jest.mock('../../../../../store/InfrastructureNamespaces', () => {
jest.mock('@/store/InfrastructureNamespaces', () => {
return {
actionCreators: {
requestNamespaces:
Expand Down Expand Up @@ -131,11 +133,9 @@ describe('About Menu', () => {
function createStore(cheCliTool: string, name: string, email: string): Store {
return new FakeStoreBuilder()
.withUserProfile({
attributes: {
preferred_username: name,
},
username: name,
email,
} as api.che.user.Profile)
} as api.IUserProfile)
.withBranding({
configuration: {
cheCliTool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Red Hat, Inc. - initial API and implementation
*/

import { api } from '@eclipse-che/common';
import { fireEvent, render, screen } from '@testing-library/react';
import { createHashHistory } from 'history';
import React from 'react';
Expand All @@ -18,14 +19,15 @@ import renderer from 'react-test-renderer';
import { Action, Store } from 'redux';

import { BRANDING_DEFAULT, BrandingData } from '@/services/bootstrap/branding.constant';
import { che } from '@/services/models';
import { AppThunk } from '@/store';
import { FakeStoreBuilder } from '@/store/__mocks__/storeBuilder';
import { selectBranding } from '@/store/Branding/selectors';
import * as InfrastructureNamespacesStore from '@/store/InfrastructureNamespaces';

import UserMenu from '..';

jest.mock('../../../../../store/InfrastructureNamespaces', () => {
jest.mock('@/store/InfrastructureNamespaces', () => {
return {
actionCreators: {
requestNamespaces:
Expand Down Expand Up @@ -87,11 +89,9 @@ describe('User Menu', () => {
function createStore(name: string, email: string): Store {
return new FakeStoreBuilder()
.withUserProfile({
attributes: {
preferred_username: name,
},
username: name,
email,
} as api.che.user.Profile)
} as api.IUserProfile)
.withBranding({
links: BRANDING_DEFAULT.links,
docs: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ exports[`Page header tools should correctly render the component 1`] = `
onKeyDown={[Function]}
type="button"
>
<span
className="pf-c-dropdown__toggle-text"
>
John Doe
</span>
<span
className="pf-c-dropdown__toggle-icon"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
* Red Hat, Inc. - initial API and implementation
*/

import { api } from '@eclipse-che/common';
import { createHashHistory } from 'history';
import React from 'react';
import { Provider } from 'react-redux';
import renderer from 'react-test-renderer';
import { Action, Store } from 'redux';

import { BRANDING_DEFAULT, BrandingData } from '@/services/bootstrap/branding.constant';
import { che } from '@/services/models';
import { AppThunk } from '@/store';
import { FakeStoreBuilder } from '@/store/__mocks__/storeBuilder';
import * as InfrastructureNamespacesStore from '@/store/InfrastructureNamespaces';
Expand All @@ -29,7 +31,7 @@ jest.mock('gravatar-url', () => {
};
});

jest.mock('../../../../store/InfrastructureNamespaces', () => {
jest.mock('@/store/InfrastructureNamespaces', () => {
return {
actionCreators: {
requestNamespaces:
Expand Down Expand Up @@ -68,11 +70,9 @@ describe('Page header tools', () => {
function createStore(cheCliTool: string, name: string, email: string): Store {
return new FakeStoreBuilder()
.withUserProfile({
attributes: {
preferred_username: name,
},
username: name,
email,
} as api.che.user.Profile)
} as api.IUserProfile)
.withBranding({
configuration: {
cheCliTool,
Expand Down
10 changes: 5 additions & 5 deletions packages/dashboard-frontend/src/Routes/__tests__/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ import { FakeStoreBuilder } from '@/store/__mocks__/storeBuilder';

import Routes from '..';

jest.mock('../../pages/GetStarted', () => {
jest.mock('@/pages/GetStarted', () => {
return function GetStarted() {
return <span>Quick Add</span>;
};
});
jest.mock('../../containers/WorkspacesList.tsx', () => {
jest.mock('@/containers/WorkspacesList.tsx', () => {
return function WorkspacesList() {
return <span>Workspaces List</span>;
};
});
jest.mock('../../containers/WorkspaceDetails', () => {
jest.mock('@/containers/WorkspaceDetails', () => {
return function WorkspaceDetails() {
return <span>Workspace Details</span>;
};
});
jest.mock('../../containers/Loader', () => {
jest.mock('@/containers/Loader', () => {
return function Loader() {
return <span>Loader</span>;
};
});
jest.mock('../../pages/UserPreferences', () => {
jest.mock('@/pages/UserPreferences', () => {
return function UserPreferences() {
return <span>User Preferences</span>;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import Routes from '@/Routes';
import devfileApi from '@/services/devfileApi';
import { AppState } from '@/store';
import { FakeStoreBuilder } from '@/store/__mocks__/storeBuilder';
import { ConvertedState } from '@/store/FactoryResolver';
import { ConvertedState, ResolverState } from '@/store/FactoryResolver';

// mute the outputs
console.error = jest.fn();
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('Workspace creation time', () => {
.withInfrastructureNamespace([namespace])
.withFactoryResolver({
resolver: Object.assign(
{ location: 'https://github.com/eclipse-che/che-dashboard' },
{ location: 'https://github.com/eclipse-che/che-dashboard' } as ResolverState,
factoryResolver,
),
converted: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { FakeStoreBuilder } from '@/store/__mocks__/storeBuilder';

import EditorTools from '..';

jest.mock('../../../contexts/ToggleBars');
jest.mock('@/contexts/ToggleBars');

const mockClipboard = jest.fn();
jest.mock('react-copy-to-clipboard', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import getComponentRenderer, { screen } from '@/services/__mocks__/getComponentR

import { NO_CONTAINERS, WorkspaceLogsContainerSelector } from '..';

jest.mock('../../../../components/ResourceIcon');
jest.mock('@/components/ResourceIcon');

const { createSnapshot, renderComponent } = getComponentRenderer(getComponent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jest.mock('../Viewer');

const mockWatchPodLogs = jest.fn();
const mockStopWatchingPodLogs = jest.fn();
jest.mock('../../../store/Pods/Logs', () => ({
jest.mock('@/store/Pods/Logs', () => ({
actionCreators: {
watchPodLogs:
(pod: V1Pod): AppThunk<Action, Promise<void>> =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import { ActionCreators } from '@/store/Workspaces';

import CommonStepCheckRunningWorkspacesLimit, { State } from '..';

jest.mock('../../../TimeLimit');
jest.mock('@/components/WorkspaceProgress/TimeLimit');

const mockStartWorkspace = jest.fn();
const mockStopWorkspace = jest.fn();
jest.mock('../../../../../store/Workspaces/index', () => {
jest.mock('@/store/Workspaces/index', () => {
return {
actionCreators: {
startWorkspace:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
POLICIES_CREATE_ATTR,
} from '@/services/helpers/factoryFlow/buildFactoryParams';
import { AlertItem } from '@/services/helpers/types';
import { che } from '@/services/models';
import { AppThunk } from '@/store';
import { DevWorkspaceBuilder } from '@/store/__mocks__/devWorkspaceBuilder';
import { FakeStoreBuilder } from '@/store/__mocks__/storeBuilder';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
DEVWORKSPACE_METADATA_ANNOTATION,
} from '@/services/workspace-client/devworkspace/devWorkspaceClient';

jest.mock('../../../../../../services/helpers/generateName');
jest.mock('@/services/helpers/generateName');
(generateWorkspaceName as jest.Mock).mockImplementation(name => name + '1234');

describe('FactoryLoaderContainer/prepareDevfile', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import devfileApi from '@/services/devfileApi';
import { DEVWORKSPACE_STORAGE_TYPE_ATTR } from '@/services/devfileApi/devWorkspace/spec/template';
import { generateWorkspaceName } from '@/services/helpers/generateName';
import sanitizeName from '@/services/helpers/sanitizeName';
import { che } from '@/services/models';
import {
DEVWORKSPACE_DEVFILE_SOURCE,
DEVWORKSPACE_METADATA_ANNOTATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ import { ActionCreators } from '@/store/Workspaces/devWorkspaces';

import CreatingStepApplyResources from '..';

jest.mock('../../../../TimeLimit');
jest.mock('../prepareResources.ts');
jest.mock('@/components/WorkspaceProgress/TimeLimit');
jest.mock('@/components/WorkspaceProgress/CreatingSteps/Apply/Resources/prepareResources.ts');

const mockCreateWorkspaceFromResources = jest.fn().mockResolvedValue(undefined);
jest.mock('../../../../../../store/Workspaces/devWorkspaces', () => {
jest.mock('@/store/Workspaces/devWorkspaces', () => {
return {
actionCreators: {
createWorkspaceFromResources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { DEVWORKSPACE_DEVFILE_SOURCE } from '@/services/workspace-client/devwork
import { DevWorkspaceResources } from '@/store/DevfileRegistries';

const suffix = '-1234';
jest.mock('../../../../../../services/helpers/generateName');
jest.mock('@/services/helpers/generateName');
(generateSuffix as jest.Mock).mockImplementation(() => suffix);

describe('FactoryLoaderContainer/prepareResources', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DevWorkspaceTemplate } from '@/services/devfileApi/devfileApi';
import { DevWorkspace } from '@/services/devfileApi/devWorkspace';
import { DEVWORKSPACE_STORAGE_TYPE_ATTR } from '@/services/devfileApi/devWorkspace/spec/template';
import { generateSuffix } from '@/services/helpers/generateName';
import { che } from '@/services/models';
import { DEVWORKSPACE_DEVFILE_SOURCE } from '@/services/workspace-client/devworkspace/devWorkspaceClient';
import { DevWorkspaceResources } from '@/store/DevfileRegistries';

Expand Down
Loading

0 comments on commit fb4e0c6

Please sign in to comment.