Skip to content

Commit 1af713e

Browse files
committed
Edit Runtime: handle TaskRunMode enum now including simulation & dummy modes
1 parent 214d528 commit 1af713e

File tree

4 files changed

+74
-20
lines changed

4 files changed

+74
-20
lines changed

src/components/graphqlFormGenerator/EditRuntimeForm.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { cloneDeep, isArray, isEqual, snakeCase, startCase } from 'lodash'
5757
import { VTextarea } from 'vuetify/components/VTextarea'
5858
import VuetifyConfig, { getComponentProps, RUNTIME_SETTING } from '@/components/graphqlFormGenerator/components/vuetify'
5959
import { findByName, mutate, mutationStatus } from '@/utils/aotf'
60+
import GEnum from '@/components/graphqlFormGenerator/components/Enum.vue'
6061
6162
const NamedTypes = {
6263
...VuetifyConfig.namedTypes,
@@ -65,7 +66,12 @@ const NamedTypes = {
6566
rows: '1',
6667
autoGrow: true,
6768
style: 'font-family: monospace;'
68-
}
69+
},
70+
TaskRunMode: {
71+
is: GEnum,
72+
// Workaround https://github.com/cylc/cylc-flow/pull/6554#discussion_r1922563421
73+
allowedValues: ['Live', 'Skip'],
74+
},
6975
}
7076
7177
export default {

src/components/graphqlFormGenerator/components/Enum.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
<template>
1919
<v-select
20-
persistent-hint
2120
v-model="model"
2221
v-bind="$attrs"
23-
:items="type.enumValues"
22+
:items="enumValues"
2423
item-title="name"
2524
:hint="itemDesc"
2625
placeholder="Select an option"
26+
persistent-hint
2727
/>
2828
</template>
2929

@@ -32,13 +32,31 @@ import { formElement } from '@/components/graphqlFormGenerator/mixins'
3232
3333
export default {
3434
name: 'g-enum',
35+
3536
mixins: [formElement],
37+
38+
props: {
39+
/** Specify a subset of the type's enum values that will be displayed. */
40+
allowedValues: {
41+
type: Array,
42+
required: false,
43+
},
44+
},
45+
3646
computed: {
47+
enumValues () {
48+
return this.allowedValues?.length
49+
? this.type.enumValues.filter(
50+
({ name }) => this.allowedValues.includes(name)
51+
)
52+
: this.type.enumValues
53+
},
54+
3755
itemDesc () {
3856
return this.type.enumValues.find(
3957
({ name }) => name === this.modelValue
4058
)?.description ?? ''
41-
}
59+
},
4260
}
4361
}
4462
</script>

src/services/mock/json/IntrospectionQuery.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7187,15 +7187,29 @@
71877187
"interfaces": null,
71887188
"enumValues": [
71897189
{
7190-
"name": "Skip",
7191-
"description": "Skips job submission; sets required outputs (by default) or configured outputs.",
7190+
"name": "Live",
7191+
"description": "Task will submit their configured jobs.",
71927192
"isDeprecated": false,
71937193
"deprecationReason": null,
71947194
"__typename": "__EnumValue"
71957195
},
71967196
{
7197-
"name": "Live",
7198-
"description": "Task will submit their configured jobs.",
7197+
"name": "Simulation",
7198+
"description": "Simulates job submission with configurable exection time and succeeded/failed outcomes (but does not submit real jobs).",
7199+
"isDeprecated": false,
7200+
"deprecationReason": null,
7201+
"__typename": "__EnumValue"
7202+
},
7203+
{
7204+
"name": "Dummy",
7205+
"description": "Submits real jobs with empty scripts.",
7206+
"isDeprecated": false,
7207+
"deprecationReason": null,
7208+
"__typename": "__EnumValue"
7209+
},
7210+
{
7211+
"name": "Skip",
7212+
"description": "Skips job submission; sets required outputs (by default) or configured outputs.",
71997213
"isDeprecated": false,
72007214
"deprecationReason": null,
72017215
"__typename": "__EnumValue"

tests/e2e/specs/editRuntimeForm.cy.js

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,8 @@ describe('Edit Runtime form', () => {
4545
* @param {string} nodeName - the tree node name, to search for and open the mutations form
4646
*/
4747
const openMenu = (nodeName) => {
48-
cy.get('[data-cy=tree-view]').as('treeView')
49-
.find('.c-task')
50-
.should('be.visible')
51-
cy.get('@treeView')
52-
.find('span')
53-
.contains(nodeName)
54-
.parent()
55-
.find('.c-task')
48+
cy.get(`[data-node-name=${nodeName}]`)
49+
.find('[data-c-interactive]:first')
5650
.click({ force: true })
5751
cy.get('#less-more-button')
5852
.click()
@@ -65,6 +59,15 @@ describe('Edit Runtime form', () => {
6559
.contains('.c-mutation', 'Edit Runtime')
6660
}
6761

62+
/**
63+
* Open the Edit Runtime form for a particular node
64+
* @param {string} nodeName
65+
*/
66+
const openForm = (nodeName) => {
67+
openMenu(nodeName)
68+
getMenuItem().click()
69+
}
70+
6871
/**
6972
* Get the form input v-list-item element for a given label.
7073
*
@@ -79,8 +82,7 @@ describe('Edit Runtime form', () => {
7982
}
8083

8184
it('handles editing and submitting the form', () => {
82-
openMenu('retrying')
83-
getMenuItem().click()
85+
openForm('retrying')
8486

8587
getInputListItem('Init Script')
8688
.find('.v-input')
@@ -132,8 +134,7 @@ describe('Edit Runtime form', () => {
132134
})
133135

134136
it('handles a form with zero diff', () => {
135-
openMenu('retrying')
136-
getMenuItem().click()
137+
openForm('retrying')
137138

138139
getInputListItem('Outputs')
139140
// Add an empty item
@@ -185,4 +186,19 @@ describe('Edit Runtime form', () => {
185186
.should('not.exist') // if this does deliberately exist in future, change to .click()
186187
getMenuItem().should('not.exist')
187188
})
189+
190+
it('only offers live & skip run modes', () => {
191+
openForm('retrying')
192+
getInputListItem('Run Mode')
193+
.find('.v-field')
194+
.click()
195+
.invoke('attr', 'aria-controls').then((dropdownID) => {
196+
cy.get(`#${dropdownID}`)
197+
.find('[role=option]')
198+
.then(
199+
(items) => Array.from(items, (x) => x.innerText).sort()
200+
)
201+
.should('deep.equal', ['Live', 'Skip'])
202+
})
203+
})
188204
})

0 commit comments

Comments
 (0)