@rancher/shell 0.3.29 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.DS_Store +0 -0
  2. package/assets/translations/en-us.yaml +1 -1
  3. package/assets/translations/zh-hans.yaml +1 -1
  4. package/components/CopyCode.vue +6 -2
  5. package/components/CopyToClipboard.vue +2 -1
  6. package/components/CopyToClipboardText.vue +14 -9
  7. package/components/EtcdInfoBanner.vue +4 -4
  8. package/components/Markdown.vue +16 -12
  9. package/components/ResourceDetail/Masthead.vue +9 -6
  10. package/components/StatusTable.vue +5 -1
  11. package/components/__tests__/CopyCode.test.ts +5 -4
  12. package/components/fleet/FleetBundles.vue +5 -11
  13. package/components/fleet/FleetSummary.vue +3 -3
  14. package/components/fleet/__tests__/FleetSummary.test.ts +316 -0
  15. package/components/form/Password.vue +3 -1
  16. package/components/nav/Header.vue +1 -1
  17. package/config/home-links.js +1 -1
  18. package/core/plugin-helpers.js +3 -5
  19. package/creators/app/files/.gitlab-ci.yml +14 -0
  20. package/creators/app/init +19 -0
  21. package/edit/monitoring.coreos.com.prometheusrule/AlertingRule.vue +12 -3
  22. package/edit/monitoring.coreos.com.prometheusrule/GroupRules.vue +2 -1
  23. package/edit/provisioning.cattle.io.cluster/__tests__/CustomCommand.tests.ts +3 -1
  24. package/edit/workload/Upgrading.vue +3 -2
  25. package/edit/workload/storage/persistentVolumeClaim/persistentvolumeclaim.vue +2 -1
  26. package/initialize/index.js +24 -5
  27. package/models/__tests__/management.cattle.io.cluster.test.ts +4 -0
  28. package/models/management.cattle.io.cluster.js +7 -3
  29. package/models/provisioning.cattle.io.cluster.js +19 -1
  30. package/package.json +2 -2
  31. package/pages/c/_cluster/apps/charts/index.vue +64 -43
  32. package/plugins/clean-html-directive.js +1 -19
  33. package/plugins/clean-html.js +53 -0
  34. package/plugins/clean-tooltip-directive.js +1 -1
  35. package/plugins/index.js +11 -0
  36. package/scripts/.DS_Store +0 -0
  37. package/scripts/extension/bundle +19 -7
  38. package/scripts/extension/helm/scripts/package +11 -3
  39. package/scripts/extension/publish +20 -9
  40. package/scripts/verdaccio.log +205 -0
  41. package/store/index.js +3 -4
  42. package/types/shell/index.d.ts +6 -0
  43. package/utils/clipboard.js +5 -0
  44. package/plugins/vue-clipboard2.js +0 -4
package/.DS_Store CHANGED
Binary file
@@ -874,7 +874,7 @@ catalog:
874
874
  versionWindowsIncompatible: Linux only version
875
875
  header: Charts
876
876
  featuredCharts: Featured Charts
877
- noCharts: 'There are no charts available, have you added any repos?'
877
+ noCharts: 'There are no charts available, have you added any repos or set filters?'
878
878
  noWindows: Your repos do not contain any charts capable of being deployed on a cluster with Windows nodes.
879
879
  noWindowsAndLinux: Your repos do not contain any charts capable of being deployed on a cluster with both Windows and Linux worker nodes.
880
880
  operatingSystems:
@@ -2080,7 +2080,7 @@ drainNode:
2080
2080
  etcdInfoBanner:
2081
2081
  hasLeader: "ETCD 有一个 Leader:"
2082
2082
  leaderChanges: "Leader 变化的次数:"
2083
- failedProposals: "失败的 proposal 数量"
2083
+ failedProposals: "失败的 proposal 数量:"
2084
2084
 
2085
2085
  fleet:
2086
2086
  dashboard:
@@ -1,5 +1,7 @@
1
1
  <script>
2
2
  import { isArray } from '@shell/utils/array';
3
+ import { copyTextToClipboard } from '@shell/utils/clipboard';
4
+ import { exceptionToErrorsArray } from '@shell/utils/error';
3
5
 
