Skip to content

Commit 3180f67

Browse files
Edit Runtime: handle changes to task run mode schema (#2057)
* Update mock data Introspection query response etc. * Edit Runtime: handle `TaskRunMode` enum now including simulation & dummy modes
2 parents da12fca + 1af713e commit 3180f67

File tree

8 files changed

+260
-102
lines changed

8 files changed

+260
-102
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: 199 additions & 84 deletions
Large diffs are not rendered by default.

src/services/mock/json/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The files in this directory include:
55
- `*.json` these a [json-server](https://github.com/typicode/json-server) database
66
files. For each of these, when exported, you should have an entry in the `/db`
77
endpoint.
8-
- `data.js` this is a JS module that exports the imported JSON files. The names
8+
- `index.cjs` this is a JS module that exports the imported JSON files. The names
99
used in the export section drive the value that appears in the `json-server`
1010
endpoints (see `/db` to inspect what values are available).
1111

src/services/mock/json/familyProxy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"directives": [],
2020
"environment": [],
2121
"outputs": [],
22+
"runMode": "Live",
2223
"__typename": "Runtime"
2324
}
2425
}

src/services/mock/json/taskProxy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
}
3838
],
3939
"outputs": [],
40+
"runMode": "Live",
4041
"__typename": "Runtime"
4142
}
4243
}

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
})

tests/unit/components/graphqlFormGenerator/editRuntimeForm.vue.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ const INITIAL_DATA = {
6262
frozenKey: true
6363
}
6464
],
65-
outputs: []
65+
outputs: [],
66+
runMode: 'Live',
6667
}
6768

6869
const $workflowService = {

0 commit comments

Comments
 (0)