11import { McpHeader } from './McpHeader' ;
22import { ControlPlaneType } from '../../../lib/api/types/crate/controlPlanes.ts' ;
33
4- const mcp = {
5- metadata : {
6- name : 'my-control-plane' ,
7- creationTimestamp : '2024-04-15T10:30:00.000Z' ,
8- annotations : {
9- 'openmcp.cloud/created-by' :
'[email protected] ' , 10- } ,
11- } ,
12- } as ControlPlaneType ;
13-
144describe ( 'McpHeader' , ( ) => {
15- it ( 'renders MCP matadata' , ( ) => {
5+ it ( 'renders MCP metadata' , ( ) => {
6+ const mcp = {
7+ metadata : {
8+ name : 'my-control-plane' ,
9+ creationTimestamp : '2024-04-15T10:30:00.000Z' ,
10+ annotations : {
11+ 'openmcp.cloud/created-by' :
'[email protected] ' , 12+ } ,
13+ } ,
14+ } as ControlPlaneType ;
15+
1616 cy . clock ( new Date ( '2024-04-17T10:30:00.000Z' ) . getTime ( ) ) ; // 2 days after MCP creation date
1717 const creationDateAsString = new Date ( '2024-04-15T10:30:00.000Z' ) . toLocaleDateString ( undefined , {
1818 day : 'numeric' ,
@@ -26,4 +26,25 @@ describe('McpHeader', () => {
2626 cy . contains ( 'span' , '[email protected] ' ) . should ( 'be.visible' ) ; 2727 cy . contains ( 'span' , `${ creationDateAsString } (2 days ago)` ) . should ( 'be.visible' ) ;
2828 } ) ;
29+
30+ it ( 'renders with missing MCP metadata' , ( ) => {
31+ const mcp = {
32+ metadata : {
33+ name : 'my-control-plane' ,
34+ creationTimestamp : '2024-04-15T10:30:00.000Z' ,
35+ } ,
36+ } as ControlPlaneType ; // missing annotations
37+
38+ cy . clock ( new Date ( '2024-04-17T10:30:00.000Z' ) . getTime ( ) ) ; // 2 days after MCP creation date
39+ const creationDateAsString = new Date ( '2024-04-15T10:30:00.000Z' ) . toLocaleDateString ( undefined , {
40+ day : 'numeric' ,
41+ month : 'long' ,
42+ year : 'numeric' ,
43+ } ) ;
44+
45+ cy . mount ( < McpHeader mcp = { mcp } /> ) ;
46+
47+ cy . contains ( 'span' , 'my-control-plane' ) . should ( 'be.visible' ) ;
48+ cy . contains ( 'span' , `${ creationDateAsString } (2 days ago)` ) . should ( 'be.visible' ) ;
49+ } ) ;
2950} ) ;
0 commit comments