Skip to content

Commit c393ce6

Browse files
authored
test: Add community modules tests (#4036)
* add current work * whole test almost work * whole test work * improve code.... * add testid * fix * fix review comments
1 parent 11e3558 commit c393ce6

File tree

13 files changed

+314
-28
lines changed

13 files changed

+314
-28
lines changed

.github/scripts/install-kyma.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ echo "Apply modules fixtures"
4343
kubectl apply -f tests/integration/fixtures/module-templates-crd.yaml
4444
kubectl apply -f tests/integration/fixtures/test-crd-kyma.yaml
4545
kubectl apply -f tests/integration/fixtures/modules
46+
kubectl apply -f tests/integration/fixtures/community-modules
4647

4748
echo "Apply gardener resources"
4849
echo "Certificates"

src/components/KymaModules/components/CommunityModuleCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function isImageAvailable(url) {
2424

2525
async function getImageSrc(module) {
2626
const defaultImage = '/assets/sap-logo.svg';
27-
const iconLink = module.versions[0]?.icon.link;
27+
const iconLink = module.versions[0]?.icon?.link;
2828

2929
if (iconLink && (await isImageAvailable(iconLink))) {
3030
return iconLink;

src/components/KymaModules/components/CommunityModulesEdit.tsx

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
ModuleTemplateListType,
1717
ModuleTemplateType,
1818
} from 'components/KymaModules/support';
19-
import { Button, Form, FormItem } from '@ui5/webcomponents-react';
19+
import { Button, Form, FormItem, MessageStrip } from '@ui5/webcomponents-react';
2020
import { useContext, useEffect, useMemo, useState } from 'react';
2121
import { UnsavedMessageBox } from 'shared/components/UnsavedMessageBox/UnsavedMessageBox';
2222
import { createPortal } from 'react-dom';
@@ -32,6 +32,7 @@ import {
3232
import { ModuleTemplatesContext } from 'components/KymaModules/providers/ModuleTemplatesProvider';
3333

3434
import './CommunityModule.scss';
35+
import { capitalizeFirstLetter } from '@ui5/webcomponents-react-base';
3536

3637
const isModuleInstalled = (
3738
foundModuleTemplate: ModuleTemplateType,
@@ -125,7 +126,9 @@ function transformDataForDisplay(
125126
): ModuleDisplayInfo[] {
126127
return Array.from(availableCommunityModules, ([moduleName, versions]) => {
127128
const formatDisplayText = (v: VersionInfo): string => {
128-
return `${v.channel ? v.channel + ' ' : ''}(v${v.version})`;
129+
return `${v.channel ? capitalizeFirstLetter(v.channel) + ' ' : ''}(v${
130+
v.version
131+
})`;
129132
};
130133

131134
return {
@@ -220,6 +223,7 @@ export default function CommunityModulesEdit() {
220223
return (
221224
<section>
222225
<UI5Panel
226+
testid={'community-modules-edit'}
223227
title={''}
224228
headerActions={
225229
<Button
@@ -250,24 +254,34 @@ export default function CommunityModulesEdit() {
250254
className="collapsible-margins"
251255
title={t('modules.community.title')}
252256
>
253-
<div className={'edit'}>
254-
{communityModulesToDisplay &&
255-
communityModulesToDisplay.map((module, idx) => {
256-
return (
257-
<CommunityModuleVersionSelect
258-
key={`${module.name}+${idx}`}
259-
module={module}
260-
onChange={onVersionChange(
261-
communityModuleTemplates,
262-
installedCommunityModuleTemplates,
263-
communityModulesTemplatesToApply,
264-
setCommunityModulesTemplatesToApply,
265-
setIsResourceEdited,
266-
)}
267-
/>
268-
);
269-
})}
270-
</div>
257+
{installedCommunityModuleTemplates.items.length !== 0 ? (
258+
<div className={'edit'}>
259+
{communityModulesToDisplay &&
260+
communityModulesToDisplay.map((module, idx) => {
261+
return (
262+
<CommunityModuleVersionSelect
263+
key={`${module.name}+${idx}`}
264+
module={module}
265+
onChange={onVersionChange(
266+
communityModuleTemplates,
267+
installedCommunityModuleTemplates,
268+
communityModulesTemplatesToApply,
269+
setCommunityModulesTemplatesToApply,
270+
setIsResourceEdited,
271+
)}
272+
/>
273+
);
274+
})}
275+
</div>
276+
) : (
277+
<MessageStrip
278+
design="Critical"
279+
hideCloseButton
280+
className="sap-margin-top-small"
281+
>
282+
{t('modules.community.no-modules-installed')}
283+
</MessageStrip>
284+
)}
271285
</CollapsibleSection>
272286
</div>
273287
</FormItem>

src/components/KymaModules/components/CommunityModulesList.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ export const CommunityModulesList = ({
257257
<GenericList
258258
testid={'community-modules-list'}
259259
className={'community-modules-list'}
260-
accessibleName={undefined}
261260
actions={actions as any}
262261
customRowClick={handleClickResource}
263262
extraHeaderContent={[

src/components/KymaModules/components/ModulesList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ export const ModulesList = ({
287287
<UnmanagedModuleInfo kymaResource={kymaResource} />
288288
</div>
289289
<GenericList
290+
testid={'kyma-modules-list'}
290291
className={'modules-list'}
291-
accessibleName={undefined}
292292
actions={actions as any}
293293
customRowClick={handleClickResource}
294294
extraHeaderContent={[

src/shared/components/GenericList/GenericList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const GenericList = ({
7373
noHideFields,
7474
customRowClick,
7575
className = '',
76-
accessibleName,
76+
accessibleName = null,
7777
customSelectedEntry = '',
7878
}) => {
7979
const navigate = useNavigate();
@@ -390,7 +390,7 @@ export const GenericList = ({
390390
<UI5Panel
391391
title={title}
392392
headerActions={!headerActionsEmpty && headerActions}
393-
data-testid={testid}
393+
testid={testid}
394394
disableMargin={disableMargin}
395395
className={className}
396396
>

src/shared/components/UI5Panel/UI5Panel.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type UI5PanelProps = {
1818
description?: string;
1919
stickyHeader?: boolean;
2020
headerTop?: string;
21+
testid?: string;
2122
};
2223

2324
export const UI5Panel = ({
@@ -33,6 +34,7 @@ export const UI5Panel = ({
3334
description = '',
3435
stickyHeader = false,
3536
headerTop = '0',
37+
testid,
3638
}: UI5PanelProps) => {
3739
useEffect(() => {
3840
if (headerTop !== '0')
@@ -51,6 +53,7 @@ export const UI5Panel = ({
5153
});
5254
return (
5355
<Panel
56+
data-testid={testid}
5457
fixed={fixed}
5558
key={keyComponent}
5659
className={`${className} bsl-panel-header card-shadow ${

tests/integration/cypress.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ module.exports = defineConfig({
8787
'tests/namespace/test-resource-quotas.spec.js',
8888
'tests/namespace/z-run-after.spec.js',
8989
'tests/kyma-cluster/test-kyma-modules.spec.js',
90+
'tests/kyma-cluster/test-community-modules.spec.js',
9091
'tests/kyma-namespace/a-run-before.spec.js',
9192
'tests/kyma-namespace/test-certificates.spec.js',
9293
'tests/kyma-namespace/test-issuers.spec.js',
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: operator.kyma-project.io/v1beta2
2+
kind: ModuleTemplate
3+
metadata:
4+
annotations:
5+
operator.kyma-project.io/is-cluster-scoped: 'false'
6+
labels:
7+
operator.kyma-project.io/module-name: busola
8+
name: busola-0-11
9+
namespace: kyma-system
10+
spec:
11+
descriptor:
12+
component:
13+
componentReferences: []
14+
name: kyma-project.io/module/busola
15+
provider: '{"name":"kyma-project.io","labels":[{"name":"kyma-project.io/built-by","value":"modulectl","version":"v1"}]}'
16+
repositoryContexts:
17+
- baseUrl: http://k3d-oci.localhost:5001
18+
componentNameMapping: urlPath
19+
type: OCIRegistry
20+
sources:
21+
- access:
22+
commit: 106643ead24aff8da197fc89a46ce546193ea8f1
23+
repoUrl: https://github.com/kyma-project/busola.git
24+
type: gitHub
25+
labels:
26+
- name: git.kyma-project.io/ref
27+
value: HEAD
28+
version: v1
29+
name: module-sources
30+
type: Github
31+
version: 0.0.29
32+
version: 0.0.29
33+
meta:
34+
schemaVersion: v2
35+
info:
36+
documentation: https://kyma-project.io/#/busola/user/README
37+
icons:
38+
- link: https://kyma-project.io/assets/logo_icon.svg
39+
name: module-icon
40+
repository: https://github.com/kyma-project/busola.git
41+
manager:
42+
group: apps
43+
kind: Deployment
44+
name: busola
45+
namespace: default
46+
version: v1
47+
mandatory: false
48+
moduleName: busola
49+
requiresDowntime: false
50+
resources:
51+
- link: https://github.com/kyma-project/busola/releases/download/v0.0.11/busola.yaml
52+
name: rawManifest
53+
version: 0.0.11
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: operator.kyma-project.io/v1beta2
2+
kind: ModuleTemplate
3+
metadata:
4+
annotations:
5+
operator.kyma-project.io/is-cluster-scoped: 'false'
6+
labels:
7+
operator.kyma-project.io/module-name: busola
8+
name: busola-0-12
9+
namespace: kyma-system
10+
spec:
11+
descriptor:
12+
component:
13+
componentReferences: []
14+
name: kyma-project.io/module/busola
15+
provider: '{"name":"kyma-project.io","labels":[{"name":"kyma-project.io/built-by","value":"modulectl","version":"v1"}]}'
16+
repositoryContexts:
17+
- baseUrl: http://k3d-oci.localhost:5001
18+
componentNameMapping: urlPath
19+
type: OCIRegistry
20+
sources:
21+
- access:
22+
commit: 106643ead24aff8da197fc89a46ce546193ea8f1
23+
repoUrl: https://github.com/kyma-project/busola.git
24+
type: gitHub
25+
labels:
26+
- name: git.kyma-project.io/ref
27+
value: HEAD
28+
version: v1
29+
name: module-sources
30+
type: Github
31+
version: 0.0.29
32+
version: 0.0.29
33+
meta:
34+
schemaVersion: v2
35+
info:
36+
documentation: https://kyma-project.io/#/busola/user/README
37+
icons:
38+
- link: https://kyma-project.io/assets/logo_icon.svg
39+
name: module-icon
40+
repository: https://github.com/kyma-project/busola.git
41+
manager:
42+
group: apps
43+
kind: Deployment
44+
name: busola
45+
namespace: default
46+
version: v1
47+
mandatory: false
48+
moduleName: busola
49+
requiresDowntime: false
50+
resources:
51+
- link: https://github.com/kyma-project/busola/releases/download/v0.0.12/busola.yaml
52+
name: rawManifest
53+
version: 0.0.12

0 commit comments

Comments
 (0)