Skip to content

Commit db7d79c

Browse files
committed
test: enabled
1 parent 53554b8 commit db7d79c

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<script lang="ts">
2+
import gql from 'graphql-tag'
3+
import { useQuery } from '@vue/apollo-composable'
4+
import { defineComponent, computed, ref } from 'vue'
5+
6+
export default defineComponent({
7+
setup () {
8+
const selectedId = ref<string | null>(null)
9+
10+
const { result, loading } = useQuery(gql`
11+
query channel ($id: ID!) {
12+
channel (id: $id) {
13+
id
14+
label
15+
messages {
16+
id
17+
}
18+
}
19+
}
20+
`, () => ({
21+
id: selectedId.value,
22+
}), () => ({
23+
fetchPolicy: 'no-cache',
24+
enabled: !!selectedId.value,
25+
}))
26+
const channel = computed(() => result.value?.channel)
27+
28+
function load () {
29+
selectedId.value = 'general'
30+
}
31+
32+
return {
33+
load,
34+
loading,
35+
channel,
36+
}
37+
},
38+
})
39+
</script>
40+
41+
<template>
42+
<div class="m-6">
43+
<div>
44+
<button
45+
class="bg-green-200 rounded-lg p-4"
46+
@click="load()"
47+
>
48+
Load channel
49+
</button>
50+
</div>
51+
52+
<div
53+
v-if="loading"
54+
class="loading"
55+
>
56+
Loading...
57+
</div>
58+
59+
<div
60+
v-if="channel"
61+
data-test-id="data"
62+
>
63+
<div>Loaded channel: {{ channel.label }}</div>
64+
<div>Messages: {{ channel.messages.length }}</div>
65+
</div>
66+
</div>
67+
</template>

packages/test-e2e-composable-vue3/src/router.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ export const router = createRouter({
3434
path: '/partial-error',
3535
component: () => import('./components/PartialError.vue'),
3636
},
37+
{
38+
path: '/disabled',
39+
component: () => import('./components/Disabled.vue'),
40+
},
3741
],
3842
})

packages/test-e2e-composable-vue3/tests/e2e/specs/test.cy.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,12 @@ describe('Vue 3 + Apollo Composable', () => {
109109
cy.get('.list-disc').should('have.length', 3)
110110
cy.get('[data-test-id="refetched"]').should('contain', 'true')
111111
})
112+
113+
it('enabled', () => {
114+
cy.visit('/disabled')
115+
cy.get('[data-test-id="data"]').should('not.exist')
116+
cy.get('.loading').should('not.exist')
117+
cy.get('button').click()
118+
cy.get('[data-test-id="data"]').should('contain', 'Loaded channel: General')
119+
})
112120
})

0 commit comments

Comments
 (0)