Skip to content

Commit b538bd9

Browse files
authored
fix: change the way the original devfile content is stored (#1315)
* fix: change the way the original devfile content is stored Signed-off-by: Oleksii Orel <oorel@redhat.com>
1 parent 1ad46ec commit b538bd9

File tree

55 files changed

+690
-1083
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+690
-1083
lines changed

.deps/EXCLUDED/prod.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This file lists dependencies that do not need CQs or auto-detection does not wor
22

33
| Packages | Resolved CQs |
44
| --- | --- |
5-
| `@devfile/api@2.3.0-1733171449` | N/A |
5+
| `@devfile/api@2.3.0-1738342178` | N/A |
66
| `@fastify/cors@9.0.1` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/@fastify/cors/9.0.1) |
77
| `@fastify/swagger-ui@4.2.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/@fastify/swagger-ui/4.2.0) |
88
| `@hapi/hoek@10.0.1` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/@hapi/hoek/10.0.1) |

.deps/dev.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@
360360
| `glob-parent@5.1.2` | ISC | clearlydefined |
361361
| `glob-parent@6.0.2` | ISC | clearlydefined |
362362
| [`glob-to-regexp@0.4.1`](https://github.com/fitzgen/glob-to-regexp.git) | BSD-2-Clause | clearlydefined |
363-
| [`glob@7.2.3`](git://github.com/isaacs/node-glob.git) | ISC | clearlydefined |
363+
| [`glob@7.2.3`](git://github.com/isaacs/node-glob.git) | ISC | #19366 |
364364
| [`global-modules@2.0.0`](https://github.com/jonschlinkert/global-modules) | MIT | clearlydefined |
365365
| [`global-prefix@3.0.0`](https://github.com/jonschlinkert/global-prefix) | MIT | clearlydefined |
366366
| `globals@11.12.0` | MIT | clearlydefined |
@@ -394,7 +394,7 @@
394394
| [`identity-obj-proxy@3.0.0`](git+https://github.com/keyanzhang/identity-obj-proxy.git) | MIT | clearlydefined |
395395
| [`ignore-by-default@1.0.1`](git+https://github.com/novemberborn/ignore-by-default.git) | ISC | clearlydefined |
396396
| [`ignore@5.2.4`](git@github.com:kaelzhang/node-ignore.git) | MIT | #5907 |
397-
| `import-fresh@3.3.0` | MIT | clearlydefined |
397+
| `import-fresh@3.3.0` | MIT | #19299 |
398398
| `import-lazy@4.0.0` | MIT | clearlydefined |
399399
| `import-local@3.1.0` | MIT | clearlydefined |
400400
| `indent-string@5.0.0` | MIT | clearlydefined |

.deps/prod.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
| Packages | License | Resolved CQs |
44
| --- | --- | --- |
55
| [`@babel/runtime@7.23.2`](https://github.com/babel/babel.git) | MIT | #10718 |
6-
| [`@devfile/api@2.3.0-1733171449`](https://github.com/GIT_USER_ID/GIT_REPO_ID.git) | Apache-2.0 | N/A |
7-
| [`@eclipse-che/che-devworkspace-generator@7.96.0-next-da9f364`](git+https://github.com/devfile/devworkspace-generator.git) | EPL-2.0 | ecd.che |
6+
| [`@devfile/api@2.3.0-1738342178`](https://github.com/GIT_USER_ID/GIT_REPO_ID.git) | Apache-2.0 | N/A |
7+
| [`@eclipse-che/che-devworkspace-generator@7.99.0-next-1ccb963`](git+https://github.com/devfile/devworkspace-generator.git) | EPL-2.0 | ecd.che |
88
| [`@fastify/accept-negotiator@1.1.0`](git+https://github.com/fastify/accept-negotiator.git) | MIT | clearlydefined |
99
| [`@fastify/ajv-compiler@3.6.0`](git+https://github.com/fastify/ajv-compiler.git) | MIT | clearlydefined |
1010
| [`@fastify/busboy@2.0.0`](https://github.com/fastify/busboy.git) | MIT | clearlydefined |

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"test:watch": "yarn test --watch"
1919
},
2020
"devDependencies": {
21-
"@devfile/api": "2.3.0-1733171449",
21+
"@devfile/api": "2.3.0-1738342178",
2222
"@kubernetes/client-node": "^0.22.1",
2323
"@types/jest": "^29.5.3",
2424
"@typescript-eslint/eslint-plugin": "^6.3.0",

packages/dashboard-backend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
],
2727
"license": "EPL-2.0",
2828
"dependencies": {
29-
"@devfile/api": "2.3.0-1733171449",
30-
"@eclipse-che/che-devworkspace-generator": "7.96.0-next-da9f364",
29+
"@devfile/api": "2.3.0-1738342178",
30+
"@eclipse-che/che-devworkspace-generator": "7.99.0-next-1ccb963",
3131
"@fastify/cors": "^9.0.1",
3232
"@fastify/error": "^3.4.1",
3333
"@fastify/http-proxy": "^9.5.0",

packages/dashboard-frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"sanitize-html": "^2.11.0"
6868
},
6969
"devDependencies": {
70-
"@devfile/api": "2.3.0-1733171449",
70+
"@devfile/api": "2.3.0-1738342178",
7171
"@eclipse-che/api": "^7.86.0",
7272
"@kubernetes/client-node": "^0.22.1",
7373
"@react-mock/state": "^0.1.8",

packages/dashboard-frontend/src/components/EditorTools/__tests__/__snapshots__/index.spec.tsx.snap

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`EditorTools DevWorkspace snapshot 1`] = `
4-
<div
5-
className="editorTools"
6-
>
7-
<div
8-
className="pf-l-flex"
9-
>
10-
<div
11-
className=""
12-
>
13-
<a
14-
aria-disabled={false}
15-
aria-label={null}
16-
className="pf-c-button pf-m-link button"
17-
data-ouia-component-id="OUIA-Generated-Button-link-4"
18-
data-ouia-component-type="PF4/Button"
19-
data-ouia-safe={true}
20-
disabled={null}
21-
href="https://console-url/k8s/ns/user-che/1.0.0~DevWorkspace/my-project"
22-
role={null}
23-
target="_blank"
24-
type={null}
25-
>
26-
<span
27-
className="pf-c-button__icon pf-m-start"
28-
>
29-
<svg
30-
aria-hidden={true}
31-
aria-labelledby={null}
32-
fill="currentColor"
33-
height="1em"
34-
role="img"
35-
style={
36-
{
37-
"verticalAlign": "-0.125em",
38-
}
39-
}
40-
viewBox="0 0 448 512"
41-
width="1em"
42-
>
43-
<path
44-
d="M448 80v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V80c0-26.51 21.49-48 48-48h352c26.51 0 48 21.49 48 48zm-88 16H248.029c-21.313 0-32.08 25.861-16.971 40.971l31.984 31.987L67.515 364.485c-4.686 4.686-4.686 12.284 0 16.971l31.029 31.029c4.687 4.686 12.285 4.686 16.971 0l195.526-195.526 31.988 31.991C358.058 263.977 384 253.425 384 231.979V120c0-13.255-10.745-24-24-24z"
45-
/>
46-
</svg>
47-
</span>
48-
Cluster console
49-
</a>
50-
</div>
51-
<hr
52-
className="pf-c-divider pf-m-vertical"
53-
/>
54-
<div
55-
className=""
56-
>
57-
<button
58-
onClick={[Function]}
59-
>
60-
Copy to clipboard
61-
</button>
62-
</div>
63-
<hr
64-
className="pf-c-divider pf-m-vertical"
65-
/>
66-
<div
67-
className=""
68-
>
69-
<a
70-
className="button"
71-
download="my-project.workspace.yaml"
72-
href="blob-url"
73-
>
74-
<svg
75-
aria-hidden={true}
76-
aria-labelledby={null}
77-
fill="currentColor"
78-
height="1em"
79-
role="img"
80-
style={
81-
{
82-
"verticalAlign": "-0.125em",
83-
}
84-
}
85-
viewBox="0 0 512 512"
86-
width="1em"
87-
>
88-
<path
89-
d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
90-
/>
91-
</svg>
92-
Download
93-
</a>
94-
</div>
95-
<hr
96-
className="pf-c-divider pf-m-vertical"
97-
/>
98-
<div
99-
className=""
100-
>
101-
<button
102-
aria-disabled={false}
103-
aria-label={null}
104-
className="pf-c-button pf-m-link button"
105-
data-ouia-component-id="OUIA-Generated-Button-link-5"
106-
data-ouia-component-type="PF4/Button"
107-
data-ouia-safe={true}
108-
disabled={false}
109-
onClick={[Function]}
110-
role={null}
111-
type="button"
112-
>
113-
<svg
114-
aria-hidden={true}
115-
aria-labelledby={null}
116-
fill="currentColor"
117-
height="1em"
118-
role="img"
119-
style={
120-
{
121-
"verticalAlign": "-0.125em",
122-
}
123-
}
124-
viewBox="0 0 448 512"
125-
width="1em"
126-
>
127-
<path
128-
d="M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z"
129-
/>
130-
</svg>
131-
Expand
132-
</button>
133-
</div>
134-
</div>
135-
</div>
136-
`;
137-
1383
exports[`EditorTools Devfile snapshot 1`] = `
1394
<div
1405
className="editorTools"

