Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 4ff56c4

Browse files
committed
test(modal): add cypress tests for modal
1 parent b05cde3 commit 4ff56c4

File tree

38 files changed

+489
-205
lines changed

38 files changed

+489
-205
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ dist
44
# At the time of writing this, I could not find any helpful
55
# documentation for adding ESLint for Vue 3 projects running on Vite.
66
# For this reason, we ignore the playground directory.
7-
playground
7+
playground
8+
snapshots.js

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"workspaces": [
99
"packages/*",
1010
"tooling/*",
11-
"website",
12-
"tests"
11+
"website"
1312
],
1413
"scripts": {
1514
"pkg": "manypkg run",
@@ -71,10 +70,10 @@
7170
"@vue/eslint-config-typescript": "^5.1.0",
7271
"@vuedx/typecheck": "^0.4.1",
7372
"@vuedx/typescript-plugin-vue": "^0.4.1",
73+
"@vueuse/core": "4.9.1",
7474
"@vueuse/integrations": "^4.8.1",
7575
"@vueuse/motion": "^1.5.4",
7676
"aria-hidden": "^1.1.2",
77-
"@vueuse/core": "4.9.1",
7877
"axe-core": "^4.1.2",
7978
"babel-jest": "^26.6.3",
8079
"body-scroll-lock": "^3.1.5",
@@ -133,8 +132,11 @@
133132
"@babel/plugin-transform-runtime": "^7.13.15",
134133
"@cypress/snapshot": "^2.1.7",
135134
"@cypress/vite-dev-server": "^1.2.6",
136-
"@cypress/vue": "^3.0.1",
135+
"@cypress/vue": "^3",
137136
"@vue/test-utils": "^2.0.0-rc.6",
138-
"cypress": "^7.2.0"
137+
"cypress": "^7.2.0",
138+
"cypress-commands": "^1.1.0",
139+
"cypress-plugin-tab": "^1.0.5",
140+
"local-cypress": "^1.2.1"
139141
}
140142
}

packages/c-alert/examples/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ export * as BaseAlert from './base-alert.vue'
22
export * as WithAccent from './with-accent.vue'
33
export * as WithIcon from './with-icon.vue'
44
export * as WithStatus from './with-status.vue'
5-
export * as WithTitle from './with-title.vue'
5+
export * as WithTitle from './with-title.vue'

packages/c-alert/tests/c-alert.cy.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,24 @@ import { CAlert, CAlertDescription, CAlertIcon, CAlertTitle } from '../src'
55
describe('Alert Examples', () => {
66
Object.entries(Examples).map(([name, example]) => {
77
it(`renders ${name} successfully`, () => {
8-
cy.mount(example.default)
9-
.then(() => {})
10-
.checkA11y()
8+
cy.mount(h(() => <example.default></example.default>)).checkA11y()
119
})
1210
})
1311
})
1412

1513
it('contains the correct role', () => {
16-
cy.mount(Examples.BaseAlert.default)
17-
.then(() => {})
18-
.get('[role=alert]')
19-
.should('exist')
14+
cy.mount(Examples.BaseAlert.default).get('[role=alert]').should('exist')
2015
})
2116

2217
it('renders its children', () => {
2318
cy.mount(
24-
<CAlert data-testid="alert" variant="left-accent" status="info" mb="3">
25-
<CAlertIcon mr="2" />
26-
<CAlertTitle> Info alert </CAlertTitle>
27-
<CAlertDescription> Something just happened </CAlertDescription>
28-
</CAlert>
19+
h(() => (
20+
<CAlert data-testid="alert" variant="left-accent" status="info" mb="3">
21+
<CAlertIcon mr="2" />
22+
<CAlertTitle> Info alert </CAlertTitle>
23+
<CAlertDescription> Something just happened </CAlertDescription>
24+
</CAlert>
25+
))
2926
)
3027
.get('[data-testid=alert]')
3128
.should('contain', 'Info alert')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * as WithButtonGroup from './with-button-group.vue'
1+
export * as WithButtonGroup from './with-button-group.vue'

packages/c-button/examples/button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export * as WithAttachedButtons from './with-attached-buttons.vue'
44
export * as WithButtonSize from '../examples/with-button-size.vue'
55
export * as WithButtonIcon from '../examples/with-button-icon.vue'
66
export * as WithButtonVariants from '../examples/with-button-variants.vue'
7-
export * as WithLoadingStatus from '../examples/with-loading-status.vue'
7+
export * as WithLoadingStatus from '../examples/with-loading-status.vue'

packages/c-button/examples/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export * as Button from './button'
2-
export * as ButtonGroup from './button-group'
2+
export * as ButtonGroup from './button-group'

packages/c-button/src/button-group.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ const props = {
3434
...vueThemingProps,
3535
}
3636

37-
type ButtonGroupContext = ComputedRef<ThemingProps & {
38-
isDisabled?: boolean
39-
}>
37+
type ButtonGroupContext = ComputedRef<
38+
ThemingProps & {
39+
isDisabled?: boolean
40+
}
41+
>
4042

4143
const [ButtonGroupProvider, useButtonGroup] = createContext<ButtonGroupContext>(
4244
{
@@ -49,12 +51,14 @@ const CButtonGroup = defineComponent({
4951
name: 'CButtonGroup',
5052
props,
5153
setup(props, { attrs, slots }) {
52-
ButtonGroupProvider(computed(() => ({
53-
size: props.size,
54-
colorScheme: props.colorScheme,
55-
variant: props.variant,
56-
isDisabled: props.isDisabled,
57-
})))
54+
ButtonGroupProvider(
55+
computed(() => ({
56+
size: props.size,
57+
colorScheme: props.colorScheme,
58+
variant: props.variant,
59+
isDisabled: props.isDisabled,
60+
}))
61+
)
5862

5963
const styles = computed(() => {
6064
let groupStyles: SystemStyleObject = {
@@ -77,9 +81,8 @@ const CButtonGroup = defineComponent({
7781

7882
return groupStyles
7983
})
80-
81-
return () => {
8284

85+
return () => {
8386
return h(
8487
chakra('div', { label: 'button__group' }),
8588
{

packages/c-button/src/button.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ const CButton = defineComponent({
9191

9292
const group = useButtonGroup()
9393
const styles = useStyleConfig('Button', {
94-
...group.value,
94+
...group?.value,
9595
...themingProps.value,
9696
})
97-
98-
const _focus = computed(() => mergeWith({}, styles.value?.['_focus'] ?? {}, {
99-
zIndex: 1,
100-
}))
97+
98+
const _focus = computed(() =>
99+
mergeWith({}, styles.value?.['_focus'] ?? {}, {
100+
zIndex: 1,
101+
})
102+
)
101103

102104
const buttonStyles = computed<SystemStyleObject>(() => ({
103105
display: 'inline-flex',
@@ -112,11 +114,10 @@ const CButton = defineComponent({
112114
outline: 'none',
113115
width: props.isFullWidth ? '100%' : 'auto',
114116
...styles.value,
115-
...(!!group.value && { _focus: _focus.value }),
117+
...(!!group?.value && { _focus: _focus.value }),
116118
}))
117119

118120
return () => {
119-
120121
return h(
121122
chakra(props.as, {
122123
label: 'button',

0 commit comments

Comments
 (0)