Skip to content

Commit

Permalink
Fix duplicate id issue in FileWidget and CheckboxWidget tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek-17h committed Jan 21, 2025
1 parent 9becbeb commit 0d684c2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ describe('CheckboxWidget', () => {

const { asFragment } = render(
<Provider store={store}>
<CheckboxWidget id="my-field" title="My field" onChange={() => {}} />
<CheckboxWidget
id="checkbox-widget"
title="Checkbox Widget"
onChange={() => {}}
/>
</Provider>,
);

Expand All @@ -37,8 +41,8 @@ describe('CheckboxWidget', () => {
<Provider store={store}>
<CheckboxWidget
value={true}
id="my-field"
title="My field"
id="checked-checkbox-widget"
title="Checked Checkbox Widget"
onChange={() => {}}
/>
</Provider>,
Expand Down
12 changes: 6 additions & 6 deletions packages/volto/src/components/manage/Widgets/FileWidget.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('FileWidget', () => {
const { container } = render(
<Provider store={store}>
<FileWidget
id="my-field"
title="My field"
id="empty-file-widget"
title="Empty File Widget"
fieldSet="default"
onChange={() => {}}
/>
Expand All @@ -43,8 +43,8 @@ describe('FileWidget', () => {
const { container } = render(
<Provider store={store}>
<FileWidget
id="my-field"
title="My field"
id="file-widget-with-value"
title="File Widget With Value"
fieldSet="default"
onChange={() => {}}
value={{
Expand All @@ -71,8 +71,8 @@ describe('FileWidget', () => {
const { container } = render(
<Provider store={store}>
<FileWidget
id="my-field"
title="My field"
id="file-widget-raw-data"
title="File Widget With Raw Data"
fieldSet="default"
onChange={() => {}}
value={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`CheckboxWidget renders a checkbox widget component 1`] = `
<DocumentFragment>
<div
class="inline field field-wrapper-my-field"
class="inline field field-wrapper-checkbox-widget"
>
<div
class="ui grid"
Expand All @@ -22,17 +22,17 @@ exports[`CheckboxWidget renders a checkbox widget component 1`] = `
>
<input
class="hidden"
id="field-my-field"
name="field-my-field"
id="field-checkbox-widget"
name="field-checkbox-widget"
readonly=""
tabindex="0"
type="checkbox"
value=""
/>
<label
for="field-my-field"
for="field-checkbox-widget"
>
My field
Checkbox Widget
</label>
</div>
</div>
Expand All @@ -46,7 +46,7 @@ exports[`CheckboxWidget renders a checkbox widget component 1`] = `
exports[`CheckboxWidget renders a checkbox widget component checked 1`] = `
<DocumentFragment>
<div
class="inline field field-wrapper-my-field"
class="inline field field-wrapper-checked-checkbox-widget"
>
<div
class="ui grid"
Expand All @@ -66,17 +66,17 @@ exports[`CheckboxWidget renders a checkbox widget component checked 1`] = `
<input
checked=""
class="hidden"
id="field-my-field"
name="field-my-field"
id="field-checked-checkbox-widget"
name="field-checked-checkbox-widget"
readonly=""
tabindex="0"
type="checkbox"
value=""
/>
<label
for="field-my-field"
for="field-checked-checkbox-widget"
>
My field
Checked Checkbox Widget
</label>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`FileWidget renders a file widget component with value 1`] = `
<div>
<div
class="inline field field-wrapper-my-field"
class="inline field field-wrapper-file-widget-with-value"
>
<div
class="ui grid"
Expand All @@ -18,10 +18,10 @@ exports[`FileWidget renders a file widget component with value 1`] = `
class="wrapper"
>
<label
for="field-my-field"
id="fieldset-default-field-label-my-field"
for="field-file-widget-with-value"
id="fieldset-default-field-label-file-widget-with-value"
>
My field
File Widget With Value
</label>
</div>
</div>
Expand All @@ -34,20 +34,20 @@ exports[`FileWidget renders a file widget component with value 1`] = `
>
<img
class="ui small image image-preview"
id="field-my-field-image"
id="field-file-widget-with-value-image"
src="http://myfile?id=0"
/>
<label
class="label-file-widget-input"
for="field-my-field"
for="field-file-widget-with-value"
>
Replace existing file
</label>
<input
autocomplete="off"
id="field-my-field"
id="field-file-widget-with-value"
multiple=""
name="my-field"
name="file-widget-with-value"
style="display: none;"
tabindex="-1"
type="file"
Expand Down Expand Up @@ -87,7 +87,7 @@ exports[`FileWidget renders a file widget component with value 1`] = `
exports[`FileWidget renders a file widget component with value in raw data 1`] = `
<div>
<div
class="inline field field-wrapper-my-field"
class="inline field field-wrapper-file-widget-raw-data"
>
<div
class="ui grid"
Expand All @@ -102,10 +102,10 @@ exports[`FileWidget renders a file widget component with value in raw data 1`] =
class="wrapper"
>
<label
for="field-my-field"
id="fieldset-default-field-label-my-field"
for="field-file-widget-raw-data"
id="fieldset-default-field-label-file-widget-raw-data"
>
My field
File Widget With Raw Data
</label>
</div>
</div>
Expand All @@ -118,20 +118,20 @@ exports[`FileWidget renders a file widget component with value in raw data 1`] =
>
<img
class="ui small image image-preview"
id="field-my-field-image"
id="field-file-widget-raw-data-image"
src="data:image/png;base64,oiweurtksdgfjaslfqw9523563456"
/>
<label
class="label-file-widget-input"
for="field-my-field"
for="field-file-widget-raw-data"
>
Replace existing file
</label>
<input
autocomplete="off"
id="field-my-field"
id="field-file-widget-raw-data"
multiple=""
name="my-field"
name="file-widget-raw-data"
style="display: none;"
tabindex="-1"
type="file"
Expand Down Expand Up @@ -170,7 +170,7 @@ exports[`FileWidget renders a file widget component with value in raw data 1`] =
exports[`FileWidget renders an empty file widget component 1`] = `
<div>
<div
class="inline field field-wrapper-my-field"
class="inline field field-wrapper-empty-file-widget"
>
<div
class="ui grid"
Expand All @@ -185,10 +185,10 @@ exports[`FileWidget renders an empty file widget component 1`] = `
class="wrapper"
>
<label
for="field-my-field"
id="fieldset-default-field-label-my-field"
for="field-empty-file-widget"
id="fieldset-default-field-label-empty-file-widget"
>
My field
Empty File Widget
</label>
</div>
</div>
Expand All @@ -210,15 +210,15 @@ exports[`FileWidget renders an empty file widget component 1`] = `
</div>
<label
class="label-file-widget-input"
for="field-my-field"
for="field-empty-file-widget"
>
Choose a file
</label>
<input
autocomplete="off"
id="field-my-field"
id="field-empty-file-widget"
multiple=""
name="my-field"
name="empty-file-widget"
style="display: none;"
tabindex="-1"
type="file"
Expand Down

0 comments on commit 0d684c2

Please sign in to comment.