4
6
  function flatten(node) {
5
7
  if ( node.text ) {
@@ -27,14 +29,16 @@ export default {
27
29
 
28
30
  const content = flatten(this.$slots.default).trim();
29
31
 
30
- this.$copyText(content).then(() => {
32
+ copyTextToClipboard(content).then(() => {
31
33
  this.copied = true;
32
34
 
33
35
  setTimeout(() => {
34
36
  this.copied = false;
35
37
  }, 2000);
38
+ this.$emit('copied');
39
+ }).catch((e) => {
40
+ this.$emit('error', exceptionToErrorsArray(e));
36
41
  });
37
- this.$emit('copied');
38
42
  },
39
43
  },
40
44
 
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  import AsyncButton from '@shell/components/AsyncButton';
3
+ import { copyTextToClipboard } from '@shell/utils/clipboard';
3
4
 
4
5
  export default {
5
6
  components: { AsyncButton },
@@ -18,7 +19,7 @@ export default {
18
19
 
19
20
  methods: {
20
21
  clicked(buttonCb) {
21
- this.$copyText(this.text).then(() => {
22
+ copyTextToClipboard(this.text).then(() => {
22
23
  buttonCb(true);
23
24
  }).catch(() => {
24
25
  buttonCb(false);
@@ -1,4 +1,6 @@
1
1
  <script>
2
+ import { copyTextToClipboard } from '@shell/utils/clipboard';
3
+ import { exceptionToErrorsArray } from '@shell/utils/error';
2
4
  export default {
3
5
  props: {
4
6
  text: {
@@ -20,17 +22,20 @@ export default {
20
22
  clicked(event) {
21
23
  if (!this.copied) {
22
24
  event.preventDefault();
23
- this.$copyText(this.text);
24
- this.copied = true;
25
+ copyTextToClipboard(this.text).then(() => {
26
+ this.copied = true;
25
27
 
26
- let t = event.target;
28
+ let t = event.target;
27
29
 
28
- if (t.tagName === 'I') {
29
- t = t.parentElement || t;
30
- }
31
- setTimeout(() => {
32
- this.copied = false;
33
- }, 500);
30
+ if (t.tagName === 'I') {
31
+ t = t.parentElement || t;
32
+ }
33
+ setTimeout(() => {
34
+ this.copied = false;
35
+ }, 500);
36
+ }).catch((e) => {
37
+ this.$emit('error', exceptionToErrorsArray(e));
38
+ });
34
39
  }
35
40
  },
36
41
  }
@@ -23,13 +23,13 @@ export default {
23
23
 
24
24
  const leader = await hasLeader(monitoringVersion, this.$store.dispatch, this.currentCluster.id);
25
25
 
26
- this.hasLeader = leader ? this.t('generic.yes') : this.t('generic.no');
26
+ this.hasLeader = leader ? 'Yes' : 'No';
27
27
  this.leaderChanges = await leaderChanges(monitoringVersion, this.$store.dispatch, this.currentCluster.id);
28
28
  this.failedProposals = await failedProposals(monitoringVersion, this.$store.dispatch, this.currentCluster.id);
29
29
  },
30
30
  data() {
31
31
  return {
32
- hasLeader: this.t('generic.no'),
32
+ hasLeader: 'No',
33
33
  leaderChanges: 0,
34
34
  failedProposals: 0
35
35
  };
@@ -46,10 +46,10 @@ export default {
46
46
  color="info"
47
47
  >
48
48
  <div class="datum">
49
- <label>{{ t('etcdInfoBanner.hasLeader') }}</label> {{ hasLeader }}
49
+ <label>{{ t('etcdInfoBanner.hasLeader') }}</label> {{ hasLeader }},
50
50
  </div>
51
51
  <div class="datum">
52
- <label>{{ t('etcdInfoBanner.leaderChanges') }}</label> {{ leaderChanges }}
52
+ <label>{{ t('etcdInfoBanner.leaderChanges') }}</label> {{ leaderChanges }},
53
53
  </div>
54
54
  <div class="datum">
55
55
  <label>{{ t('etcdInfoBanner.failedProposals') }}</label> {{ failedProposals }}
@@ -13,9 +13,8 @@ export default {
13
13
 
14
14
  data() {
15
15
  return {
16
- loaded: false,
17
- marked: null,
18
- dompurify: null,
16
+ loaded: false,
17
+ marked: null,
19
18
  };
20
19
  },
21
20
 
@@ -26,15 +25,10 @@ export default {
26
25
  breaks: true
27
26
  });
28
27
  },
29
-
30
- sanitized() {
31
- return this.dompurify.sanitize(this.html);
32
- },
33
28
  },
34
29
 
35
30
  async mounted() {
36
31
  const marked = (await import(/* webpackChunkName: "markdown" */ 'marked'));
37
- const dompurify = (await import(/* webpackChunkName: "markdown" */ 'dompurify')).default;
38
32
 
39
33
  const renderer = new marked.Renderer();
40
34
  const linkRenderer = renderer.link;
@@ -63,11 +57,8 @@ export default {
63
57
  return rendered;
64
58
  };
65
59
 
66
- dompurify.setConfig({ ADD_ATTR: ['target'] });
67
-
68
60
  this.marked = marked;
69
61
  this.markedRenderer = renderer;
70
- this.dompurify = dompurify;
71
62
  this.loaded = true;
72
63
  this.$emit('loaded', true);
73
64
  }
@@ -77,7 +68,7 @@ export default {
77
68
  <template>
78
69
  <div
79
70
  v-if="loaded"
80
- v-clean-html="sanitized"
71
+ v-clean-html="html"
81
72
  class="markdown"
82
73
  />
83
74
  <Loading v-else />
@@ -96,8 +87,20 @@ export default {
96
87
  }
97
88
 
98
89
  .markdown {
90
+ blockquote {
91
+ color: rgb(101, 109, 118);
92
+ border-left: 0.25em solid rgb(208, 215, 222);
93
+ padding: 0 1em;
94
+ margin-bottom: 16px;
95
+ }
96
+
97
+ table {
98
+ border-collapse: collapse;
99
+ }
100
+
99
101
  TH {
100
102
  text-align: left;
103
+ border: 1px solid #e3e7eb;
101
104
  }
102
105
 
103
106
  table tr th {
@@ -118,6 +121,7 @@ export default {
118
121
  text-align: left;
119
122
  margin: 0;
120
123
  padding: 6px 13px;
124
+ border: 1px solid #e3e7eb;
121
125
  }
122
126
 
123
127
  table tr th :first-child, table tr td :first-child {
@@ -177,13 +177,16 @@ export default {
177
177
 
178
178
  project() {
179
179
  if (this.isNamespace) {
180
- const id = (this.value?.metadata?.labels || {})[PROJECT];
181
- const clusterId = this.$store.getters['currentCluster'].id;
180
+ const cluster = this.$store.getters['currentCluster'];
182
181
 
183
- return this.$store.getters['management/byId'](MANAGEMENT.PROJECT, `${ clusterId }/${ id }`);
184
- } else {
185
- return null;
182
+ if (cluster) {
183
+ const id = (this.value?.metadata?.labels || {})[PROJECT];
184
+
185
+ return this.$store.getters['management/byId'](MANAGEMENT.PROJECT, `${ cluster.id }/${ id }`);
186
+ }
186
187
  }
188
+
189
+ return null;
187
190
  },
188
191
 
189
192
  banner() {
@@ -370,7 +373,7 @@ export default {
370
373
  },
371
374
 
372
375
  hideNamespaceLocation() {
373
- return this.$store.getters['currentProduct'].hideNamespaceLocation;
376
+ return this.$store.getters['currentProduct'].hideNamespaceLocation || this.value.namespaceLocation === null;
374
377
  },
375
378
  },
376
379
 
@@ -3,6 +3,8 @@ import {
3
3
  LAST_UPDATED, TYPE, REASON, MESSAGE, STATUS
4
4
  } from '@shell/config/table-headers';
5
5
  import SortableTable from '@shell/components/SortableTable';
6
+ import { copyTextToClipboard } from '@shell/utils/clipboard';
7
+ import { exceptionToErrorsArray } from '@shell/utils/error';
6
8
  export default {
7
9
  components: { SortableTable },
8
10
  props: {
@@ -31,12 +33,14 @@ export default {
31
33
  $event.stopPropagation();
32
34
  $event.preventDefault();
33
35
 
34
- this.$copyText(this.$slots.default[0].text).then(() => {
36
+ copyTextToClipboard(this.$slots.default[0].text).then(() => {
35
37
  this.copied = true;
36
38
 
37
39
  setTimeout(() => {
38
40
  this.copied = false;
39
41
  }, 2000);
42
+ }).catch((e) => {
43
+ this.$emit('error', exceptionToErrorsArray(e));
40
44
  });
41
45
  },
42
46
  }
@@ -1,12 +1,13 @@
1
1
  import { mount } from '@vue/test-utils';
2
2
  import CopyCode from '@shell/components/CopyCode.vue';
3
3
 
4
+ jest.mock('@shell/utils/clipboard', () => {
5
+ return { copyTextToClipboard: jest.fn(() => Promise.resolve({})) };
6
+ });
7
+
4
8
  describe('component: CopyCode', () => {
5
9
  it('should emit copied after click', async() => {
6
- const wrapper = mount(CopyCode, {
7
- mocks: { $copyText: () => new Promise(() => undefined) },
8
- slots: { default: '<div></div>' }
9
- });
10
+ const wrapper = mount(CopyCode, { slots: { default: '<div></div>' } });
10
11
 
11
12
  await wrapper.find('code').trigger('click');
12
13
 
@@ -37,8 +37,8 @@ export default {
37
37
 
38
38
  computed: {
39
39
 
40
- allBundles() {
41
- // gitrepo model has getter for bundles.
40
+ allBundlesInRepo() {
41
+ // gitrepo model has getter for its bundles.
42
42
  return this.value.bundles || [];
43
43
  },
44
44
 
@@ -65,13 +65,7 @@ export default {
65
65
  bundles() {
66
66
  const harvester = this.harvesterClusters;
67
67
 
68
- return this.allBundles.filter((bundle) => {
69
- const isRepoBundle = bundle.metadata.name.startsWith(`${ this.value.metadata.name }-`);
70
-
71
- if (!isRepoBundle) {
72
- return false;
73
- }
74
-
68
+ return this.allBundlesInRepo.filter((bundle) => {
75
69
  const targets = bundle.spec?.targets || [];
76
70
 
77
71
  // Filter out any bundle that has one target whose cluster is a harvester cluster
@@ -84,7 +78,7 @@ export default {
84
78
  },
85
79
 
86
80
  hidden() {
87
- return this.allBundles.length - this.bundles.length;
81
+ return this.allBundlesInRepo.length - this.bundles.length;
88
82
  },
89
83
 
90
84
  headers() {
@@ -105,7 +99,6 @@ export default {
105
99
  return out;
106
100
  },
107
101
  },
108
-
109
102
  methods: {
110
103
  displayWarning(row) {
111
104
  return !!row.status?.summary && (row.status.summary.desiredReady !== row.status.summary.ready);
@@ -113,6 +106,7 @@ export default {
113
106
  }
114
107
  };
115
108
  </script>
109
+
116
110
  <template>
117
111
  <div>
118
112
  <Loading v-if="$fetchState.pending" />
@@ -1,5 +1,4 @@
1
1
  <script>
2
- import capitalize from 'lodash/capitalize';
3
2
  import { STATES, STATES_ENUM } from '@shell/plugins/dashboard-store/resource-class';
4
3
  import FleetStatus from '@shell/components/fleet/FleetStatus';
5
4
 
@@ -85,7 +84,7 @@ export default {
85
84
  },
86
85
 
87
86
  bundleCounts() {
88
- const resources = this.bundles.filter((item) => item.metadata.name.startsWith(`${ this.repoName }-`));
87
+ const resources = this.bundles.filter((item) => item.repoName === this.repoName);
89
88
 
90
89
  if (!resources.length) {
91
90
  return [];
@@ -179,7 +178,6 @@ export default {
179
178
 
180
179
  },
181
180
 
182
- methods: { capitalize },
183
181
  };
184
182
  </script>
185
183
 
@@ -190,11 +188,13 @@ export default {
190
188
  title="Bundles"
191
189
  :values="bundleCounts"
192
190
  value-key="count"
191
+ data-testid="gitrepo-bundle-summary"
193
192
  />
194
193
  <FleetStatus
195
194
  title="Resources"
196
195
  :values="resourceCounts"
197
196
  value-key="count"
197
+ data-testid="gitrepo-deployment-summary"
198
198
  />
199
199
  </div>
200
200
  </template>
@@ -0,0 +1,316 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import FleetSummary from '@shell/components/fleet/FleetSummary.vue';
3
+
4
+ const REPO_NAME = 'testrepo';
5
+
6
+ const REPO_NAME_VARIANT = 'testrepo-again';
7
+
8
+ const CLUSTER_NAME = 'testcluster';
9
+
10
+ const mockedBundlesInRepo = [{
11
+ id: `fleet-default/${ REPO_NAME }-${ CLUSTER_NAME }-1234`,
12
+ type: 'fleet.cattle.io.bundle',
13
+ apiVersion: 'fleet.cattle.io/v1alpha1',
14
+ kind: 'Bundle',
15
+ repoName: REPO_NAME,
16
+ metadata: {
17
+ labels: {
18
+ 'fleet.cattle.io/commit': '3640888439d1b7b6a53dbeee291a533eea2632ab',
19
+ 'fleet.cattle.io/repo-name': REPO_NAME
20
+ },
21
+
22
+ name: `${ REPO_NAME }-${ CLUSTER_NAME }-1234`,
23
+ namespace: 'fleet-default',
24
+ state: {
25
+ error: false,
26
+ message: 'Resource is Ready',
27
+ name: 'active',
28
+ transitioning: false
29
+ },
30
+ },
31
+ spec: {
32
+ correctDrift: { },
33
+ forceSyncGeneration: 2,
34
+ ignore: { },
35
+ namespace: 'custom-namespace-name',
36
+ resources: [
37
+ {
38
+ content: 'apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: configmap-test\n annotations:\n {}\n# key: string\n labels:\n {}\n# key: string\ndata:\n key1: val1\n key2: val2\n key3: val3',
39
+ name: 'test-configmap.yaml'
40
+ }
41
+ ],
42
+ targets: [
43
+ {
44
+ clusterName: 'nb-cluster0-28',
45
+ namespace: 'custom-namespace-name'
46
+ }
47
+ ]
48
+ }
49
+ },
50
+ {
51
+ id: `fleet-default/${ REPO_NAME }-${ CLUSTER_NAME }-5678`,
52
+ type: 'fleet.cattle.io.bundle',
53
+ apiVersion: 'fleet.cattle.io/v1alpha1',
54
+ kind: 'Bundle',
55
+ repoName: REPO_NAME,
56
+ metadata: {
57
+ labels: {
58
+ 'fleet.cattle.io/commit': '3640888439d1b7b6a53dbeee291a533eea2632ab',
59
+ 'fleet.cattle.io/repo-name': REPO_NAME
60
+ },
61
+
62
+ name: `${ REPO_NAME }-${ CLUSTER_NAME }-5678`,
63
+ namespace: 'fleet-default',
64
+ state: {
65
+ error: false,
66
+ message: 'Resource is Ready',
67
+ name: 'active',
68
+ transitioning: false
69
+ },
70
+ },
71
+ spec: {
72
+ correctDrift: { },
73
+ forceSyncGeneration: 2,
74
+ ignore: { },
75
+ namespace: 'custom-namespace-name',
76
+ resources: [
77
+ {
78
+ content: 'apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: nginx-cluster0\n labels:\n app: nginx\nspec:\n replicas: 1\n selector:\n matchLabels:\n app: nginx\n template:\n metadata:\n labels:\n app: nginx\n spec:\n containers:\n - name: nginx\n image: nginx:latest\n ports:\n - containerPort: 80',
79
+ name: 'nginx.yml'
80
+ },
81
+ ],
82
+ targets: [
83
+ {
84
+ clusterName: 'nb-cluster0-28',
85
+ namespace: 'custom-namespace-name'
86
+ }
87
+ ]
88
+ }
89
+ }];
90
+
91
+ const mockedBundlesOutOfRepo = [{
92
+ id: `fleet-default/${ REPO_NAME_VARIANT }-${ CLUSTER_NAME }-1234`,
93
+ type: 'fleet.cattle.io.bundle',
94
+ apiVersion: 'fleet.cattle.io/v1alpha1',
95
+ kind: 'Bundle',
96
+ repoName: REPO_NAME_VARIANT,
97
+ metadata: {
98
+ labels: {
99
+ 'fleet.cattle.io/commit': '3640888439d1b7b6a53dbeee291a533eea2632ab',
100
+ 'fleet.cattle.io/repo-name': REPO_NAME_VARIANT
101
+ },
102
+
103
+ name: `${ REPO_NAME_VARIANT }-${ CLUSTER_NAME }-1234`,
104
+ namespace: 'fleet-default',
105
+ state: {
106
+ error: false,
107
+ message: 'Resource is Ready',
108
+ name: 'active',
109
+ transitioning: false
110
+ },
111
+ },
112
+ spec: {
113
+ correctDrift: { },
114
+ forceSyncGeneration: 2,
115
+ ignore: { },
116
+ namespace: 'custom-namespace-name',
117
+ resources: [
118
+ {
119
+ content: 'apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: configmap-test\n annotations:\n {}\n# key: string\n labels:\n {}\n# key: string\ndata:\n key1: val1\n key2: val2\n key3: val3',
120
+ name: 'test-configmap.yaml'
121
+ }
122
+ ],
123
+ targets: [
124
+ {
125
+ clusterName: 'nb-cluster0-28',
126
+ namespace: 'custom-namespace-name'
127
+ }
128
+ ]
129
+ }
130
+ },
131
+ {
132
+ id: `fleet-default/${ REPO_NAME_VARIANT }-${ CLUSTER_NAME }-5678`,
133
+ type: 'fleet.cattle.io.bundle',
134
+ apiVersion: 'fleet.cattle.io/v1alpha1',
135
+ kind: 'Bundle',
136
+ repoName: REPO_NAME_VARIANT,
137
+ metadata: {
138
+ labels: {
139
+ 'fleet.cattle.io/commit': '3640888439d1b7b6a53dbeee291a533eea2632ab',
140
+ 'fleet.cattle.io/repo-name': REPO_NAME_VARIANT
141
+ },
142
+
143
+ name: `${ REPO_NAME_VARIANT }-${ CLUSTER_NAME }-5678`,
144
+ namespace: 'fleet-default',
145
+ state: {
146
+ error: false,
147
+ message: 'Resource is Ready',
148
+ name: 'active',
149
+ transitioning: false
150
+ },
151
+ },
152
+ spec: {
153
+ correctDrift: { },
154
+ forceSyncGeneration: 2,
155
+ ignore: { },
156
+ namespace: 'custom-namespace-name',
157
+ resources: [
158
+ {
159
+ content: 'apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: nginx-cluster0\n labels:\n app: nginx\nspec:\n replicas: 1\n selector:\n matchLabels:\n app: nginx\n template:\n metadata:\n labels:\n app: nginx\n spec:\n containers:\n - name: nginx\n image: nginx:latest\n ports:\n - containerPort: 80',
160
+ name: 'nginx.yml'
161
+ },
162
+ ],
163
+ targets: [
164
+ {
165
+ clusterName: 'nb-cluster0-28',
166
+ namespace: 'custom-namespace-name'
167
+ }
168
+ ]
169
+ }
170
+ }];
171
+
172
+ const mockRepo = {
173
+ id: `fleet-default/${ REPO_NAME }`,
174
+ type: 'fleet.cattle.io.gitrepo',
175
+ apiVersion: 'fleet.cattle.io/v1alpha1',
176
+ kind: 'GitRepo',
177
+ metadata: {
178
+
179
+ name: `${ REPO_NAME }`,
180
+ namespace: 'fleet-default',
181
+ state: {
182
+ error: false,
183
+ message: 'Resource is Ready',
184
+ name: 'active',
185
+ transitioning: false
186
+ },
187
+ },
188
+ spec: {
189
+ branch: 'main',
190
+ correctDrift: { enabled: false },
191
+ forceSyncGeneration: 2,
192
+ insecureSkipTLSVerify: false,
193
+ paths: [
194
+ './cluster0'
195
+ ],
196
+ repo: 'https://github.com/testuser/testrepo.git',
197
+ targetNamespace: 'custom-namespace-name',
198
+ targets: [
199
+ { clusterName: `${ CLUSTER_NAME }` }
200
+ ]
201
+ },
202
+ status: {
203
+ commit: '3640888439d1b7b6a53dbeee291a533eea2632ab',
204
+ conditions: [
205
+ {
206
+ error: false,
207
+ lastUpdateTime: '2023-10-05T18:06:27Z',
208
+ status: 'True',
209
+ transitioning: false,
210
+ type: 'Ready'
211
+ },
212
+ {
213
+ error: false,
214
+ lastUpdateTime: '2023-10-05T20:35:07Z',
215
+ status: 'True',
216
+ transitioning: false,
217
+ type: 'Accepted'
218
+ },
219
+ {
220
+ error: false,
221
+ lastUpdateTime: '2023-10-05T18:05:09Z',
222
+ status: 'True',
223
+ transitioning: false,
224
+ type: 'ImageSynced'
225
+ },
226
+ {
227
+ error: false,
228
+ lastUpdateTime: '2023-10-05T18:06:22Z',
229
+ status: 'False',
230
+ transitioning: false,
231
+ type: 'Reconciling'
232
+ },
233
+ {
234
+ error: false,
235
+ lastUpdateTime: '2023-10-05T18:05:09Z',
236
+ status: 'False',
237
+ transitioning: false,
238
+ type: 'Stalled'
239
+ },
240
+ {
241
+ error: false,
242
+ lastUpdateTime: '2023-10-05T20:35:07Z',
243
+ status: 'True',
244
+ transitioning: false,
245
+ type: 'Synced'
246
+ }
247
+ ],
248
+ desiredReadyClusters: 1,
249
+ display: { readyBundleDeployments: '2/2' },
250
+ gitJobStatus: 'Current',
251
+ lastSyncedImageScanTime: null,
252
+ observedGeneration: 2,
253
+ readyClusters: 1,
254
+ resourceCounts: {
255
+ desiredReady: 2,
256
+ missing: 0,
257
+ modified: 0,
258
+ notReady: 0,
259
+ orphaned: 0,
260
+ ready: 2,
261
+ unknown: 0,
262
+ waitApplied: 0
263
+ },
264
+ resources: [
265
+ {
266
+ apiVersion: 'apps/v1',
267
+ id: 'custom-namespace-name/nginx-cluster0',
268
+ kind: 'Deployment',
269
+ name: 'nginx-cluster0',
270
+ namespace: 'custom-namespace-name',
271
+ state: 'Ready',
272
+ type: 'apps.deployment'
273
+ },
274
+ {
275
+ apiVersion: 'v1',
276
+ id: 'custom-namespace-name/configmap-test',
277
+ kind: 'ConfigMap',
278
+ name: 'configmap-test',
279
+ namespace: 'custom-namespace-name',
280
+ state: 'Ready',
281
+ type: 'configmap'
282
+ }
283
+ ],
284
+ summary: {
285
+ desiredReady: 1,
286
+ ready: 1
287
+ }
288
+ }
289
+ };
290
+
291
+ const mockStore = { getters: { 'i18n/withFallback': (key, opt, fallback) => fallback } };
292
+
293
+ describe('component: FleetSummary', () => {
294
+ it.each([
295
+ [[...mockedBundlesInRepo, ...mockedBundlesOutOfRepo], '2'],
296
+ [mockedBundlesInRepo, '2'],
297
+ ])('displays the number of bundles associated with the current gitrepo', (bundles: any[], bundleCount: string) => {
298
+ const wrapper = mount(FleetSummary, { propsData: { bundles, value: mockRepo }, mocks: { $store: mockStore } });
299
+
300
+ const bundleCountEl = wrapper.find('[data-testid="gitrepo-bundle-summary"] .count');
301
+
302
+ expect(bundleCountEl.text()).toBe(bundleCount);
303
+ });
304
+
305
+ it.each([
306
+ [[...mockedBundlesInRepo, ...mockedBundlesOutOfRepo], '2'],
307
+ [mockedBundlesInRepo, '2'],
308
+
309
+ ])('displays the number of deployments associated with the current gitrepo', (bundles: any[], bundleCount: string) => {
310
+ const wrapper = mount(FleetSummary, { propsData: { bundles, value: mockRepo }, mocks: { $store: mockStore } });
311
+
312
+ const bundleCountEl = wrapper.find('[data-testid="gitrepo-deployment-summary"] .count');
313
+
314
+ expect(bundleCountEl.text()).toBe(bundleCount);
315
+ });
316
+ });