packages/dashboard-frontend/src/components/EditorTools/__tests__/index.spec.tsx

Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
* Red Hat, Inc. - initial API and implementation
1111
*/
1212

13-
import { ApplicationId } from '@eclipse-che/common';
1413
import userEvent from '@testing-library/user-event';
14+
import { dump } from 'js-yaml';
1515
import React from 'react';
1616
import { Provider } from 'react-redux';
1717
import { Store } from 'redux';
1818

19+
import EditorTools from '@/components/EditorTools';
1920
import getComponentRenderer, { screen } from '@/services/__mocks__/getComponentRenderer';
20-
import devfileApi from '@/services/devfileApi';
2121
import { MockStoreBuilder } from '@/store/__mocks__/mockStore';
2222

23-
import EditorTools from '..';
23+
// mute console.error
24+
console.error = jest.fn();
2425

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

@@ -49,19 +50,8 @@ const mockOnExpand = jest.fn();
4950
let store: Store;
5051

5152
describe('EditorTools', () => {
52-
const clusterConsole = {
53-
id: ApplicationId.CLUSTER_CONSOLE,
54-
url: 'https://console-url',
55-
icon: 'https://console-icon-url',
56-
title: 'Cluster console',
57-
};
58-
5953
beforeEach(() => {
60-
store = new MockStoreBuilder()
61-
.withClusterInfo({
62-
applications: [clusterConsole],
63-
})
64-
.build();
54+
store = new MockStoreBuilder().build();
6555

6656
jest.useFakeTimers();
6757
});
@@ -72,26 +62,22 @@ describe('EditorTools', () => {
7262
});
7363

7464
describe('Devfile', () => {
75-
let devfile: devfileApi.Devfile;
76-
77-
beforeEach(() => {
78-
devfile = {
79-
schemaVersion: '2.1.0',
80-
metadata: {
81-
name: 'my-project',
82-
namespace: 'user-che',
83-
},
84-
};
65+
const name = 'my-project';
66+
const devfileContent = dump({
67+
schemaVersion: '2.1.0',
68+
metadata: {
69+
name,
70+
},
8571
});
8672

8773
test('snapshot', () => {
88-
const snapshot = createSnapshot(devfile);
74+
const snapshot = createSnapshot(devfileContent, name);
8975
expect(snapshot.toJSON()).toMatchSnapshot();
9076
});
9177

9278
test('expand and compress', async () => {
9379
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
94-
renderComponent(devfile);
80+
renderComponent(devfileContent, name);
9581

9682
/* expand the editor */
9783

@@ -120,7 +106,7 @@ describe('EditorTools', () => {
120106
const mockCreateObjectURL = jest.fn().mockReturnValue('blob-url');
121107
URL.createObjectURL = mockCreateObjectURL;
122108

123-
renderComponent(devfile);
109+
renderComponent(devfileContent, name);
124110

125111
const copyButtonName = 'Copy to clipboard';
126112
expect(screen.queryByRole('button', { name: copyButtonName })).toBeTruthy;
@@ -129,7 +115,7 @@ describe('EditorTools', () => {
129115
await user.click(copyButton);
130116

131117
expect(mockClipboard).toHaveBeenCalledWith(
132-
'schemaVersion: 2.1.0\nmetadata:\n name: my-project\n namespace: user-che\n',
118+
'schemaVersion: 2.1.0\nmetadata:\n name: my-project\n',
133119
);
134120

135121
/* 'Copy to clipboard' should be hidden for a while */
@@ -146,46 +132,16 @@ describe('EditorTools', () => {
146132
expect(screen.queryByRole('button', { name: copyButtonNameAfter })).toBeFalsy;
147133
});
148134
});
149-
150-
describe('DevWorkspace', () => {
151-
let devWorkspace: devfileApi.DevWorkspace;
152-
153-
beforeEach(() => {
154-
devWorkspace = {
155-
apiVersion: '1.0.0',
156-
metadata: {
157-
name: 'my-project',
158-
namespace: 'user-che',
159-
labels: {},
160-
uid: '123',
161-
},
162-
kind: 'DevWorkspace',
163-
spec: {
164-
template: {},
165-
started: true,
166-
},
167-
};
168-
});
169-
170-
test('snapshot', () => {
171-
const snapshot = createSnapshot(devWorkspace);
172-
expect(snapshot.toJSON()).toMatchSnapshot();
173-
});
174-
175-
test('Cluster Console', () => {
176-
renderComponent(devWorkspace);
177-
178-
const clusterConsoleButton = screen.getByRole('link', { name: clusterConsole.title });
179-
180-
expect(clusterConsoleButton.textContent).toEqual(clusterConsole.title);
181-
});
182-
});
183135
});
184136

185-
function getComponent(devfileOrDevWorkspace: devfileApi.Devfile | devfileApi.DevWorkspace) {
137+
function getComponent(contentText: string, workspaceName: string) {
186138
return (
187139
<Provider store={store}>
188-
<EditorTools devfileOrDevWorkspace={devfileOrDevWorkspace} handleExpand={mockOnExpand} />
140+
<EditorTools
141+
contentText={contentText}
142+
workspaceName={workspaceName}
143+
handleExpand={mockOnExpand}
144+
/>
189145
</Provider>
190146
);
191147
}

0 commit comments

Comments
 (0)