Skip to content

Commit fe8b762

Browse files
committed
Add E2E tests for N-window selector
1 parent 3d8d9b8 commit fe8b762

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

src/components/cylc/workflow/Toolbar.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
8989
:disabled="isStopped"
9090
link
9191
size="small"
92+
data-cy="n-win-selector"
9293
>
9394
N={{ nWindow }}
9495
<v-menu
9596
activator="parent"
9697
:close-on-content-click="false"
9798
max-width="400"
99+
data-cy="n-win-popup"
98100
>
99101
<v-card title="Graph Window Depth">
100102
<v-card-text>

tests/e2e/specs/toolbar.cy.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18+
import { mutationStatus } from '@/utils/aotf'
19+
import { Deferred } from '$tests/util'
20+
1821
describe('Toolbar component', () => {
1922
it('Is displayed when we are looking at a workflow', () => {
2023
cy.visit('/#/workspace/one')
@@ -63,3 +66,68 @@ describe('Toolbar Component authenticated user', () => {
6366
.should('have.text', 'U')
6467
})
6568
})
69+
70+
describe('N-window selector', () => {
71+
/** Capture mutations. */
72+
function captureGraphWinMutation () {
73+
const mutations = []
74+
const deferred = new Deferred()
75+
cy.window().its('app.$workflowService').then((service) => {
76+
// mock the workflow service's mutate method to catch high-level calls
77+
service.mutate = async (name, id, args) => {
78+
switch (name) {
79+
case 'setGraphWindowExtent':
80+
mutations.push(args.nEdgeDistance)
81+
await deferred.promise
82+
return [mutationStatus.SUCCEEDED, '']
83+
default:
84+
throw new Error('This mutation is not mocked by the tests')
85+
}
86+
}
87+
})
88+
return { mutations, deferred }
89+
}
90+
91+
it('Is enabled for workflows that are not stopped', () => {
92+
// Disabled for stopped workflow:
93+
cy.visit('/#/workspace/multi/level/run1')
94+
.get('#core-app-bar')
95+
.find('[data-cy=n-win-selector]')
96+
.should('have.attr', 'disabled')
97+
// Enabled for running workflow:
98+
cy.visit('/#/workspace/one')
99+
.get('[data-cy=n-win-selector]')
100+
.click()
101+
.get('[data-cy=n-win-popup]')
102+
.find('input')
103+
.invoke('val')
104+
.should('eq', '1')
105+
})
106+
107+
it('Sets the n-window', () => {
108+
cy.visit('/#/workspace/one')
109+
const { mutations, deferred } = captureGraphWinMutation()
110+
cy.get('[data-cy=n-win-selector]')
111+
.click()
112+
.get('[data-cy=n-win-popup]')
113+
.find('[role=combobox]')
114+
.click()
115+
.invoke('attr', 'aria-owns').then((dropdownID) => {
116+
cy.get(`#${dropdownID}`)
117+
.contains('3')
118+
.click()
119+
.then(() => {
120+
expect(mutations).to.deep.equal([3])
121+
// Should show loading spinner while waiting for response
122+
cy.get('[data-cy=n-win-popup] .v-progress-circular').as('loadingSpinner')
123+
.should('be.visible').then(() => {
124+
// Allow the "response" to complete
125+
deferred.resolve()
126+
cy.get('@loadingSpinner')
127+
.should('not.exist')
128+
// Note we cannot mock websockets in Cypress so we cannot test the actual update of the n-window in the GraphQL subscription
129+
})
130+
})
131+
})
132+
})
133+
})

0 commit comments

Comments
 (0)