@@ -5,10 +5,12 @@ import { MEDIUM_TIMEOUT_OPT, LONG_TIMEOUT_OPT } from '@/cypress/support/utils/ti
55import Kubectl from '@/cypress/e2e/po/components/kubectl.po' ;
66import { CompliancePo , ComplianceListPo } from '~/cypress/e2e/po/other-products/compliance.po' ;
77import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po' ;
8+ import { runTestWhenChartAvailable } from '@/cypress/support/commands/rancher-api-commands' ;
89
910describe ( 'Charts' , { testIsolation : 'off' , tags : [ '@charts' , '@adminUser' ] } , ( ) => {
1011 before ( ( ) => {
1112 cy . login ( ) ;
13+ cy . setUserPreference ( { 'show-pre-release' : true } , true ) ; // Show pre-release versions so charts with only -rc versions appear on Charts page
1214 HomePagePo . goTo ( ) ;
1315 } ) ;
1416
@@ -17,78 +19,80 @@ describe('Charts', { testIsolation: 'off', tags: ['@charts', '@adminUser'] }, ()
1719 const chartPage = new ChartPage ( ) ;
1820
1921 describe ( 'YAML view' , ( ) => {
20- beforeEach ( ( ) => {
21- ChartPage . navTo ( null , 'Rancher Compliance' ) ;
22- chartPage . waitForChartHeader ( 'Rancher Compliance' , MEDIUM_TIMEOUT_OPT ) ;
23- chartPage . goToInstall ( ) ;
24- installChartPage . nextPage ( ) . editYaml ( ) ;
25- } ) ;
26-
2722 describe ( 'UI Elements' , ( ) => {
28- it ( 'Footer controls should sticky to bottom' , ( ) => {
29- cy . get ( '#wizard-footer-controls' ) . should ( 'be.visible' ) ;
30-
31- cy . get ( '#wizard-footer-controls' ) . then ( ( $el ) => {
32- const elementRect = $el [ 0 ] . getBoundingClientRect ( ) ;
33- const viewportHeight = Cypress . config ( 'viewportHeight' ) ;
34- const pageHeight = Cypress . $ ( cy . state ( 'window' ) ) . height ( ) ;
35-
36- expect ( elementRect . bottom ) . to . eq ( pageHeight ) ;
37- expect ( elementRect . bottom ) . to . eq ( viewportHeight ) ;
23+ it ( 'Footer controls should sticky to bottom' , function ( ) {
24+ runTestWhenChartAvailable ( 'rancher-charts' , 'rancher-compliance' , this , ( ) => {
25+ ChartPage . navTo ( null , 'Rancher Compliance' ) ;
26+ chartPage . waitForChartHeader ( 'Rancher Compliance' , MEDIUM_TIMEOUT_OPT ) ;
27+ chartPage . goToInstall ( ) ;
28+ installChartPage . nextPage ( ) . editYaml ( ) ;
29+
30+ installChartPage . footerControls ( ) . should ( 'be.visible' ) ;
31+
32+ installChartPage . footerControls ( ) . then ( ( $el ) => {
33+ const elementRect = $el [ 0 ] . getBoundingClientRect ( ) ;
34+ const viewportHeight = Cypress . config ( 'viewportHeight' ) ;
35+ const pageHeight = Cypress . $ ( cy . state ( 'window' ) ) . height ( ) ;
36+
37+ expect ( elementRect . bottom ) . to . eq ( pageHeight ) ;
38+ expect ( elementRect . bottom ) . to . eq ( viewportHeight ) ;
39+ } ) ;
3840 } ) ;
3941 } ) ;
4042 } ) ;
4143 } ) ;
4244
4345 describe ( 'Compliance Chart setup' , ( ) => {
44- it ( 'Complete install and a Scan is created' , ( ) => {
45- cy . updateNamespaceFilter ( 'local' , 'none' , '{"local":[]}' ) ;
46- const kubectl = new Kubectl ( ) ;
47- const compliance = new CompliancePo ( ) ;
48- const complianceList = new ComplianceListPo ( ) ;
49- const sideNav = new ProductNavPo ( ) ;
50- const terminal = new Kubectl ( ) ;
51-
52- ChartPage . navTo ( null , 'Rancher Compliance' ) ;
53- chartPage . waitForChartHeader ( 'Rancher Compliance' , MEDIUM_TIMEOUT_OPT ) ;
54- chartPage . goToInstall ( ) ;
55-
56- installChartPage . nextPage ( ) ;
57-
58- cy . intercept ( 'POST' , 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install' ) . as ( 'chartInstall' ) ;
59- installChartPage . installChart ( ) ;
60- cy . wait ( '@chartInstall' ) . its ( 'response.statusCode' ) . should ( 'eq' , 201 ) ;
61- kubectl . waitForTerminalStatus ( 'Disconnected' ) ;
62-
63- kubectl . closeTerminal ( ) ;
64-
65- sideNav . navToSideMenuGroupByLabel ( 'Compliance' ) ;
66- complianceList . waitForPage ( ) ;
67-
68- // Compliance does not come with any profiles, so create one
69-
70- // Open terminal
71- terminal . openTerminal ( LONG_TIMEOUT_OPT ) ;
72-
73- // kubectl commands
74- terminal . executeCommand ( `apply -f https://raw.githubusercontent.com/rancher/compliance-operator/refs/heads/main/tests/k3s-bench-test.yaml` ) ;
75-
76- terminal . closeTerminal ( ) ;
77-
78- complianceList . createScan ( ) ;
79- compliance . waitForPage ( ) ;
80- compliance . cruResource ( ) . saveAndWaitForRequests ( 'POST' , 'v1/compliance.cattle.io.clusterscans' )
81- . then ( ( { response } ) => {
82- expect ( response ?. statusCode ) . to . eq ( 201 ) ;
83- expect ( response ?. body ) . to . have . property ( 'type' , 'compliance.cattle.io.clusterscan' ) ;
84- expect ( response ?. body . metadata ) . to . have . property ( 'name' ) ;
85- expect ( response ?. body . metadata ) . to . have . property ( 'generateName' , 'scan-' ) ;
86- } ) ;
87- complianceList . waitForPage ( ) ;
88- complianceList . checkVisible ( ) ;
89-
90- complianceList . list ( ) . resourceTable ( ) . checkVisible ( ) ;
91- complianceList . list ( ) . resourceTable ( ) . sortableTable ( ) . checkRowCount ( false , 2 ) ;
46+ it ( 'Complete install and a Scan is created' , function ( ) {
47+ runTestWhenChartAvailable ( 'rancher-charts' , 'rancher-compliance' , this , ( ) => {
48+ cy . updateNamespaceFilter ( 'local' , 'none' , '{"local":[]}' ) ;
49+ const kubectl = new Kubectl ( ) ;
50+ const compliance = new CompliancePo ( ) ;
51+ const complianceList = new ComplianceListPo ( ) ;
52+ const sideNav = new ProductNavPo ( ) ;
53+ const terminal = new Kubectl ( ) ;
54+
55+ ChartPage . navTo ( null , 'Rancher Compliance' ) ;
56+ chartPage . waitForChartHeader ( 'Rancher Compliance' , MEDIUM_TIMEOUT_OPT ) ;
57+ chartPage . goToInstall ( ) ;
58+
59+ installChartPage . nextPage ( ) ;
60+
61+ cy . intercept ( 'POST' , 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install' ) . as ( 'chartInstall' ) ;
62+ installChartPage . installChart ( ) ;
63+ cy . wait ( '@chartInstall' ) . its ( 'response.statusCode' ) . should ( 'eq' , 201 ) ;
64+ kubectl . waitForTerminalStatus ( 'Disconnected' ) ;
65+
66+ kubectl . closeTerminal ( ) ;
67+
68+ sideNav . navToSideMenuGroupByLabel ( 'Compliance' ) ;
69+ complianceList . waitForPage ( ) ;
70+
71+ // Compliance does not come with any profiles, so create one
72+
73+ // Open terminal
74+ terminal . openTerminal ( LONG_TIMEOUT_OPT ) ;
75+
76+ // kubectl commands
77+ terminal . executeCommand ( `apply -f https://raw.githubusercontent.com/rancher/compliance-operator/refs/heads/main/tests/k3s-bench-test.yaml` ) ;
78+
79+ terminal . closeTerminal ( ) ;
80+
81+ complianceList . createScan ( ) ;
82+ compliance . waitForPage ( ) ;
83+ compliance . cruResource ( ) . saveAndWaitForRequests ( 'POST' , 'v1/compliance.cattle.io.clusterscans' )
84+ . then ( ( { response } ) => {
85+ expect ( response ?. statusCode ) . to . eq ( 201 ) ;
86+ expect ( response ?. body ) . to . have . property ( 'type' , 'compliance.cattle.io.clusterscan' ) ;
87+ expect ( response ?. body . metadata ) . to . have . property ( 'name' ) ;
88+ expect ( response ?. body . metadata ) . to . have . property ( 'generateName' , 'scan-' ) ;
89+ } ) ;
90+ complianceList . waitForPage ( ) ;
91+ complianceList . checkVisible ( ) ;
92+
93+ complianceList . list ( ) . resourceTable ( ) . checkVisible ( ) ;
94+ complianceList . list ( ) . resourceTable ( ) . sortableTable ( ) . checkRowCount ( false , 2 ) ;
95+ } ) ;
9296 } ) ;
9397
9498 after ( 'clean up' , ( ) => {
@@ -102,4 +106,8 @@ describe('Charts', { testIsolation: 'off', tags: ['@charts', '@adminUser'] }, ()
102106 } ) ;
103107 } ) ;
104108 } ) ;
109+
110+ after ( ( ) => {
111+ cy . setUserPreference ( { 'show-pre-release' : false } ) ;
112+ } ) ;
105113} ) ;
0 commit comments