Skip to content

Commit

Permalink
fix(NcAppSettingsDialog): Make sure sections are correctly labelled
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jul 4, 2024
1 parent 2e3c392 commit 25872ad
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
48 changes: 48 additions & 0 deletions cypress/component/NcAppSettingsDialog.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { mount } from 'cypress/vue2'
import NcAppSettingsDialog from '../../src/components/NcAppSettingsDialog/NcAppSettingsDialog.vue'
import NcAppSettingsSection from '../../src/components/NcAppSettingsSection/NcAppSettingsSection.vue'
import { defineComponent } from 'vue'

describe('NcAppSettingsDialog', () => {
it('Dialog is correctly labelled', () => {
mount(NcAppSettingsDialog, {
propsData: {
open: true,
name: 'My settings dialog',
},
slots: {
default: defineComponent({
render: (h) => h(NcAppSettingsSection, { props: { name: 'First section', id: 'first' } })
})
},
})

cy.findByRole('dialog', { name: 'My settings dialog' }).should('exist')
})

it('Dialog sections are correctly labelled', () => {
mount(NcAppSettingsDialog, {
propsData: {
open: true,
name: 'My settings dialog',
showNavigation: true,
},
slots: {
default: defineComponent({
render: (h) => h(NcAppSettingsSection, { props: { name: 'First section', id: 'first' } }, ['The section content'])
})
},
})

cy.findByRole('dialog', { name: 'My settings dialog' }).should('exist')
cy.findByRole('dialog', { name: 'My settings dialog' })
.findByRole('region', { name: 'First section' })
.should('exist')
.and('contain.text', 'The section content')
})
})
6 changes: 3 additions & 3 deletions src/components/NcAppSettingsSection/NcAppSettingsSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
-->

<template>
<div :id="htmlId" class="app-settings-section">
<h3 class="app-settings-section__name">
<section :id="htmlId" :aria-labelledby="`${htmlId}--label`" class="app-settings-section">
<h3 :id="`${htmlId}--label`" class="app-settings-section__name">
{{ name }}
</h3>
<slot />
<!-- @slot Optonal icon to for the secion in the navigation -->
<slot v-if="false" name="icon" />
</div>
</section>
</template>

<script>
Expand Down

0 comments on commit 25872ad

Please sign in to comment.