@rancher/shell 3.0.9-rc.5 → 3.0.9
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.
- package/assets/images/providers/oci-open-containers.svg +22 -0
- package/assets/images/providers/traefik.png +0 -0
- package/assets/styles/themes/_dark.scss +2 -0
- package/assets/styles/themes/_light.scss +2 -0
- package/assets/styles/themes/_modern.scss +6 -0
- package/assets/translations/en-us.yaml +129 -25
- package/components/CruResource.vue +3 -1
- package/components/ExplorerProjectsNamespaces.vue +12 -12
- package/components/IconOrSvg.vue +61 -42
- package/components/Resource/Detail/Card/StatusCard/__tests__/StatusCard.test.ts +109 -0
- package/components/Resource/Detail/Card/StatusCard/index.vue +21 -4
- package/components/Resource/Detail/Metadata/IdentifyingInformation/__tests__/identifying-fields.test.ts +19 -2
- package/components/Resource/Detail/Metadata/IdentifyingInformation/identifying-fields.ts +19 -11
- package/components/Resource/Detail/ResourcePopover/__tests__/index.test.ts +12 -0
- package/components/Resource/Detail/ResourcePopover/index.vue +2 -0
- package/components/Resource/Detail/ResourceRow.vue +2 -2
- package/components/ResourceList/index.vue +7 -4
- package/components/SortableTable/index.vue +2 -2
- package/components/Window/ContainerLogs.vue +48 -37
- package/components/fleet/FleetClusterTargets/TargetsList.vue +2 -2
- package/components/fleet/FleetClusterTargets/index.vue +6 -1
- package/components/fleet/GitRepoAdvancedTab.vue +333 -0
- package/components/fleet/GitRepoMetadataTab.vue +43 -0
- package/components/fleet/GitRepoRepositoryTab.vue +101 -0
- package/components/fleet/GitRepoTargetTab.vue +77 -0
- package/components/fleet/HelmOpAdvancedTab.vue +247 -0
- package/components/fleet/HelmOpChartTab.vue +158 -0
- package/components/fleet/HelmOpMetadataTab.vue +46 -0
- package/components/fleet/HelmOpTargetTab.vue +84 -0
- package/components/fleet/HelmOpValuesTab.vue +147 -0
- package/components/fleet/__tests__/FleetClusterTargets.test.ts +119 -70
- package/components/form/BannerSettings.vue +2 -2
- package/components/form/NodeScheduling.vue +81 -7
- package/components/form/NotificationSettings.vue +2 -2
- package/components/form/PodAffinity.vue +1 -36
- package/components/form/ResourceLabeledSelect.vue +8 -4
- package/components/form/ResourceQuota/Namespace.vue +30 -9
- package/components/form/ResourceQuota/NamespaceRow.vue +25 -7
- package/components/form/ResourceQuota/Project.vue +140 -82
- package/components/form/ResourceQuota/ResourceQuotaEntry.vue +145 -0
- package/components/form/ResourceQuota/__tests__/Namespace.test.ts +307 -0
- package/components/form/ResourceQuota/__tests__/NamespaceRow.test.ts +281 -0
- package/components/form/ResourceQuota/__tests__/Project.test.ts +274 -27
- package/components/form/ResourceQuota/__tests__/ResourceQuotaEntry.test.ts +215 -0
- package/components/form/SchedulingCustomization.vue +14 -6
- package/components/form/SelectOrCreateAuthSecret.vue +107 -18
- package/components/form/__tests__/NodeScheduling.test.ts +12 -9
- package/components/form/__tests__/PodAffinity.test.ts +21 -2
- package/components/form/__tests__/SchedulingCustomization.test.ts +240 -0
- package/components/formatter/ClusterLink.vue +8 -0
- package/components/formatter/SecretOrigin.vue +79 -0
- package/config/labels-annotations.js +7 -6
- package/config/pagination-table-headers.js +6 -4
- package/config/product/explorer.js +1 -11
- package/config/product/manager.js +0 -1
- package/config/query-params.js +3 -0
- package/config/settings.ts +15 -2
- package/config/table-headers.js +21 -17
- package/config/types.js +23 -8
- package/detail/fleet.cattle.io.cluster.vue +1 -1
- package/detail/workload/index.vue +11 -16
- package/dialog/DeactivateDriverDialog.vue +1 -1
- package/dialog/FeatureFlagListDialog.vue +1 -1
- package/dialog/Ipv6NetworkingDialog.vue +156 -0
- package/dialog/ScalePoolDownDialog.vue +2 -2
- package/edit/__tests__/fleet.cattle.io.gitrepo.test.ts +1 -1
- package/edit/__tests__/fleet.cattle.io.helmop.test.ts +1 -0
- package/edit/__tests__/management.cattle.io.project.test.js +56 -128
- package/edit/auth/oidc.vue +1 -1
- package/edit/catalog.cattle.io.clusterrepo.vue +155 -25
- package/edit/fleet.cattle.io.gitrepo.vue +153 -283
- package/edit/fleet.cattle.io.helmop.vue +190 -332
- package/edit/management.cattle.io.project.vue +5 -42
- package/edit/management.cattle.io.setting.vue +6 -0
- package/edit/monitoring.coreos.com.alertmanagerconfig/__tests__/auth.spec.ts +145 -0
- package/edit/monitoring.coreos.com.alertmanagerconfig/__tests__/index.test.ts +202 -0
- package/edit/monitoring.coreos.com.alertmanagerconfig/__tests__/tls.spec.ts +226 -0
- package/edit/monitoring.coreos.com.alertmanagerconfig/auth.vue +24 -21
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/__tests__/opsgenie.spec.ts +157 -0
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/__tests__/pagerduty.spec.ts +132 -0
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/__tests__/slack.spec.ts +108 -0
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/pagerduty.vue +2 -1
- package/edit/monitoring.coreos.com.receiver/__tests__/auth.spec.ts +165 -0
- package/edit/monitoring.coreos.com.receiver/__tests__/index.test.ts +153 -0
- package/edit/monitoring.coreos.com.receiver/__tests__/tls.spec.ts +115 -0
- package/edit/monitoring.coreos.com.receiver/types/__tests__/email.spec.ts +86 -0
- package/edit/monitoring.coreos.com.receiver/types/__tests__/opsgenie.spec.ts +209 -0
- package/edit/monitoring.coreos.com.receiver/types/__tests__/pagerduty.spec.ts +105 -0
- package/edit/monitoring.coreos.com.receiver/types/__tests__/slack.spec.ts +92 -0
- package/edit/monitoring.coreos.com.receiver/types/__tests__/webhook.spec.ts +131 -0
- package/edit/provisioning.cattle.io.cluster/__tests__/Basics.test.ts +55 -24
- package/edit/provisioning.cattle.io.cluster/__tests__/Networking.test.ts +1 -103
- package/edit/provisioning.cattle.io.cluster/__tests__/index.test.ts +13 -1
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2-fleet-cluster-agent.test.ts +283 -0
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +65 -49
- package/edit/provisioning.cattle.io.cluster/ingress/IngressCards.vue +114 -0
- package/edit/provisioning.cattle.io.cluster/ingress/IngressConfiguration.vue +158 -0
- package/edit/provisioning.cattle.io.cluster/rke2.vue +167 -69
- package/edit/provisioning.cattle.io.cluster/shared.ts +36 -1
- package/edit/provisioning.cattle.io.cluster/tabs/AgentConfiguration.vue +2 -1
- package/edit/provisioning.cattle.io.cluster/tabs/Basics.vue +70 -7
- package/edit/provisioning.cattle.io.cluster/tabs/Ingress.vue +343 -0
- package/edit/provisioning.cattle.io.cluster/tabs/MachinePool.vue +2 -1
- package/edit/provisioning.cattle.io.cluster/tabs/etcd/__tests__/S3Config.test.ts +13 -1
- package/edit/provisioning.cattle.io.cluster/tabs/networking/index.vue +10 -44
- package/edit/secret/index.vue +1 -1
- package/edit/token.vue +68 -29
- package/edit/workload/__tests__/index.test.ts +2 -37
- package/edit/workload/index.vue +6 -2
- package/edit/workload/mixins/workload.js +0 -32
- package/list/__tests__/management.cattle.io.setting.test.ts +198 -0
- package/list/management.cattle.io.setting.vue +13 -0
- package/list/provisioning.cattle.io.cluster.vue +50 -1
- package/list/secret.vue +4 -9
- package/list/service.vue +6 -8
- package/machine-config/amazonec2.vue +11 -4
- package/machine-config/components/EC2Networking.vue +46 -30
- package/machine-config/components/__tests__/EC2Networking.test.ts +7 -7
- package/machine-config/components/__tests__/utils/vpcSubnetMockData.js +0 -9
- package/machine-config/digitalocean.vue +3 -3
- package/models/__tests__/chart.test.ts +2 -2
- package/models/__tests__/namespace.test.ts +11 -0
- package/models/__tests__/provisioning.cattle.io.cluster.test.ts +96 -0
- package/models/__tests__/workload.test.ts +42 -1
- package/models/catalog.cattle.io.clusterrepo.js +30 -4
- package/models/chart.js +3 -3
- package/models/ext.cattle.io.token.js +48 -0
- package/models/kontainerdriver.js +2 -2
- package/models/namespace.js +7 -1
- package/models/nodedriver.js +2 -2
- package/models/provisioning.cattle.io.cluster.js +28 -7
- package/models/secret.js +0 -17
- package/models/service.js +44 -1
- package/models/token.js +4 -0
- package/models/workload.js +12 -6
- package/package.json +1 -1
- package/pages/account/index.vue +96 -67
- package/pages/auth/setup.vue +5 -14
- package/pages/c/_cluster/apps/charts/AppChartCardFooter.vue +45 -18
- package/pages/c/_cluster/apps/charts/__tests__/install.test.ts +4 -1
- package/pages/c/_cluster/apps/charts/index.vue +82 -3
- package/pages/c/_cluster/apps/charts/install.vue +317 -42
- package/pages/c/_cluster/explorer/tools/index.vue +1 -1
- package/pages/c/_cluster/manager/cloudCredential/index.vue +1 -1
- package/pages/c/_cluster/manager/drivers/kontainerDriver/index.vue +5 -4
- package/pages/c/_cluster/settings/index.vue +3 -1
- package/pages/c/_cluster/uiplugins/index.vue +1 -1
- package/plugins/dashboard-store/__tests__/getters.test.ts +108 -0
- package/plugins/dashboard-store/__tests__/resource-class.test.ts +27 -0
- package/plugins/dashboard-store/actions.js +3 -8
- package/plugins/dashboard-store/getters.js +7 -5
- package/plugins/dashboard-store/mutations.js +4 -1
- package/plugins/dashboard-store/resource-class.js +3 -3
- package/plugins/steve/__tests__/steve-class.test.ts +102 -141
- package/plugins/steve/steve-class.js +12 -3
- package/plugins/steve/steve-pagination-utils.ts +6 -2
- package/rancher-components/RcIcon/types.ts +2 -0
- package/rancher-components/RcItemCard/RcItemCard.vue +72 -20
- package/store/prefs.js +3 -0
- package/types/aws-sdk.d.ts +121 -0
- package/types/resources/node.ts +15 -0
- package/types/shell/index.d.ts +537 -506
- package/types/store/pagination.types.ts +5 -5
- package/utils/__tests__/array.test.ts +1 -29
- package/utils/__tests__/cluster-agent-configuration.test.ts +203 -0
- package/utils/array.ts +0 -11
- package/utils/aws.ts +21 -0
- package/utils/cluster.js +22 -2
- package/utils/selector-typed.ts +1 -1
- package/utils/svg-filter.js +4 -3
- package/components/__tests__/ProjectRow.test.ts +0 -206
- package/components/form/ResourceQuota/ProjectRow.vue +0 -277
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import { _EDIT } from '@shell/config/query-params';
|
|
3
|
+
import Index from '../index.vue';
|
|
4
|
+
|
|
5
|
+
describe('shell/edit/monitoring.coreos.com.receiver/index.vue', () => {
|
|
6
|
+
const mockStore = (resourceFields = {}) => ({
|
|
7
|
+
getters: {
|
|
8
|
+
'cluster/schemaFor': jest.fn(() => ({ resourceFields })),
|
|
9
|
+
clusterId: 'c-cluster-123',
|
|
10
|
+
'i18n/t': (key) => key,
|
|
11
|
+
},
|
|
12
|
+
dispatch: jest.fn(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const baseValue = () => ({
|
|
16
|
+
spec: {
|
|
17
|
+
name: 'test-receiver',
|
|
18
|
+
email_configs: [],
|
|
19
|
+
slack_configs: [],
|
|
20
|
+
webhook_configs: [],
|
|
21
|
+
pagerduty_configs: [],
|
|
22
|
+
opsgenie_configs: [],
|
|
23
|
+
victorops_configs: [],
|
|
24
|
+
pushover_configs: [],
|
|
25
|
+
wechat_configs: [],
|
|
26
|
+
},
|
|
27
|
+
applyDefaults: jest.fn(),
|
|
28
|
+
save: jest.fn(),
|
|
29
|
+
done: jest.fn(),
|
|
30
|
+
registerBeforeHook: jest.fn(),
|
|
31
|
+
doneRoute: {},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
jest.clearAllMocks();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should mount and initialize data correctly in create mode', () => {
|
|
39
|
+
const value = baseValue();
|
|
40
|
+
const wrapper = shallowMount(Index, {
|
|
41
|
+
props: {
|
|
42
|
+
value,
|
|
43
|
+
mode: 'create'
|
|
44
|
+
},
|
|
45
|
+
global: {
|
|
46
|
+
mocks: {
|
|
47
|
+
$store: mockStore(value.spec),
|
|
48
|
+
$fetchState: { pending: false },
|
|
49
|
+
$route: { name: 'test-route' },
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(wrapper.vm.suffixYaml).toBe('');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should correctly process email configs with smarthost on edit mode', () => {
|
|
58
|
+
const valueWithSmarthost = baseValue();
|
|
59
|
+
|
|
60
|
+
valueWithSmarthost.spec.email_configs = [{ smarthost: 'smtp.example.com:587' }];
|
|
61
|
+
const wrapper = shallowMount(Index, {
|
|
62
|
+
props: {
|
|
63
|
+
value: valueWithSmarthost,
|
|
64
|
+
mode: _EDIT
|
|
65
|
+
},
|
|
66
|
+
global: {
|
|
67
|
+
mocks: {
|
|
68
|
+
$store: mockStore(),
|
|
69
|
+
$fetchState: { pending: false },
|
|
70
|
+
$route: { name: 'test-route' },
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(wrapper.vm.value.spec.email_configs[0].host).toBe('smtp.example.com');
|
|
76
|
+
expect(wrapper.vm.value.spec.email_configs[0].port).toBe('587');
|
|
77
|
+
expect(wrapper.vm.value.spec.email_configs[0].smarthost).toBeUndefined();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should call saveOverride which calls save method on success', async() => {
|
|
81
|
+
const wrapper = shallowMount(Index, {
|
|
82
|
+
props: {
|
|
83
|
+
value: baseValue(),
|
|
84
|
+
mode: _EDIT,
|
|
85
|
+
},
|
|
86
|
+
global: {
|
|
87
|
+
mocks: {
|
|
88
|
+
$store: mockStore(),
|
|
89
|
+
$fetchState: { pending: false },
|
|
90
|
+
$route: { name: 'test-route' },
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const spy = jest.spyOn(wrapper.vm, 'save');
|
|
96
|
+
const buttonDone = jest.fn();
|
|
97
|
+
|
|
98
|
+
wrapper.vm.saveOverride(buttonDone);
|
|
99
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should call saveOverride which populates errors on yaml error', async() => {
|
|
103
|
+
const wrapper = shallowMount(Index, {
|
|
104
|
+
props: {
|
|
105
|
+
value: baseValue(),
|
|
106
|
+
mode: _EDIT,
|
|
107
|
+
},
|
|
108
|
+
global: {
|
|
109
|
+
mocks: {
|
|
110
|
+
$store: mockStore(),
|
|
111
|
+
$fetchState: { pending: false },
|
|
112
|
+
$route: { name: 'test-route' },
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const spy = jest.spyOn(wrapper.vm, 'save');
|
|
118
|
+
|
|
119
|
+
wrapper.vm.yamlError = 'Invalid YAML';
|
|
120
|
+
const buttonDone = jest.fn();
|
|
121
|
+
|
|
122
|
+
wrapper.vm.saveOverride(buttonDone);
|
|
123
|
+
|
|
124
|
+
expect(wrapper.vm.errors).toContain('Invalid YAML');
|
|
125
|
+
expect(spy).not.toHaveBeenCalled();
|
|
126
|
+
expect(buttonDone).toHaveBeenCalledWith(false);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('should call createSmarthost and update email configs', () => {
|
|
130
|
+
const value = baseValue();
|
|
131
|
+
|
|
132
|
+
value.spec.email_configs = [{ host: 'smtp.example.com', port: '587' }];
|
|
133
|
+
|
|
134
|
+
const wrapper = shallowMount(Index, {
|
|
135
|
+
props: {
|
|
136
|
+
value,
|
|
137
|
+
mode: _EDIT
|
|
138
|
+
},
|
|
139
|
+
global: {
|
|
140
|
+
mocks: {
|
|
141
|
+
$store: mockStore(),
|
|
142
|
+
$fetchState: { pending: false },
|
|
143
|
+
$route: { name: 'test-route' },
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
wrapper.vm.createSmarthost();
|
|
149
|
+
expect(value.spec.email_configs[0].smarthost).toBe('smtp.example.com:587');
|
|
150
|
+
expect(value.spec.email_configs[0].host).toBeUndefined();
|
|
151
|
+
expect(value.spec.email_configs[0].port).toBeUndefined();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import Tls from '@shell/edit/monitoring.coreos.com.receiver/tls.vue';
|
|
3
|
+
import { LabeledInput } from '@components/Form/LabeledInput';
|
|
4
|
+
import { Banner } from '@components/Banner';
|
|
5
|
+
|
|
6
|
+
describe('shell/edit/monitoring.coreos.com.receiver/tls.vue', () => {
|
|
7
|
+
const mockValue = {
|
|
8
|
+
tls_config: {
|
|
9
|
+
ca_file: 'ca.pem', cert_file: 'cert.pem', key_file: 'key.pem'
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const mockMode = 'edit';
|
|
13
|
+
|
|
14
|
+
it('should mount correctly', () => {
|
|
15
|
+
const wrapper = shallowMount(Tls, {
|
|
16
|
+
props: {
|
|
17
|
+
value: mockValue,
|
|
18
|
+
mode: mockMode,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(wrapper.exists()).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should initialize tls_config if it does not exist', () => {
|
|
26
|
+
const wrapper = shallowMount(Tls, {
|
|
27
|
+
props: {
|
|
28
|
+
value: {},
|
|
29
|
+
mode: mockMode,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
expect(wrapper.props().value.tls_config).toBeDefined();
|
|
34
|
+
expect(wrapper.props().value.tls_config).toStrictEqual({});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should render all LabeledInput components with correct labels and modes', () => {
|
|
38
|
+
const wrapper = shallowMount(Tls, {
|
|
39
|
+
props: {
|
|
40
|
+
value: mockValue,
|
|
41
|
+
mode: mockMode,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const inputs = wrapper.findAllComponents(LabeledInput);
|
|
46
|
+
|
|
47
|
+
expect(inputs).toHaveLength(3);
|
|
48
|
+
|
|
49
|
+
const labels = [
|
|
50
|
+
'%monitoring.receiver.tls.caFilePath.label%',
|
|
51
|
+
'%monitoring.receiver.tls.certFilePath.label%',
|
|
52
|
+
'%monitoring.receiver.tls.keyFilePath.label%',
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
inputs.forEach((input, i) => {
|
|
56
|
+
expect(input.props('label')).toBe(labels[i]);
|
|
57
|
+
expect(input.props('mode')).toBe(mockMode);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should bind LabeledInput values correctly', () => {
|
|
62
|
+
const wrapper = shallowMount(Tls, {
|
|
63
|
+
props: {
|
|
64
|
+
value: mockValue,
|
|
65
|
+
mode: mockMode,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const inputs = wrapper.findAllComponents(LabeledInput);
|
|
70
|
+
|
|
71
|
+
expect(inputs[0].props('value')).toBe(mockValue.tls_config.ca_file);
|
|
72
|
+
expect(inputs[1].props('value')).toBe(mockValue.tls_config.cert_file);
|
|
73
|
+
expect(inputs[2].props('value')).toBe(mockValue.tls_config.key_file);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should update the value when LabeledInput emits an update', async() => {
|
|
77
|
+
const wrapper = shallowMount(Tls, {
|
|
78
|
+
props: {
|
|
79
|
+
value: {
|
|
80
|
+
tls_config: {
|
|
81
|
+
ca_file: '', cert_file: '', key_file: ''
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
mode: mockMode,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const inputs = wrapper.findAllComponents(LabeledInput);
|
|
89
|
+
const newCaFile = 'new-ca.pem';
|
|
90
|
+
const newCertFile = 'new-cert.pem';
|
|
91
|
+
const newKeyFile = 'new-key.pem';
|
|
92
|
+
|
|
93
|
+
await inputs[0].vm.$emit('update:value', newCaFile);
|
|
94
|
+
await inputs[1].vm.$emit('update:value', newCertFile);
|
|
95
|
+
await inputs[2].vm.$emit('update:value', newKeyFile);
|
|
96
|
+
|
|
97
|
+
expect(wrapper.props().value.tls_config.ca_file).toBe(newCaFile);
|
|
98
|
+
expect(wrapper.props().value.tls_config.cert_file).toBe(newCertFile);
|
|
99
|
+
expect(wrapper.props().value.tls_config.key_file).toBe(newKeyFile);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should display the informational banner', () => {
|
|
103
|
+
const wrapper = shallowMount(Tls, {
|
|
104
|
+
props: {
|
|
105
|
+
value: mockValue,
|
|
106
|
+
mode: mockMode,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const banner = wrapper.findComponent(Banner);
|
|
111
|
+
|
|
112
|
+
expect(banner.exists()).toBe(true);
|
|
113
|
+
expect(banner.props('color')).toBe('info');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
2
|
+
import { shallowMount } from '@vue/test-utils';
|
|
3
|
+
import Email from '@shell/edit/monitoring.coreos.com.receiver/types/email.vue';
|
|
4
|
+
import TLS from '@shell/edit/monitoring.coreos.com.receiver/tls.vue';
|
|
5
|
+
import { LabeledInput } from '@components/Form/LabeledInput';
|
|
6
|
+
import { Checkbox } from '@components/Form/Checkbox';
|
|
7
|
+
import { _EDIT } from '@shell/config/query-params';
|
|
8
|
+
|
|
9
|
+
describe('component: Email', () => {
|
|
10
|
+
const mockStore = {
|
|
11
|
+
getters: {
|
|
12
|
+
'i18n/t': (key: string) => key,
|
|
13
|
+
'i18n/exists': () => true,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const requiredProps = {
|
|
18
|
+
mode: _EDIT,
|
|
19
|
+
value: {},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it('should render all child components', () => {
|
|
23
|
+
const wrapper = shallowMount(Email, {
|
|
24
|
+
props: requiredProps,
|
|
25
|
+
global: { mocks: mockStore },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const labeledInputs = wrapper.findAllComponents(LabeledInput);
|
|
29
|
+
const checkboxes = wrapper.findAllComponents(Checkbox);
|
|
30
|
+
const tls = wrapper.findComponent(TLS);
|
|
31
|
+
|
|
32
|
+
expect(labeledInputs).toHaveLength(6);
|
|
33
|
+
expect(checkboxes).toHaveLength(2);
|
|
34
|
+
expect(tls.exists()).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should pass down the mode prop to child components', () => {
|
|
38
|
+
const wrapper = shallowMount(Email, {
|
|
39
|
+
props: requiredProps,
|
|
40
|
+
global: { mocks: mockStore },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const labeledInputs = wrapper.findAllComponents(LabeledInput);
|
|
44
|
+
const checkboxes = wrapper.findAllComponents(Checkbox);
|
|
45
|
+
const tls = wrapper.findComponent(TLS);
|
|
46
|
+
|
|
47
|
+
labeledInputs.forEach((input) => {
|
|
48
|
+
expect(input.props().mode).toBe(_EDIT);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
checkboxes.forEach((checkbox) => {
|
|
52
|
+
expect(checkbox.props().mode).toBe(_EDIT);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(tls.props().mode).toBe(_EDIT);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should initialize send_resolved and require_tls to false if not present', () => {
|
|
59
|
+
const value = {};
|
|
60
|
+
const wrapper = shallowMount(Email, {
|
|
61
|
+
props: {
|
|
62
|
+
...requiredProps,
|
|
63
|
+
value,
|
|
64
|
+
},
|
|
65
|
+
global: { mocks: mockStore },
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
expect(wrapper.props().value.send_resolved).toBe(false);
|
|
69
|
+
expect(wrapper.props().value.require_tls).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should emit an input event when TLS component emits an update:value event', async() => {
|
|
73
|
+
const wrapper = shallowMount(Email, {
|
|
74
|
+
props: requiredProps,
|
|
75
|
+
global: { mocks: mockStore },
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const tls = wrapper.findComponent(TLS);
|
|
79
|
+
const updatedValue = { smarthost: 'new-value' };
|
|
80
|
+
|
|
81
|
+
await tls.vm.$emit('update:value', updatedValue);
|
|
82
|
+
|
|
83
|
+
expect(wrapper.emitted('input')).toHaveLength(1);
|
|
84
|
+
expect(wrapper.emitted('input')?.[0][0]).toStrictEqual(updatedValue);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
|
|
2
|
+
import { shallowMount } from '@vue/test-utils';
|
|
3
|
+
import Opsgenie, { TARGETS, TYPES } from '@shell/edit/monitoring.coreos.com.receiver/types/opsgenie.vue';
|
|
4
|
+
import { LabeledInput } from '@components/Form/LabeledInput';
|
|
5
|
+
import { Checkbox } from '@components/Form/Checkbox';
|
|
6
|
+
import ArrayList from '@shell/components/form/ArrayList.vue';
|
|
7
|
+
import { _EDIT, _VIEW } from '@shell/config/query-params';
|
|
8
|
+
|
|
9
|
+
describe('component: Opsgenie', () => {
|
|
10
|
+
const mockStore = {
|
|
11
|
+
getters: {
|
|
12
|
+
'i18n/t': (key: string) => key,
|
|
13
|
+
'i18n/exists': () => true,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const requiredProps = {
|
|
18
|
+
mode: _EDIT,
|
|
19
|
+
value: { responders: [] },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it('should render all child components', () => {
|
|
23
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
24
|
+
props: requiredProps,
|
|
25
|
+
global: { mocks: mockStore },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const labeledInputs = wrapper.findAllComponents(LabeledInput);
|
|
29
|
+
const checkbox = wrapper.findComponent(Checkbox);
|
|
30
|
+
const arrayList = wrapper.findComponent(ArrayList);
|
|
31
|
+
|
|
32
|
+
expect(labeledInputs).toHaveLength(2);
|
|
33
|
+
expect(checkbox.exists()).toBe(true);
|
|
34
|
+
expect(arrayList.exists()).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should pass down the mode prop to child components', () => {
|
|
38
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
39
|
+
props: requiredProps,
|
|
40
|
+
global: { mocks: mockStore },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const labeledInputs = wrapper.findAllComponents(LabeledInput);
|
|
44
|
+
const checkbox = wrapper.findComponent(Checkbox);
|
|
45
|
+
const arrayList = wrapper.findComponent(ArrayList);
|
|
46
|
+
|
|
47
|
+
labeledInputs.forEach((input) => {
|
|
48
|
+
expect(input.props().mode).toBe(_EDIT);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(checkbox.props().mode).toBe(_EDIT);
|
|
52
|
+
expect(arrayList.props().mode).toBe(_EDIT);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('data initialization', () => {
|
|
56
|
+
it('should initialize http_config, send_resolved, and responders', () => {
|
|
57
|
+
const value = {};
|
|
58
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
59
|
+
props: {
|
|
60
|
+
...requiredProps,
|
|
61
|
+
value,
|
|
62
|
+
},
|
|
63
|
+
global: { mocks: mockStore },
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
expect(wrapper.props().value.http_config).toBeDefined();
|
|
67
|
+
expect(wrapper.props().value.send_resolved).toBe(true);
|
|
68
|
+
expect(wrapper.props().value.responders).toBeDefined();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should correctly transform responders from props', () => {
|
|
72
|
+
const value = {
|
|
73
|
+
responders: [
|
|
74
|
+
{ type: 'team', id: 'team-id' },
|
|
75
|
+
{ type: 'user', name: 'user-name' },
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
79
|
+
props: {
|
|
80
|
+
...requiredProps,
|
|
81
|
+
value,
|
|
82
|
+
},
|
|
83
|
+
global: { mocks: mockStore },
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expect(wrapper.vm.responders).toStrictEqual([
|
|
87
|
+
{
|
|
88
|
+
type: 'team', target: 'id', value: 'team-id'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'user', target: 'name', value: 'user-name'
|
|
92
|
+
},
|
|
93
|
+
]);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('watchers', () => {
|
|
98
|
+
it('should update value.responders when responders data changes', async() => {
|
|
99
|
+
const value = { responders: [] };
|
|
100
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
101
|
+
props: {
|
|
102
|
+
...requiredProps,
|
|
103
|
+
value,
|
|
104
|
+
},
|
|
105
|
+
global: { mocks: mockStore },
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
wrapper.vm.responders = [
|
|
109
|
+
{
|
|
110
|
+
type: 'team', target: 'id', value: 'team-id'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: 'user', target: 'name', value: 'user-name'
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
await wrapper.vm.$nextTick();
|
|
118
|
+
|
|
119
|
+
expect(value.responders).toStrictEqual([
|
|
120
|
+
{ type: 'team', id: 'team-id' },
|
|
121
|
+
{ type: 'user', name: 'user-name' },
|
|
122
|
+
]);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('methods', () => {
|
|
127
|
+
it('should update a responder with updateResponder', () => {
|
|
128
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
129
|
+
props: requiredProps,
|
|
130
|
+
global: { mocks: mockStore },
|
|
131
|
+
});
|
|
132
|
+
const responder = {
|
|
133
|
+
type: 'team',
|
|
134
|
+
target: 'id',
|
|
135
|
+
value: 'old-value',
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
wrapper.vm.updateResponder({ selected: 'name', text: 'new-value' }, responder);
|
|
139
|
+
|
|
140
|
+
expect(responder.target).toBe('name');
|
|
141
|
+
expect(responder.value).toBe('new-value');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should return the correct label with typeLabel', () => {
|
|
145
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
146
|
+
props: requiredProps,
|
|
147
|
+
global: { mocks: mockStore },
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
TYPES.forEach((type) => {
|
|
151
|
+
expect(wrapper.vm.typeLabel(type.value)).toBe(type.label);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should return the correct label with targetLabel', () => {
|
|
156
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
157
|
+
props: requiredProps,
|
|
158
|
+
global: { mocks: mockStore },
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
TARGETS.forEach((target) => {
|
|
162
|
+
expect(wrapper.vm.targetLabel(target.value)).toBe(target.label);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe('template', () => {
|
|
168
|
+
describe('responders', () => {
|
|
169
|
+
it('should render responders correctly in edit mode', async() => {
|
|
170
|
+
const value = { responders: [{ type: 'team', id: 'team-id' }] };
|
|
171
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
172
|
+
props: {
|
|
173
|
+
...requiredProps,
|
|
174
|
+
value,
|
|
175
|
+
},
|
|
176
|
+
global: { mocks: mockStore },
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const arrayList = wrapper.findComponent(ArrayList);
|
|
180
|
+
|
|
181
|
+
expect(arrayList.props().value).toStrictEqual([{
|
|
182
|
+
type: 'team',
|
|
183
|
+
target: 'id',
|
|
184
|
+
value: 'team-id'
|
|
185
|
+
}]);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('should render responders correctly in view mode', async() => {
|
|
189
|
+
const value = { responders: [{ type: 'team', id: 'team-id' }] };
|
|
190
|
+
const wrapper = shallowMount(Opsgenie, {
|
|
191
|
+
props: {
|
|
192
|
+
...requiredProps,
|
|
193
|
+
value,
|
|
194
|
+
mode: _VIEW,
|
|
195
|
+
},
|
|
196
|
+
global: { mocks: mockStore },
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const arrayList = wrapper.findComponent(ArrayList);
|
|
200
|
+
|
|
201
|
+
expect(arrayList.props().value).toStrictEqual([{
|
|
202
|
+
type: 'team',
|
|
203
|
+
target: 'id',
|
|
204
|
+
value: 'team-id'
|
|
205
|
+
}]);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
|
|
2
|
+
import { shallowMount } from '@vue/test-utils';
|
|
3
|
+
import Pagerduty from '@shell/edit/monitoring.coreos.com.receiver/types/pagerduty.vue';
|
|
4
|
+
import { LabeledInput } from '@components/Form/LabeledInput';
|
|
5
|
+
import { Checkbox } from '@components/Form/Checkbox';
|
|
6
|
+
import LabeledSelect from '@shell/components/form/LabeledSelect.vue';
|
|
7
|
+
import { _EDIT } from '@shell/config/query-params';
|
|
8
|
+
|
|
9
|
+
describe('component: Pagerduty', () => {
|
|
10
|
+
const mockStore = {
|
|
11
|
+
getters: {
|
|
12
|
+
'i18n/t': (key: string) => key,
|
|
13
|
+
'i18n/exists': () => true,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const requiredProps = {
|
|
18
|
+
mode: _EDIT,
|
|
19
|
+
value: {},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it('should render all child components', () => {
|
|
23
|
+
const wrapper = shallowMount(Pagerduty, {
|
|
24
|
+
props: requiredProps,
|
|
25
|
+
global: { mocks: mockStore },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const labeledInputs = wrapper.findAllComponents(LabeledInput);
|
|
29
|
+
const checkbox = wrapper.findComponent(Checkbox);
|
|
30
|
+
const labeledSelect = wrapper.findComponent(LabeledSelect);
|
|
31
|
+
|
|
32
|
+
expect(labeledInputs).toHaveLength(2);
|
|
33
|
+
expect(checkbox.exists()).toBe(true);
|
|
34
|
+
expect(labeledSelect.exists()).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should pass down the mode prop to child components', () => {
|
|
38
|
+
const wrapper = shallowMount(Pagerduty, {
|
|
39
|
+
props: requiredProps,
|
|
40
|
+
global: { mocks: mockStore },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const labeledInputs = wrapper.findAllComponents(LabeledInput);
|
|
44
|
+
const checkbox = wrapper.findComponent(Checkbox);
|
|
45
|
+
const labeledSelect = wrapper.findComponent(LabeledSelect);
|
|
46
|
+
|
|
47
|
+
labeledInputs.forEach((input) => {
|
|
48
|
+
expect(input.props().mode).toBe(_EDIT);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(checkbox.props().mode).toBe(_EDIT);
|
|
52
|
+
expect(labeledSelect.attributes().mode).toBe(_EDIT);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('data initialization', () => {
|
|
56
|
+
it('should initialize http_config and send_resolved', () => {
|
|
57
|
+
const value = {};
|
|
58
|
+
const wrapper = shallowMount(Pagerduty, {
|
|
59
|
+
props: {
|
|
60
|
+
...requiredProps,
|
|
61
|
+
value,
|
|
62
|
+
},
|
|
63
|
+
global: { mocks: mockStore },
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
expect(wrapper.props().value.http_config).toBeDefined();
|
|
67
|
+
expect(wrapper.props().value.send_resolved).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it.each([
|
|
71
|
+
['Events API v2', { routing_key: 'test-key' }],
|
|
72
|
+
['Prometheus', { service_key: 'test-key' }],
|
|
73
|
+
['Events API v2', {}],
|
|
74
|
+
])('should set integrationType to %p', (expectedType, value) => {
|
|
75
|
+
const wrapper = shallowMount(Pagerduty, {
|
|
76
|
+
props: {
|
|
77
|
+
...requiredProps,
|
|
78
|
+
value,
|
|
79
|
+
},
|
|
80
|
+
global: { mocks: mockStore },
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(wrapper.vm.integrationType).toBe(expectedType);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('watchers', () => {
|
|
88
|
+
it('should clear old integration key when integrationType changes', async() => {
|
|
89
|
+
const value = { routing_key: 'test-key' };
|
|
90
|
+
const wrapper = shallowMount(Pagerduty, {
|
|
91
|
+
props: {
|
|
92
|
+
...requiredProps,
|
|
93
|
+
value,
|
|
94
|
+
},
|
|
95
|
+
global: { mocks: mockStore },
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
wrapper.vm.integrationType = 'Prometheus';
|
|
99
|
+
|
|
100
|
+
await wrapper.vm.$nextTick();
|
|
101
|
+
|
|
102
|
+
expect(value.routing_key).toBeNull();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|