Skip to content

Commit 7608612

Browse files
authored
test: Add test for the sap-logging extensibility links (kyma-project#4343)
* tests: Add test for the sap-logging extensibility links * adjust title of the it * adjust comments * remove additional configmap
1 parent 568246b commit 7608612

File tree

6 files changed

+86
-18
lines changed

6 files changed

+86
-18
lines changed

.github/workflows/pull-integration-cluster-k3d.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ on:
66
paths:
77
- '.github/workflows/pull-integration-cluster-k3d.yml'
88
- '.github/scripts/**'
9-
- "backend/**"
10-
- "public/**"
11-
- "src/**"
12-
- "package.json"
13-
- "Makefile"
14-
- "Dockerfile*"
15-
- "nginx/**"
9+
- 'backend/**'
10+
- 'public/**'
11+
- 'src/**'
12+
- 'package.json'
13+
- 'Makefile'
14+
- 'Dockerfile*'
15+
- 'nginx/**'
1616
- 'resources/**'
1717
- 'tests/integration/**'
1818

@@ -51,6 +51,12 @@ jobs:
5151
run: |
5252
kubectl create namespace kyma-system
5353
(cd examples/busola-web-components && kubectl kustomize . | kubectl apply -n kyma-system -f - )
54+
- name: Install sap-logging extensibility example
55+
shell: bash
56+
run: |
57+
kubectl create namespace sap-cloud-logging-integration
58+
kubectl apply -f tests/integration/fixtures/sap-logging-secret.yaml
59+
kubectl apply -f tests/integration/fixtures/sap-loggging-config-map.yaml
5460
- name: Run tests
5561
shell: bash
5662
run: |

src/sidebar/NavItem.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,9 @@ export function NavItem({ node, subItem = false }: NavItemProps) {
7272
]);
7373

7474
const handleNavigation = () => {
75-
if (node.dataSources) {
76-
let link =
77-
!jsonataError && jsonataLink ? jsonataLink : (node.externalUrl ?? '');
78-
link = link.startsWith('http') ? link : `https://${link}`;
79-
const newWindow = window.open(link, 'noopener, noreferrer');
80-
if (newWindow) newWindow.opener = null;
81-
} else if (node.externalUrl) {
82-
const link = node.externalUrl.startsWith('http')
83-
? node.externalUrl
84-
: `https://${node.externalUrl}`;
85-
const newWindow = window.open(link, 'noopener, noreferrer');
75+
if (node.dataSources || node.externalUrl) {
76+
const link = getURL();
77+
const newWindow = window.open(link, '_blank', 'noopener,noreferrer');
8678
if (newWindow) newWindow.opener = null;
8779
} else {
8880
navigateSafely(() => {
@@ -109,11 +101,27 @@ export function NavItem({ node, subItem = false }: NavItemProps) {
109101
}
110102
};
111103

104+
const getURL = () => {
105+
let link;
106+
if (node.dataSources) {
107+
link =
108+
!jsonataError && jsonataLink ? jsonataLink : (node.externalUrl ?? '');
109+
link = link.startsWith('http') ? link : `https://${link}`;
110+
} else if (node.externalUrl) {
111+
link = node.externalUrl.startsWith('http')
112+
? node.externalUrl
113+
: `https://${node.externalUrl}`;
114+
}
115+
return link || undefined;
116+
};
117+
112118
const propsForNav = {
113119
icon: node.externalUrl ? 'action' : node.icon,
114120
text: t(node.label, { defaultValue: node.label }),
115121
selected: isSelected,
122+
href: node.dataSources || node.externalUrl ? getURL() : undefined,
116123
onClick: (e: Event) => {
124+
e.preventDefault();
117125
e.stopPropagation();
118126
handleNavigation();
119127
},

tests/integration/cypress.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module.exports = defineConfig({
5454
'tests/cluster/test-command-palette.spec.js',
5555
'tests/cluster/test-custom-resources.spec.js',
5656
'tests/cluster/test-navigation-features.spec.js',
57+
'tests/extensibility/ext-test-statics-jsonata-links.spec.js',
5758
'tests/extensibility/ext-test-pizzas.spec.js',
5859
'tests/extensibility/ext-test-services.spec.js',
5960
'tests/extensibility/ext-test-variables.spec.js',
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: sap-cloud-logging
5+
namespace: kube-public
6+
labels:
7+
busola.io/extension: statics
8+
busola.io/extension-version: '0.5'
9+
data:
10+
dataSources: |-
11+
clsSecret:
12+
resource:
13+
kind: Secret
14+
version: v1
15+
namespace: sap-cloud-logging-integration
16+
name: sap-cloud-logging
17+
general: |-
18+
externalNodes:
19+
- category: SAP Cloud Logging
20+
icon: display
21+
children:
22+
- label: "Dashboards"
23+
link: "$string('https://') & $base64decode($string($clsSecret().data.'dashboards-endpoint')) & \"/app/dashboards#/view/maintained-by-perfx_kyma-content-package_Kyma-Overview\""
24+
- label: "Discover Logs"
25+
link: "$string('https://') & $base64decode($string($clsSecret().data.'dashboards-endpoint')) & \"/app/discover?security_tenant=global#/?_g=(filters:!(),refreshInterval:(pause:!t,value:5000),time:(from:now-7d,to:now))&_a=(columns:!(kubernetes.pod_name,kubernetes.container_name,log),index:maintained-by-perfx_kyma-content-package_index-pattern-logs-json-kyma)\""
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kind: Secret
2+
apiVersion: v1
3+
metadata:
4+
name: sap-cloud-logging
5+
namespace: sap-cloud-logging-integration
6+
data:
7+
dashboards-endpoint: dGVzdA==
8+
type: Opaque
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference types="cypress" />
2+
import 'cypress-file-upload';
3+
4+
context('Test Links from Statics - sap-logging example', () => {
5+
Cypress.skipAfterFail();
6+
7+
before(() => {
8+
cy.loginAndSelectCluster();
9+
});
10+
11+
it('Check Cluster Overview sap-logging links', () => {
12+
cy.wait(500);
13+
cy.getLeftNav().contains('SAP Cloud Logging').click();
14+
15+
cy.get('ui5-side-navigation-sub-item')
16+
.contains('Discover Logs')
17+
.invoke('attr', 'href')
18+
.should('match', /^https:\/\/test\/app/);
19+
});
20+
});

0 commit comments

Comments
 (0)