@rancher/shell 0.3.19 → 0.3.21
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/translations/en-us.yaml +4 -1
- package/components/PromptModal.vue +4 -0
- package/components/Questions/Array.vue +2 -2
- package/components/Questions/Boolean.vue +7 -1
- package/components/Questions/CloudCredential.vue +1 -0
- package/components/Questions/Enum.vue +21 -2
- package/components/Questions/Float.vue +8 -3
- package/components/Questions/Int.vue +8 -3
- package/components/Questions/Question.js +72 -0
- package/components/Questions/QuestionMap.vue +2 -1
- package/components/Questions/Radio.vue +33 -0
- package/components/Questions/Reference.vue +2 -0
- package/components/Questions/String.vue +8 -3
- package/components/Questions/Yaml.vue +46 -0
- package/components/Questions/__tests__/Boolean.test.ts +123 -0
- package/components/Questions/__tests__/Float.test.ts +123 -0
- package/components/Questions/__tests__/Int.test.ts +123 -0
- package/components/Questions/__tests__/String.test.ts +123 -0
- package/components/Questions/__tests__/Yaml.test.ts +123 -0
- package/components/Questions/index.vue +8 -1
- package/components/ResourceTable.vue +10 -13
- package/components/SideNav.vue +634 -0
- package/components/__tests__/NamespaceFilter.test.ts +3 -4
- package/components/form/UnitInput.vue +1 -0
- package/components/form/__tests__/KeyValue.test.ts +2 -1
- package/components/form/__tests__/UnitInput.test.ts +2 -2
- package/components/formatter/LinkName.vue +12 -1
- package/components/nav/WorkspaceSwitcher.vue +4 -1
- package/core/plugin-helpers.js +4 -1
- package/core/types.ts +25 -1
- package/detail/node.vue +2 -2
- package/edit/fleet.cattle.io.gitrepo.vue +7 -0
- package/layouts/default.vue +11 -597
- package/middleware/authenticated.js +2 -14
- package/models/fleet.cattle.io.gitrepo.js +3 -1
- package/package.json +1 -1
- package/pages/auth/login.vue +1 -1
- package/pages/c/_cluster/fleet/index.vue +4 -0
- package/pages/c/_cluster/uiplugins/index.vue +3 -3
- package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +8 -0
- package/rancher-components/components/Form/Radio/RadioButton.test.ts +7 -3
- package/store/auth.js +2 -0
- package/types/shell/index.d.ts +2 -0
- package/utils/auth.js +17 -0
- package/utils/object.js +0 -1
- package/utils/validators/__tests__/cidr.test.ts +33 -0
- package/utils/validators/cidr.js +5 -0
|
@@ -3041,6 +3041,7 @@ login:
|
|
|
3041
3041
|
noResponse: "No response received"
|
|
3042
3042
|
error: An error occurred logging in. Please try again.
|
|
3043
3043
|
clientError: Invalid username or password. Please try again.
|
|
3044
|
+
specificError: 'An error occurred logging in: {msg}'
|
|
3044
3045
|
useLocal: Use a local user
|
|
3045
3046
|
loginWithProvider: Log in with {provider}
|
|
3046
3047
|
username: Username
|
|
@@ -3441,7 +3442,7 @@ namespace:
|
|
|
3441
3442
|
workloads: Workloads
|
|
3442
3443
|
label: Namespace
|
|
3443
3444
|
selectNamespace: Select Namespace
|
|
3444
|
-
createNamespace: Create a
|
|
3445
|
+
createNamespace: Create a new Namespace
|
|
3445
3446
|
selectOrCreate: Select or Create a Namespace
|
|
3446
3447
|
resourceStates:
|
|
3447
3448
|
success: 'Active'
|
|
@@ -5633,6 +5634,8 @@ validation:
|
|
|
5633
5634
|
logdna:
|
|
5634
5635
|
apiKey: Required an "Api Key" to be set.
|
|
5635
5636
|
invalidCron: Invalid cron schedule
|
|
5637
|
+
invalidCidr: "Invalid CIDR"
|
|
5638
|
+
invalidIP: "Invalid IP"
|
|
5636
5639
|
k8s:
|
|
5637
5640
|
name: Must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc').
|
|
5638
5641
|
identifier:
|
|
@@ -42,6 +42,9 @@ export default {
|
|
|
42
42
|
const isSticky = !!this.modalData?.modalSticky;
|
|
43
43
|
|
|
44
44
|
return !isSticky ? '' : 'display: flex; flex-direction: column; ';
|
|
45
|
+
},
|
|
46
|
+
closeOnClickOutside() {
|
|
47
|
+
return this.modalData?.closeOnClickOutside;
|
|
45
48
|
}
|
|
46
49
|
},
|
|
47
50
|
|
|
@@ -85,6 +88,7 @@ export default {
|
|
|
85
88
|
:styles="`background-color: var(--nav-bg); border-radius: var(--border-radius); ${stickyProps} max-height: 95vh; ${cssProps}`"
|
|
86
89
|
height="auto"
|
|
87
90
|
:scrollable="true"
|
|
91
|
+
:click-to-close="closeOnClickOutside"
|
|
88
92
|
@closed="close()"
|
|
89
93
|
>
|
|
90
94
|
<component
|
|
@@ -19,11 +19,11 @@ export default {
|
|
|
19
19
|
<div class="col span-6">
|
|
20
20
|
<ArrayList
|
|
21
21
|
:key="question.variable"
|
|
22
|
-
v-model="value
|
|
22
|
+
v-model="value"
|
|
23
23
|
:title="question.label"
|
|
24
24
|
:mode="mode"
|
|
25
|
-
:protip="false"
|
|
26
25
|
:disabled="disabled"
|
|
26
|
+
:protip="displayTooltip"
|
|
27
27
|
@input="update"
|
|
28
28
|
/>
|
|
29
29
|
</div>
|
|
@@ -9,18 +9,24 @@ export default {
|
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<template>
|
|
12
|
-
<div
|
|
12
|
+
<div
|
|
13
|
+
:data-testid="`boolean-row-${question.variable}`"
|
|
14
|
+
class="row"
|
|
15
|
+
>
|
|
13
16
|
<div class="col span-6">
|
|
14
17
|
<Checkbox
|
|
15
18
|
:mode="mode"
|
|
16
19
|
:label="displayLabel"
|
|
17
20
|
:value="value"
|
|
18
21
|
:disabled="disabled"
|
|
22
|
+
:tooltip="displayTooltip"
|
|
23
|
+
:data-testid="`boolean-input-${question.variable}`"
|
|
19
24
|
@input="$emit('input', $event)"
|
|
20
25
|
/>
|
|
21
26
|
</div>
|
|
22
27
|
<div
|
|
23
28
|
v-if="showDescription"
|
|
29
|
+
:data-testid="`boolean-description-${question.variable}`"
|
|
24
30
|
class="col span-6 mt-10"
|
|
25
31
|
>
|
|
26
32
|
{{ displayDescription }}
|
|
@@ -4,7 +4,23 @@ import Question from './Question';
|
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
components: { LabeledSelect },
|
|
7
|
-
mixins: [Question]
|
|
7
|
+
mixins: [Question],
|
|
8
|
+
computed: {
|
|
9
|
+
options() {
|
|
10
|
+
const options = this.question.options;
|
|
11
|
+
|
|
12
|
+
if (Array.isArray(options)) {
|
|
13
|
+
return options;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return Object.entries(options).map(([key, value]) => {
|
|
17
|
+
return {
|
|
18
|
+
value: key,
|
|
19
|
+
label: value,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
8
24
|
};
|
|
9
25
|
</script>
|
|
10
26
|
|
|
@@ -14,11 +30,14 @@ export default {
|
|
|
14
30
|
<LabeledSelect
|
|
15
31
|
:mode="mode"
|
|
16
32
|
:label="displayLabel"
|
|
17
|
-
:options="
|
|
33
|
+
:options="options"
|
|
18
34
|
:placeholder="question.description"
|
|
19
35
|
:required="question.required"
|
|
36
|
+
:multiple="question.multiple"
|
|
20
37
|
:value="value"
|
|
21
38
|
:disabled="disabled"
|
|
39
|
+
:tooltip="displayTooltip"
|
|
40
|
+
:searchable="question.searchable"
|
|
22
41
|
@input="$emit('input', $event)"
|
|
23
42
|
/>
|
|
24
43
|
</div>
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import { LabeledInput } from '@components/Form/LabeledInput';
|
|
3
3
|
import Question from './Question';
|
|
4
4
|
|
|
5
|
-
// @TODO valid_chars, invalid_chars
|
|
6
|
-
|
|
7
5
|
export default {
|
|
8
6
|
components: { LabeledInput },
|
|
9
7
|
mixins: [Question]
|
|
@@ -11,7 +9,10 @@ export default {
|
|
|
11
9
|
</script>
|
|
12
10
|
|
|
13
11
|
<template>
|
|
14
|
-
<div
|
|
12
|
+
<div
|
|
13
|
+
:data-testid="`float-row-${question.variable}`"
|
|
14
|
+
class="row"
|
|
15
|
+
>
|
|
15
16
|
<div class="col span-6">
|
|
16
17
|
<LabeledInput
|
|
17
18
|
type="text"
|
|
@@ -21,11 +22,15 @@ export default {
|
|
|
21
22
|
:required="question.required"
|
|
22
23
|
:value="value"
|
|
23
24
|
:disabled="disabled"
|
|
25
|
+
:tooltip="displayTooltip"
|
|
26
|
+
:rules="rules"
|
|
27
|
+
:data-testid="`float-input-${question.variable}`"
|
|
24
28
|
@input="val = parseFloat($event); if ( !isNaN(val) ) { $emit('input', val) }"
|
|
25
29
|
/>
|
|
26
30
|
</div>
|
|
27
31
|
<div
|
|
28
32
|
v-if="showDescription"
|
|
33
|
+
:data-testid="`float-description-${question.variable}`"
|
|
29
34
|
class="col span-6 mt-10"
|
|
30
35
|
>
|
|
31
36
|
{{ question.description }}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import { LabeledInput } from '@components/Form/LabeledInput';
|
|
3
3
|
import Question from './Question';
|
|
4
4
|
|
|
5
|
-
// @TODO valid_chars, invalid_chars
|
|
6
|
-
|
|
7
5
|
export default {
|
|
8
6
|
components: { LabeledInput },
|
|
9
7
|
mixins: [Question]
|
|
@@ -11,7 +9,10 @@ export default {
|
|
|
11
9
|
</script>
|
|
12
10
|
|
|
13
11
|
<template>
|
|
14
|
-
<div
|
|
12
|
+
<div
|
|
13
|
+
:data-testid="`int-row-${question.variable}`"
|
|
14
|
+
class="row"
|
|
15
|
+
>
|
|
15
16
|
<div class="col span-6">
|
|
16
17
|
<LabeledInput
|
|
17
18
|
type="text"
|
|
@@ -21,11 +22,15 @@ export default {
|
|
|
21
22
|
:required="question.required"
|
|
22
23
|
:value="value"
|
|
23
24
|
:disabled="disabled"
|
|
25
|
+
:tooltip="displayTooltip"
|
|
26
|
+
:rules="rules"
|
|
27
|
+
:data-testid="`int-input-${question.variable}`"
|
|
24
28
|
@input="val = parseInt($event, 10); if ( !isNaN(val) ) { $emit('input', val) }"
|
|
25
29
|
/>
|
|
26
30
|
</div>
|
|
27
31
|
<div
|
|
28
32
|
v-if="showDescription"
|
|
33
|
+
:data-testid="`int-description-${question.variable}`"
|
|
29
34
|
class="col span-6 mt-10"
|
|
30
35
|
>
|
|
31
36
|
{{ displayDescription }}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { _EDIT } from '@shell/config/query-params';
|
|
2
|
+
import { validateChars, validateHostname, validateLength } from '@shell/utils/validators';
|
|
3
|
+
import { cronSchedule } from '@shell/utils/validators/cron-schedule';
|
|
4
|
+
import { isValidCIDR, isValidIP } from '@shell/utils/validators/cidr';
|
|
2
5
|
|
|
3
6
|
export default {
|
|
4
7
|
props: {
|
|
@@ -57,6 +60,75 @@ export default {
|
|
|
57
60
|
|
|
58
61
|
return this.$store.getters['i18n/withFallback'](`charts.${ this.chartName }."${ variable }".description`, null, this.question?.description);
|
|
59
62
|
},
|
|
63
|
+
|
|
64
|
+
displayTooltip() {
|
|
65
|
+
if (!this.question?.tooltip) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const variable = this.question?.variable;
|
|
69
|
+
|
|
70
|
+
return this.$store.getters['i18n/withFallback'](`charts.${ this.chartName }."${ variable }".tooltip`, null, this.question?.tooltip);
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
rules() {
|
|
74
|
+
return [
|
|
75
|
+
(val) => {
|
|
76
|
+
let errors = [];
|
|
77
|
+
|
|
78
|
+
errors = validateChars(
|
|
79
|
+
val,
|
|
80
|
+
{
|
|
81
|
+
validChars: this.question.valid_chars,
|
|
82
|
+
invalidChars: this.question.invalid_chars
|
|
83
|
+
},
|
|
84
|
+
this.displayLabel,
|
|
85
|
+
this.$store.getters,
|
|
86
|
+
errors,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
errors = validateLength(
|
|
90
|
+
val,
|
|
91
|
+
{
|
|
92
|
+
minLength: this.question?.min_length,
|
|
93
|
+
maxLenght: this.question?.max_length,
|
|
94
|
+
min: this.question?.min,
|
|
95
|
+
max: this.question?.max,
|
|
96
|
+
},
|
|
97
|
+
this.displayLabel,
|
|
98
|
+
this.$store.getters,
|
|
99
|
+
errors,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (this.question.type === 'hostname') {
|
|
103
|
+
errors = validateHostname(
|
|
104
|
+
val,
|
|
105
|
+
this.displayLabel,
|
|
106
|
+
this.$store.getters,
|
|
107
|
+
{},
|
|
108
|
+
errors,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (this.question.type === 'cron') {
|
|
113
|
+
cronSchedule(
|
|
114
|
+
val,
|
|
115
|
+
this.$store.getters,
|
|
116
|
+
errors,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (this.question.type === 'cidr' && !isValidCIDR(val)) {
|
|
121
|
+
errors.push(this.$store.getters['i18n/t']('validation.invalidCidr'));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (this.question.type === 'ipaddr' && !isValidIP(val)) {
|
|
125
|
+
errors.push(this.$store.getters['i18n/t']('validation.invalidIP'));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return errors;
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
}
|
|
60
132
|
},
|
|
61
133
|
|
|
62
134
|
created() {
|
|
@@ -29,11 +29,12 @@ export default {
|
|
|
29
29
|
<div class="col span-12 mt-10">
|
|
30
30
|
<KeyValue
|
|
31
31
|
:key="question.variable"
|
|
32
|
-
v-model="value
|
|
32
|
+
v-model="value"
|
|
33
33
|
:title="question.label"
|
|
34
34
|
:mode="mode"
|
|
35
35
|
:protip="false"
|
|
36
36
|
:disabled="disabled"
|
|
37
|
+
:title-protip="displayTooltip"
|
|
37
38
|
@input="update"
|
|
38
39
|
/>
|
|
39
40
|
</div>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import RadioGroup from '@components/Form/Radio/RadioGroup.vue';
|
|
3
|
+
import Question from './Question';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
components: { RadioGroup },
|
|
7
|
+
mixins: [Question]
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<div class="row">
|
|
13
|
+
<div class="col span-6">
|
|
14
|
+
<RadioGroup
|
|
15
|
+
name="question.variable"
|
|
16
|
+
:mode="mode"
|
|
17
|
+
:labels="Array.isArray(question.options) ? question.options : Object.values(question.options)"
|
|
18
|
+
:options="Array.isArray(question.options) ? question.options : Object.keys(question.options)"
|
|
19
|
+
:value="value"
|
|
20
|
+
:disabled="disabled"
|
|
21
|
+
:label="displayLabel"
|
|
22
|
+
:tooltip="displayTooltip"
|
|
23
|
+
@input="$emit('input', $event)"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
<div
|
|
27
|
+
v-if="showDescription"
|
|
28
|
+
class="col span-6 mt-10"
|
|
29
|
+
>
|
|
30
|
+
{{ displayDescription }}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
@@ -96,6 +96,7 @@ export default {
|
|
|
96
96
|
:placeholder="question.description"
|
|
97
97
|
:required="question.required"
|
|
98
98
|
:value="value"
|
|
99
|
+
:tooltip="displayTooltip"
|
|
99
100
|
@input="!$fetchState.pending && $emit('input', $event)"
|
|
100
101
|
/>
|
|
101
102
|
</div>
|
|
@@ -118,6 +119,7 @@ export default {
|
|
|
118
119
|
:placeholder="question.description"
|
|
119
120
|
:required="question.required"
|
|
120
121
|
:value="value"
|
|
122
|
+
:tooltip="displayTooltip"
|
|
121
123
|
@input="!$fetchState.pending && $emit('input', $event)"
|
|
122
124
|
/>
|
|
123
125
|
</div>
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import { LabeledInput } from '@components/Form/LabeledInput';
|
|
3
3
|
import Question from './Question';
|
|
4
4
|
|
|
5
|
-
// @TODO valid_chars, invalid_chars
|
|
6
|
-
|
|
7
5
|
export default {
|
|
8
6
|
components: { LabeledInput },
|
|
9
7
|
mixins: [Question],
|
|
@@ -21,7 +19,10 @@ export default {
|
|
|
21
19
|
</script>
|
|
22
20
|
|
|
23
21
|
<template>
|
|
24
|
-
<div
|
|
22
|
+
<div
|
|
23
|
+
:data-testid="`string-row-${question.variable}`"
|
|
24
|
+
class="row"
|
|
25
|
+
>
|
|
25
26
|
<div class="col span-6">
|
|
26
27
|
<LabeledInput
|
|
27
28
|
:mode="mode"
|
|
@@ -31,11 +32,15 @@ export default {
|
|
|
31
32
|
:required="question.required"
|
|
32
33
|
:value="value"
|
|
33
34
|
:disabled="disabled"
|
|
35
|
+
:tooltip="displayTooltip"
|
|
36
|
+
:rules="rules"
|
|
37
|
+
:data-testid="`string-input-${question.variable}`"
|
|
34
38
|
@input="$emit('input', $event)"
|
|
35
39
|
/>
|
|
36
40
|
</div>
|
|
37
41
|
<div
|
|
38
42
|
v-if="showDescription"
|
|
43
|
+
:data-testid="`string-description-${question.variable}`"
|
|
39
44
|
class="col span-6 mt-10"
|
|
40
45
|
>
|
|
41
46
|
{{ displayDescription }}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import YamlEditor from '@shell/components/YamlEditor';
|
|
3
|
+
import Question from './Question';
|
|
4
|
+
import { _VIEW } from '@shell/config/query-params';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
components: { YamlEditor },
|
|
8
|
+
mixins: [Question],
|
|
9
|
+
data() {
|
|
10
|
+
return { VIEW: _VIEW };
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<div
|
|
17
|
+
:data-testid="`yaml-row-${question.variable}`"
|
|
18
|
+
class="row"
|
|
19
|
+
>
|
|
20
|
+
<div class="col span-6">
|
|
21
|
+
<h3>
|
|
22
|
+
{{ displayLabel }}
|
|
23
|
+
<i
|
|
24
|
+
v-if="displayTooltip"
|
|
25
|
+
v-clean-tooltip="displayTooltip"
|
|
26
|
+
class="icon icon-info icon-lg"
|
|
27
|
+
/>
|
|
28
|
+
</h3>
|
|
29
|
+
<YamlEditor
|
|
30
|
+
class="yaml-editor mb-6"
|
|
31
|
+
:editor-mode="mode === VIEW ? 'VIEW_CODE' : 'EDIT_CODE'"
|
|
32
|
+
:disabled="disabled"
|
|
33
|
+
:value="value"
|
|
34
|
+
:data-testid="`yaml-input-${question.variable}`"
|
|
35
|
+
@input="$emit('input', $event)"
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
<div
|
|
39
|
+
v-if="showDescription"
|
|
40
|
+
:data-testid="`yaml-description-${question.variable}`"
|
|
41
|
+
class="col span-6 mt-10"
|
|
42
|
+
>
|
|
43
|
+
{{ displayDescription }}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import Questions from '@shell/components/Questions';
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import { _EDIT } from '@shell/config/query-params';
|
|
4
|
+
const defaultStubs = {
|
|
5
|
+
Tab: true,
|
|
6
|
+
Tabbed: true,
|
|
7
|
+
};
|
|
8
|
+
const defaultGetters = {
|
|
9
|
+
currentStore: () => 'current_store',
|
|
10
|
+
'management/schemaFor': jest.fn(),
|
|
11
|
+
'current_store/all': jest.fn(),
|
|
12
|
+
'i18n/t': jest.fn(),
|
|
13
|
+
'i18n/withFallback': jest.fn((key, args, fallback) => fallback),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe('the Boolean Component', () => {
|
|
17
|
+
it('input field is present', () => {
|
|
18
|
+
const wrapper = mount(Questions, {
|
|
19
|
+
propsData: {
|
|
20
|
+
value: {},
|
|
21
|
+
targetNamespace: 'test',
|
|
22
|
+
source: [{
|
|
23
|
+
variable: 'var_name',
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
label: '',
|
|
26
|
+
}],
|
|
27
|
+
mode: _EDIT
|
|
28
|
+
},
|
|
29
|
+
mocks: { $store: { getters: defaultGetters } },
|
|
30
|
+
stubs: defaultStubs,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const inputFields = wrapper.findAll('[data-testid="boolean-input-var_name"] input[type=checkbox]');
|
|
34
|
+
|
|
35
|
+
expect(inputFields).toHaveLength(1);
|
|
36
|
+
|
|
37
|
+
const descriptionFields = wrapper.findAll('[data-testid="boolean-description-var_name"]');
|
|
38
|
+
|
|
39
|
+
expect(descriptionFields).toHaveLength(0);
|
|
40
|
+
|
|
41
|
+
const labelFields = wrapper.findAll('[data-testid="boolean-row-var_name"] label');
|
|
42
|
+
|
|
43
|
+
expect(labelFields).toHaveLength(1);
|
|
44
|
+
expect(labelFields.at(0).text()).toBe('var_name');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('description is present', () => {
|
|
48
|
+
const wrapper = mount(Questions, {
|
|
49
|
+
propsData: {
|
|
50
|
+
value: {},
|
|
51
|
+
targetNamespace: 'test',
|
|
52
|
+
source: [{
|
|
53
|
+
variable: 'var_name',
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
description: 'test description'
|
|
56
|
+
}],
|
|
57
|
+
mode: _EDIT
|
|
58
|
+
},
|
|
59
|
+
mocks: { $store: { getters: defaultGetters } },
|
|
60
|
+
stubs: defaultStubs,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const inputFields = wrapper.findAll('[data-testid="boolean-input-var_name"]');
|
|
64
|
+
|
|
65
|
+
expect(inputFields).toHaveLength(1);
|
|
66
|
+
|
|
67
|
+
const descriptionFields = wrapper.findAll('[data-testid="boolean-description-var_name"]');
|
|
68
|
+
|
|
69
|
+
expect(descriptionFields).toHaveLength(1);
|
|
70
|
+
expect(descriptionFields.at(0).text()).toBe('test description');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('label is present', () => {
|
|
74
|
+
const wrapper = mount(Questions, {
|
|
75
|
+
propsData: {
|
|
76
|
+
value: {},
|
|
77
|
+
targetNamespace: 'test',
|
|
78
|
+
source: [{
|
|
79
|
+
variable: 'var_name',
|
|
80
|
+
type: 'boolean',
|
|
81
|
+
label: 'test label'
|
|
82
|
+
}],
|
|
83
|
+
mode: _EDIT
|
|
84
|
+
},
|
|
85
|
+
mocks: { $store: { getters: defaultGetters } },
|
|
86
|
+
stubs: defaultStubs,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const inputFields = wrapper.findAll('[data-testid="boolean-input-var_name"]');
|
|
90
|
+
|
|
91
|
+
expect(inputFields).toHaveLength(1);
|
|
92
|
+
|
|
93
|
+
const labelFields = wrapper.findAll('[data-testid="boolean-row-var_name"] label');
|
|
94
|
+
|
|
95
|
+
expect(labelFields).toHaveLength(1);
|
|
96
|
+
expect(labelFields.at(0).text()).toBe('test label');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('tooltip is present', () => {
|
|
100
|
+
const wrapper = mount(Questions, {
|
|
101
|
+
propsData: {
|
|
102
|
+
value: {},
|
|
103
|
+
targetNamespace: 'test',
|
|
104
|
+
source: [{
|
|
105
|
+
variable: 'var_name',
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
tooltip: 'test tooltip'
|
|
108
|
+
}],
|
|
109
|
+
mode: _EDIT
|
|
110
|
+
},
|
|
111
|
+
mocks: { $store: { getters: defaultGetters } },
|
|
112
|
+
stubs: defaultStubs,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const inputFields = wrapper.findAll('[data-testid="boolean-input-var_name"]');
|
|
116
|
+
|
|
117
|
+
expect(inputFields).toHaveLength(1);
|
|
118
|
+
|
|
119
|
+
const labelFields = wrapper.findAll('[data-testid="boolean-row-var_name"] .checkbox-info');
|
|
120
|
+
|
|
121
|
+
expect(labelFields).toHaveLength(1);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import Questions from '@shell/components/Questions';
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import { _EDIT } from '@shell/config/query-params';
|
|
4
|
+
const defaultStubs = {
|
|
5
|
+
Tab: true,
|
|
6
|
+
Tabbed: true,
|
|
7
|
+
};
|
|
8
|
+
const defaultGetters = {
|
|
9
|
+
currentStore: () => 'current_store',
|
|
10
|
+
'management/schemaFor': jest.fn(),
|
|
11
|
+
'current_store/all': jest.fn(),
|
|
12
|
+
'i18n/t': jest.fn(),
|
|
13
|
+
'i18n/withFallback': jest.fn((key, args, fallback) => fallback),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe('the float Component', () => {
|
|
17
|
+
it('input field is present', () => {
|
|
18
|
+
const wrapper = mount(Questions, {
|
|
19
|
+
propsData: {
|
|
20
|
+
value: {},
|
|
21
|
+
targetNamespace: 'test',
|
|
22
|
+
source: [{
|
|
23
|
+
variable: 'var_name',
|
|
24
|
+
type: 'float',
|
|
25
|
+
label: '',
|
|
26
|
+
}],
|
|
27
|
+
mode: _EDIT
|
|
28
|
+
},
|
|
29
|
+
mocks: { $store: { getters: defaultGetters } },
|
|
30
|
+
stubs: defaultStubs,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const inputFields = wrapper.findAll('[data-testid="float-input-var_name"]');
|
|
34
|
+
|
|
35
|
+
expect(inputFields).toHaveLength(1);
|
|
36
|
+
|
|
37
|
+
const descriptionFields = wrapper.findAll('[data-testid="float-description-var_name"]');
|
|
38
|
+
|
|
39
|
+
expect(descriptionFields).toHaveLength(0);
|
|
40
|
+
|
|
41
|
+
const labelFields = wrapper.findAll('[data-testid="float-row-var_name"] label');
|
|
42
|
+
|
|
43
|
+
expect(labelFields).toHaveLength(1);
|
|
44
|
+
expect(labelFields.at(0).text()).toBe('var_name');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('description is present', () => {
|
|
48
|
+
const wrapper = mount(Questions, {
|
|
49
|
+
propsData: {
|
|
50
|
+
value: {},
|
|
51
|
+
targetNamespace: 'test',
|
|
52
|
+
source: [{
|
|
53
|
+
variable: 'var_name',
|
|
54
|
+
type: 'float',
|
|
55
|
+
description: 'test description'
|
|
56
|
+
}],
|
|
57
|
+
mode: _EDIT
|
|
58
|
+
},
|
|
59
|
+
mocks: { $store: { getters: defaultGetters } },
|
|
60
|
+
stubs: defaultStubs,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const inputFields = wrapper.findAll('[data-testid="float-input-var_name"]');
|
|
64
|
+
|
|
65
|
+
expect(inputFields).toHaveLength(1);
|
|
66
|
+
|
|
67
|
+
const descriptionFields = wrapper.findAll('[data-testid="float-description-var_name"]');
|
|
68
|
+
|
|
69
|
+
expect(descriptionFields).toHaveLength(1);
|
|
70
|
+
expect(descriptionFields.at(0).text()).toBe('test description');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('label is present', () => {
|
|
74
|
+
const wrapper = mount(Questions, {
|
|
75
|
+
propsData: {
|
|
76
|
+
value: {},
|
|
77
|
+
targetNamespace: 'test',
|
|
78
|
+
source: [{
|
|
79
|
+
variable: 'var_name',
|
|
80
|
+
type: 'float',
|
|
81
|
+
label: 'test label'
|
|
82
|
+
}],
|
|
83
|
+
mode: _EDIT
|
|
84
|
+
},
|
|
85
|
+
mocks: { $store: { getters: defaultGetters } },
|
|
86
|
+
stubs: defaultStubs,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const inputFields = wrapper.findAll('[data-testid="float-input-var_name"]');
|
|
90
|
+
|
|
91
|
+
expect(inputFields).toHaveLength(1);
|
|
92
|
+
|
|
93
|
+
const labelFields = wrapper.findAll('[data-testid="float-row-var_name"] label');
|
|
94
|
+
|
|
95
|
+
expect(labelFields).toHaveLength(1);
|
|
96
|
+
expect(labelFields.at(0).text()).toBe('test label');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('tooltip is present', () => {
|
|
100
|
+
const wrapper = mount(Questions, {
|
|
101
|
+
propsData: {
|
|
102
|
+
value: {},
|
|
103
|
+
targetNamespace: 'test',
|
|
104
|
+
source: [{
|
|
105
|
+
variable: 'var_name',
|
|
106
|
+
type: 'float',
|
|
107
|
+
tooltip: 'test tooltip'
|
|
108
|
+
}],
|
|
109
|
+
mode: _EDIT
|
|
110
|
+
},
|
|
111
|
+
mocks: { $store: { getters: defaultGetters } },
|
|
112
|
+
stubs: defaultStubs,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const inputFields = wrapper.findAll('[data-testid="float-input-var_name"]');
|
|
116
|
+
|
|
117
|
+
expect(inputFields).toHaveLength(1);
|
|
118
|
+
|
|
119
|
+
const labelFields = wrapper.findAll('[data-testid="float-row-var_name"] .labeled-tooltip');
|
|
120
|
+
|
|
121
|
+
expect(labelFields).toHaveLength(1);
|
|
122
|
+
});
|
|
123
|
+
});
|