11import ClusterToolsPagePo from '@/cypress/e2e/po/pages/explorer/cluster-tools.po' ;
22import ClusterDashboardPagePo from '@/cypress/e2e/po/pages/explorer/cluster-dashboard.po' ;
33import { InstallChartPage } from '@/cypress/e2e/po/pages/explorer/charts/install-charts.po' ;
4- import { CLUSTER_APPS_BASE_URL } from '@/cypress/support/utils/api-endpoints' ;
4+ import { CLUSTER_APPS_BASE_URL , CLUSTER_REPOS_BASE_URL } from '@/cypress/support/utils/api-endpoints' ;
55import { runTestWhenChartAvailable } from '@/cypress/support/commands/rancher-api-commands' ;
66import Kubectl from '@/cypress/e2e/po/components/kubectl.po' ;
77import PromptRemove from '@/cypress/e2e/po/prompts/promptRemove.po' ;
88import { MEDIUM_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts' ;
9+ import LoadingPo from '@/cypress/e2e/po/components/loading.po' ;
10+ import { qase } from '@/cypress/support/qase' ;
911
1012const clusterTools = new ClusterToolsPagePo ( 'local' ) ;
1113const kubectl = new Kubectl ( ) ;
14+ const loadingPo = new LoadingPo ( '.loading-indicator' ) ;
1215
1316describe ( 'Cluster Tools' , { tags : [ '@explorer2' , '@adminUser' ] } , ( ) => {
17+ const CHART = {
18+ name : 'Alerting Drivers' ,
19+ id : 'rancher-alerting-drivers' ,
20+ repo : 'rancher-charts'
21+ } ;
22+ const NAMESPACE = 'default' ;
23+
24+ const cleanup = ( ) => {
25+ cy . createRancherResource ( 'v1' , `catalog.cattle.io.apps/${ NAMESPACE } /${ CHART . id } ?action=uninstall` , '{}' , false ) ;
26+ cy . waitForRancherResource ( 'v1' , 'catalog.cattle.io.apps' , `${ NAMESPACE } /${ CHART . id } ` , ( resp : any ) => resp . status === 404 , 20 , { failOnStatusCode : false } ) ;
27+ } ;
28+
29+ const waitForToolsPage = ( ) => {
30+ clusterTools . goTo ( ) ;
31+ clusterTools . waitForPage ( ) ;
32+ cy . wait ( '@fetchChartData' , MEDIUM_TIMEOUT_OPT ) . its ( 'response.statusCode' ) . should ( 'eq' , 200 ) ;
33+ cy . get ( '@fetchChartData.all' ) . should ( 'have.length.at.least' , 3 ) ;
34+ loadingPo . checkNotExists ( MEDIUM_TIMEOUT_OPT ) ;
35+ } ;
36+
1437 beforeEach ( ( ) => {
1538 cy . login ( ) ;
39+ cy . intercept ( 'GET' , `${ CLUSTER_REPOS_BASE_URL } /**` ) . as ( 'fetchChartData' ) ;
1640 } ) ;
1741
18- it ( 'can navigate to cluster tools and see all feature charts' , ( ) => {
42+ qase ( 2061 , it ( 'can navigate to cluster tools and see all feature charts' , ( ) => {
1943 const clusterDashboard = new ClusterDashboardPagePo ( 'local' ) ;
2044
2145 clusterDashboard . goTo ( ) ;
@@ -26,72 +50,89 @@ describe('Cluster Tools', { tags: ['@explorer2', '@adminUser'] }, () => {
2650 cy . getClusterToolsChartCount ( ) . then ( ( expectedCount ) => {
2751 clusterTools . featureChartCards ( ) . should ( 'have.length' , expectedCount ) ;
2852 } ) ;
29- } ) ;
53+ } ) ) ;
54+
55+ describe ( 'Install' , ( ) => {
56+ beforeEach ( function ( ) {
57+ runTestWhenChartAvailable ( CHART . repo , CHART . id , this , cleanup ) ;
58+ } ) ;
3059
31- it ( 'can deploy chart successfully' , function ( ) {
32- runTestWhenChartAvailable ( 'rancher-charts' , 'rancher-alerting-drivers' , this , ( ) => {
33- // Clean up any previously installed chart before each attempt, so retries start with a clean state
34- cy . createRancherResource ( 'v1' , 'catalog.cattle.io.apps/default/rancher-alerting-drivers?action=uninstall' , '{}' , false ) ;
35- cy . waitForRancherResource ( 'v1' , 'catalog.cattle.io.apps' , 'default/rancher-alerting-drivers' , ( resp : any ) => resp . status === 404 , 20 , { failOnStatusCode : false } ) ;
60+ qase ( 2062 , it ( 'can deploy chart successfully' , function ( ) {
61+ runTestWhenChartAvailable ( CHART . repo , CHART . id , this , ( ) => {
62+ waitForToolsPage ( ) ;
3663
37- clusterTools . goTo ( ) ;
38- clusterTools . waitForPage ( ) ;
39- clusterTools . getChartVersion ( 'Alerting Drivers' ) . invoke ( 'text' ) . then ( ( el ) => {
40- const chartVersion = el . trim ( ) ;
64+ clusterTools . getChartVersion ( CHART . name ) . invoke ( 'text' ) . then ( ( el ) => {
65+ const chartVersion = el . trim ( ) ;
4166
42- const chartType = 'rancher-alerting-drivers' ;
43- const installAlertingDriversPage = `repo-type=cluster&repo=rancher-charts&chart=${ chartType } &version=${ chartVersion } &tools` ;
44- const installCharts = new InstallChartPage ( ) ;
67+ const installAlertingDriversPage = `repo-type=cluster&repo=${ CHART . repo } &chart=${ CHART . id } &version=${ chartVersion } &tools` ;
68+ const installCharts = new InstallChartPage ( ) ;
4569
46- clusterTools . goToInstall ( 'Alerting Drivers' ) ;
47- installCharts . waitForPage ( installAlertingDriversPage ) ;
48- installCharts . nextPage ( ) ;
70+ clusterTools . goToInstall ( CHART . name ) ;
71+ installCharts . waitForPage ( installAlertingDriversPage ) ;
72+ installCharts . nextPage ( ) ;
4973
50- cy . intercept ( 'POST' , 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install' ) . as ( 'chartInstall' ) ;
51- installCharts . installChart ( ) ;
74+ cy . intercept ( 'POST' , `/v1/catalog.cattle.io.clusterrepos/${ CHART . repo } ?action=install` ) . as ( 'chartInstall' ) ;
75+ installCharts . installChart ( ) ;
76+ } ) ;
5277 cy . wait ( '@chartInstall' ) . its ( 'response.statusCode' ) . should ( 'eq' , 201 ) ;
5378 clusterTools . waitForPage ( ) ;
5479 kubectl . waitForTerminalStatus ( 'Connected' ) ;
80+ cy . waitForResourceState ( 'v1' , 'catalog.cattle.io.apps' , `${ NAMESPACE } /${ CHART . id } ` , 'deployed' , 40 ) ;
5581 kubectl . waitForTerminalStatus ( 'Disconnected' , MEDIUM_TIMEOUT_OPT ) ;
5682 } ) ;
57- } ) ;
83+ } ) ) ;
5884 } ) ;
5985
60- it ( 'can edit chart successfully' , function ( ) {
61- runTestWhenChartAvailable ( 'rancher-charts' , 'rancher-alerting-drivers' , this , ( ) => {
62- clusterTools . goTo ( ) ;
63- clusterTools . waitForPage ( ) ;
64- clusterTools . editChart ( 'Alerting Drivers' ) ;
86+ describe ( 'Manage Installed Chart' , ( ) => {
87+ beforeEach ( function ( ) {
88+ runTestWhenChartAvailable ( CHART . repo , CHART . id , this , ( ) => {
89+ cleanup ( ) ;
90+ cy . getChartVersions ( CHART . repo , CHART . id ) . then ( ( versions ) => {
91+ cy . installChart ( CHART . repo , CHART . id , CHART . name , versions [ 0 ] , NAMESPACE ) ;
92+ } ) ;
93+ cy . waitForResourceState ( 'v1' , 'catalog.cattle.io.apps' , `${ NAMESPACE } /${ CHART . id } ` , 'deployed' , 40 ) ;
94+ } ) ;
95+ } ) ;
6596
66- const installChart = new InstallChartPage ( ) ;
97+ qase ( 2063 , it ( 'can edit chart successfully' , function ( ) {
98+ runTestWhenChartAvailable ( CHART . repo , CHART . id , this , ( ) => {
99+ waitForToolsPage ( ) ;
100+ clusterTools . editChart ( CHART . name ) ;
67101
68- installChart . nextPage ( ) ;
102+ const installChartPage = new InstallChartPage ( ) ;
69103
70- cy . intercept ( 'POST' , 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=upgrade' ) . as ( 'chartUpdate' ) ;
71- installChart . installChart ( ) ;
72- cy . wait ( '@chartUpdate' ) . its ( 'response.statusCode' ) . should ( 'eq' , 201 ) ;
73- clusterTools . waitForPage ( ) ;
74- kubectl . waitForTerminalStatus ( 'Connected' ) ;
75- kubectl . waitForTerminalStatus ( 'Disconnected' , MEDIUM_TIMEOUT_OPT ) ;
76- } ) ;
77- } ) ;
104+ installChartPage . nextPage ( ) ;
78105
79- it ( 'can uninstall chart successfully' , function ( ) {
80- runTestWhenChartAvailable ( 'rancher-charts' , 'rancher-alerting-drivers' , this , ( ) => {
81- clusterTools . goTo ( ) ;
82- clusterTools . waitForPage ( ) ;
83- clusterTools . deleteChart ( 'Alerting Drivers' ) ;
106+ cy . intercept ( 'POST' , `v1/catalog.cattle.io.clusterrepos/${ CHART . repo } ?action=upgrade` ) . as ( 'chartUpdate' ) ;
107+ installChartPage . installChart ( ) ;
108+ cy . wait ( '@chartUpdate' ) . its ( 'response.statusCode' ) . should ( 'eq' , 201 ) ;
109+ clusterTools . waitForPage ( ) ;
110+ kubectl . waitForTerminalStatus ( 'Connected' ) ;
111+ cy . waitForResourceState ( 'v1' , 'catalog.cattle.io.apps' , `${ NAMESPACE } /${ CHART . id } ` , 'deployed' , 40 ) ;
112+ kubectl . waitForTerminalStatus ( 'Disconnected' , MEDIUM_TIMEOUT_OPT ) ;
113+ } ) ;
114+ } ) ) ;
84115
85- const promptRemove = new PromptRemove ( ) ;
116+ qase ( 2060 , it ( 'can uninstall chart successfully' , function ( ) {
117+ runTestWhenChartAvailable ( CHART . repo , CHART . id , this , ( ) => {
118+ waitForToolsPage ( ) ;
119+ clusterTools . deleteChart ( CHART . name ) ;
86120
87- promptRemove . checkbox ( ) . checkNotExists ( ) ;
121+ const promptRemove = new PromptRemove ( ) ;
88122
89- cy . intercept ( 'POST' , `${ CLUSTER_APPS_BASE_URL } /default/rancher-alerting-drivers?action=uninstall` ) . as ( 'chartUninstall' ) ;
90- promptRemove . remove ( ) ;
91- cy . wait ( '@chartUninstall' ) . its ( 'response.statusCode' ) . should ( 'eq' , 201 ) ;
92- // we can't check that the initial state is connected... as the supporting socket can connect and disconnect quicker than we can show the window
93- // kubectl.waitForTerminalStatus('Connected');
94- kubectl . waitForTerminalStatus ( 'Disconnected' ) ;
95- } ) ;
123+ promptRemove . checkbox ( ) . checkNotExists ( ) ;
124+
125+ cy . intercept ( 'POST' , `${ CLUSTER_APPS_BASE_URL } /${ NAMESPACE } /${ CHART . id } ?action=uninstall` ) . as ( 'chartUninstall' ) ;
126+ promptRemove . remove ( ) ;
127+ cy . wait ( '@chartUninstall' ) . its ( 'response.statusCode' ) . should ( 'eq' , 201 ) ;
128+ // we can't check that the initial state is connected... as the supporting socket can connect and disconnect quicker than we can show the window
129+ // kubectl.waitForTerminalStatus('Connected');
130+ kubectl . waitForTerminalStatus ( 'Disconnected' , MEDIUM_TIMEOUT_OPT ) ;
131+ } ) ;
132+ } ) ) ;
133+ } ) ;
134+
135+ after ( ( ) => {
136+ cleanup ( ) ;
96137 } ) ;
97138} ) ;
0 commit comments