|
15 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 | */
|
17 | 17 |
|
| 18 | +import { mutationStatus } from '@/utils/aotf' |
| 19 | +import { Deferred } from '$tests/util' |
| 20 | + |
18 | 21 | describe('Toolbar component', () => {
|
19 | 22 | it('Is displayed when we are looking at a workflow', () => {
|
20 | 23 | cy.visit('/#/workspace/one')
|
@@ -63,3 +66,68 @@ describe('Toolbar Component authenticated user', () => {
|
63 | 66 | .should('have.text', 'U')
|
64 | 67 | })
|
65 | 68 | })
|
| 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