Skip to content

Commit

Permalink
fix: do not propagate click event on checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasHirt committed Apr 30, 2021
1 parent 090b13c commit 0b9dd04
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/components/ListResources.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
<oc-td v-if="!isLocationPicker" class="oc-pm" width="shrink">
<oc-checkbox
class="file-picker-resource-checkbox uk-margin-small-left"
:data-testid="`list-resources-checkbox-${resource.id}`"
:value="isResourceSelected(resource)"
:label="selectLabel(resource.name)"
:hide-label="true"
@click.stop
@change.native="toggleResourceSelection(resource)"
@click.native.stop
@input="toggleResourceSelection(resource)"
/>
</oc-td>
<oc-td class="oc-pm">
Expand Down
52 changes: 46 additions & 6 deletions tests/integration/specs/filePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('Users can select location from within the file picker', () => {
test('User can select the current folder', async () => {
const { getByTestId, emitted } = render(FilePicker, {
props: {
variation: 'location'
}
variation: 'location',
},
})

await waitFor(() => expect(getByTestId('list-resources-table')).toBeVisible())
Expand All @@ -25,8 +25,8 @@ describe('Users can select location from within the file picker', () => {
test('User can select a nested folder as a location', async () => {
const { getByTestId, emitted, getByText } = render(FilePicker, {
props: {
variation: 'location'
}
variation: 'location',
},
})

await waitFor(() => expect(getByTestId('list-resources-table')).toBeVisible())
Expand All @@ -47,7 +47,7 @@ describe('Users can select location from within the file picker', () => {
await fireEvent.click(getByTestId('list-header-btn-select'))

const expectedFolder = resources['/Photos'].find(
r => r.fileInfo['{http://owncloud.org/ns}fileid'] === '1'
(r) => r.fileInfo['{http://owncloud.org/ns}fileid'] === '1'
)

expect(emitted().selectResources[0][0][0].id).toMatch(
Expand All @@ -57,5 +57,45 @@ describe('Users can select location from within the file picker', () => {
})

describe('Users can select resources from within the file picker', () => {
test.todo('User can select resources from the current folder')
test('User can select resources from the current folder', async () => {
const { getByTestId, getByText, emitted } = render(FilePicker, {
props: {
variation: 'resource',
},
})

await waitFor(() => expect(getByTestId('list-resources-table')).toBeVisible())

expect(getByText('Photos')).toBeVisible()

await fireEvent.click(getByText('Photos'))

await waitFor(() => expect(getByText('Vacation')).toBeVisible())
expect(getByText('Teotihuacan')).toBeVisible()
expect(getByTestId('list-resources-row-9')).not.toHaveClass('files-list-row-disabled')

await fireEvent.click(getByTestId('list-resources-checkbox-1').querySelector('.oc-checkbox'))
await fireEvent.click(getByTestId('list-resources-checkbox-9').querySelector('.oc-checkbox'))

expect(getByTestId('list-resources-row-1')).toHaveClass('oc-background-selected')
expect(getByTestId('list-resources-row-9')).toHaveClass('oc-background-selected')
expect(getByTestId('list-header-btn-select')).toBeVisible()

await fireEvent.click(getByTestId('list-header-btn-select'))

const expectedResources = resources['/Photos']

expect(
expectedResources.find(
(r) =>
r.fileInfo['{http://owncloud.org/ns}fileid'] === emitted().selectResources[0][0][0].id
)
).toBeTruthy()
expect(
expectedResources.find(
(r) =>
r.fileInfo['{http://owncloud.org/ns}fileid'] === emitted().selectResources[0][0][1].id
)
).toBeTruthy()
})
})

0 comments on commit 0b9dd04

Please sign in to comment.