Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DASF Web Component
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DASF Data Analytics Software Framework
DASF Web Component
Commits
a8f15f7c
Verified
Commit
a8f15f7c
authored
1 month ago
by
Philipp S. Sommer
Browse files
Options
Downloads
Patches
Plain Diff
implement test for function container
parent
1bd74146
No related branches found
No related tags found
1 merge request
!1
Initial implementation
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
index.html
+1
-24
1 addition, 24 deletions
index.html
src/components/FunctionContainer.tsx
+2
-1
2 additions, 1 deletion
src/components/FunctionContainer.tsx
src/main.tsx
+2
-0
2 additions, 0 deletions
src/main.tsx
tests/FunctionContainer.test.tsx
+57
-0
57 additions, 0 deletions
tests/FunctionContainer.test.tsx
with
62 additions
and
25 deletions
index.html
+
1
−
24
View file @
a8f15f7c
...
...
@@ -13,30 +13,6 @@ SPDX-License-Identifier: Apache-2.0
<title>
Vite + React + TS
</title>
</head>
<body>
<script
id=
"function-schema"
type=
"application/json"
>
{
"
description
"
:
"
Find R and B values for an ICON grid.
"
,
"
properties
"
:
{
"
func_name
"
:
{
"
const
"
:
"
icon_rb
"
,
"
description
"
:
"
The name of the function. Must be 'icon_rb'
"
,
"
enum
"
:
[
"
icon_rb
"
],
"
title
"
:
"
Func Name
"
,
"
type
"
:
"
string
"
},
"
delta
"
:
{
"
description
"
:
"
The target grid width in kilometer.
"
,
"
exclusiveMinimum
"
:
0.0
,
"
title
"
:
"
Delta
"
,
"
type
"
:
"
number
"
}
},
"
required
"
:
[
"
func_name
"
,
"
delta
"
],
"
title
"
:
"
FuncIconRb
"
,
"
type
"
:
"
object
"
}
</script>
<script>
function
showinLog
(
response
)
{
console
.
log
(
response
);
...
...
@@ -49,6 +25,7 @@ SPDX-License-Identifier: Apache-2.0
topic=
"mytesttopic"
description=
"A list of the grid definitions with the closest grid width."
on-response=
"showinLog"
function-name=
"test_function"
>
</function-container>
<script
type=
"module"
src=
"/src/main.tsx"
></script>
...
...
This diff is collapsed.
Click to expand it.
src/components/FunctionContainer.tsx
+
2
−
1
View file @
a8f15f7c
...
...
@@ -96,11 +96,12 @@ function FunctionContainer({
};
if
(
typeof
finalSchema
===
'
undefined
'
)
{
dasfConnection
.
getApiInfo
().
then
((
api_info
)
=>
{
console
.
log
(
functionName
);
if
(
typeof
functionName
===
'
undefined
'
)
{
setFinalSchema
(
api_info
.
functions
[
0
].
rpcSchema
);
}
else
{
setFinalSchema
(
api_info
.
functions
.
filter
((
f
)
=>
f
.
name
==
functionName
)[
0
],
api_info
.
functions
.
filter
((
f
)
=>
f
.
name
==
functionName
)[
0
]
.
rpcSchema
,
);
}
});
...
...
This diff is collapsed.
Click to expand it.
src/main.tsx
+
2
−
0
View file @
a8f15f7c
...
...
@@ -11,7 +11,9 @@ const WebFunctionContainer = r2wc(FunctionContainer, {
websocketUrl
:
'
string
'
,
topic
:
'
string
'
,
description
:
'
string
'
,
functionName
:
'
string
'
,
onResponse
:
'
function
'
,
onError
:
'
function
'
,
},
});
...
...
This diff is collapsed.
Click to expand it.
tests/FunctionContainer.test.tsx
0 → 100644
+
57
−
0
View file @
a8f15f7c
// SPDX-FileCopyrightText: 2025 Helmholtz-Zentrum hereon GmbH
//
// SPDX-License-Identifier: Apache-2.0
import
{
render
}
from
'
@testing-library/react
'
;
import
{
describe
,
expect
,
it
,
vi
}
from
'
vitest
'
;
import
{
userEvent
}
from
'
@vitest/browser/context
'
;
import
FunctionContainer
from
'
../src/components/FunctionContainer
'
;
import
{
DASFConnection
,
WebsocketUrlBuilder
}
from
'
@dasf/dasf-messaging
'
;
import
{
exec
}
from
'
child_process
'
;
function
createConnection
(
uri
?:
string
):
DASFConnection
{
const
websocketUrl
=
uri
?
uri
:
import
.
meta
.
env
.
VITE_WEBSOCKET_URL
||
'
ws://localhost:8080/ws
'
;
const
topic
=
'
mytesttopic
'
;
return
new
DASFConnection
(
new
WebsocketUrlBuilder
(
websocketUrl
,
topic
));
}
describe
(
'
FunctionContainer
'
,
()
=>
{
it
(
'
test FunctionContainer submission
'
,
async
()
=>
{
const
connection
=
createConnection
();
const
result
=
[];
const
handleResponse
=
(
response
)
=>
{
result
.
push
(
response
);
};
const
container
=
render
(
<
FunctionContainer
connection
=
{
connection
}
functionName
=
"test_function"
onResponse
=
{
handleResponse
}
/>,
);
await
vi
.
waitFor
(()
=>
container
.
getByRole
(
'
button
'
),
{
timeout
:
3000
,
interval
:
20
,
});
const
submitButton
=
container
.
getByRole
(
'
button
'
);
expect
(
submitButton
.
innerHTML
).
toBe
(
'
Submit
'
);
await
submitButton
.
click
();
await
vi
.
waitFor
(
()
=>
{
if
(
result
.
length
!=
1
)
throw
Error
(
'
No response yet
'
);
},
{
timeout
:
3000
,
interval
:
20
,
},
);
expect
(
result
[
0
]).
toEqual
(
1
);
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment