Skip to content

Commit 876320b

Browse files
Copilotpattonwebz
andauthored
fix: make confirmed accessible first dismiss reason default
Co-authored-by: pattonwebz <3902039+pattonwebz@users.noreply.github.com>
1 parent 19698c3 commit 876320b

5 files changed

Lines changed: 36 additions & 13 deletions

File tree

admin/class-ignore-ui.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class IgnoreUI {
2727
*/
2828
public static function get_reasons(): array {
2929
return [
30+
'accessible' => [
31+
'label' => __( 'Confirmed accessible', 'accessibility-checker' ),
32+
'description' => __( 'Reviewed and verified to meet accessibility requirements.', 'accessibility-checker' ),
33+
],
3034
'false_positive' => [
3135
'label' => __( 'False positive', 'accessibility-checker' ),
3236
'description' => __( 'The scanner flagged this, but it does not apply to this content.', 'accessibility-checker' ),
@@ -35,10 +39,6 @@ public static function get_reasons(): array {
3539
'label' => __( 'Remediated', 'accessibility-checker' ),
3640
'description' => __( 'The issue has been fixed, but the page has not been rescanned yet.', 'accessibility-checker' ),
3741
],
38-
'accessible' => [
39-
'label' => __( 'Confirmed accessible', 'accessibility-checker' ),
40-
'description' => __( 'Reviewed and verified to meet accessibility requirements.', 'accessibility-checker' ),
41-
],
4242
];
4343
}
4444

src/issueModal/components/DismissPanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { getDismissReasonOptions } from '../../sidebar/utils/dismissHelpers';
2929
*/
3030
const DismissPanel = ( { issue, isOpen, onToggle, onIgnore, onCloseModal, forceGlobal = false, isPro = typeof window !== 'undefined' && window.edac_editor_app?.pro === '1' } ) => {
3131
const [ comment, setComment ] = useState( issue?.ignre_comment ? decodeEntities( issue.ignre_comment ) : '' );
32-
const [ dismissReason, setDismissReason ] = useState( issue?.ignre_reason || 'false_positive' );
32+
const [ dismissReason, setDismissReason ] = useState( issue?.ignre_reason || 'accessible' );
3333
const [ isSubmitting, setIsSubmitting ] = useState( false );
3434
const [ error, setError ] = useState( null );
3535
const [ successNotice, setSuccessNotice ] = useState( null );

tests/jest/issueModal/DismissPanel.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,29 @@ jest.mock( '../../../src/issueModal/index', () => ( {
5050
} ) );
5151

5252
describe( 'DismissPanel', () => {
53+
test( 'defaults dismiss reason to confirmed accessible for new dismissals', async () => {
54+
const { toggleIssueDismiss } = require( '../../../src/issueModal/api' );
55+
const { container, unmount } = renderReact(
56+
<DismissPanel
57+
issue={ { id: 3, ignre: '0', ignre_global: 0 } }
58+
isOpen={ true }
59+
onToggle={ jest.fn() }
60+
onIgnore={ jest.fn() }
61+
onCloseModal={ jest.fn() }
62+
isPro={ false }
63+
/>,
64+
);
65+
66+
await act( async () => {
67+
container.querySelector( 'form' ).dispatchEvent(
68+
new Event( 'submit', { bubbles: true, cancelable: true } ),
69+
);
70+
} );
71+
expect( toggleIssueDismiss ).toHaveBeenCalledWith( 3, true, 'accessible', '', false );
72+
73+
unmount();
74+
} );
75+
5376
test( 'hides global dismiss controls for free users', () => {
5477
window.edac_editor_app.pro = '0';
5578

tests/jest/setupTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ beforeEach( () => {
1616
highlightNonce: 'test-highlight-nonce',
1717
canManageSettings: true,
1818
dismissReasons: {
19+
accessible: { label: 'Confirmed accessible', description: 'Reviewed and verified to meet accessibility requirements.' },
1920
false_positive: { label: 'False Positive', description: 'This issue does not apply to this content.' },
2021
remediated: { label: 'Remediated', description: 'This issue has been fixed.' },
21-
accessible: { label: 'Accessible', description: 'This content is accessible by other means.' },
2222
},
2323
};
2424
window.edac_editor_app = {

tests/jest/sharedComponents/dismissHelpers.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
*/
88

99
const FIXTURE_REASONS = {
10+
accessible: {
11+
label: 'Confirmed accessible',
12+
description: 'Reviewed and verified to meet accessibility requirements.',
13+
},
1014
false_positive: {
1115
label: 'False positive',
1216
description: 'This issue does not apply to this content.',
@@ -15,10 +19,6 @@ const FIXTURE_REASONS = {
1519
label: 'Remediated',
1620
description: 'This issue has been fixed.',
1721
},
18-
accessible: {
19-
label: 'Accessible',
20-
description: 'This content is accessible by other means.',
21-
},
2222
};
2323

2424
/**
@@ -83,9 +83,9 @@ describe( 'dismissHelpers', () => {
8383
const options = getDismissReasonOptions();
8484
const values = options.map( ( o ) => o.value );
8585

86+
expect( values[ 0 ] ).toBe( 'accessible' );
8687
expect( values ).toContain( 'false_positive' );
8788
expect( values ).toContain( 'remediated' );
88-
expect( values ).toContain( 'accessible' );
8989
} );
9090

9191
test( 'returns empty array when no dismiss reasons exist', () => {
@@ -99,7 +99,7 @@ describe( 'dismissHelpers', () => {
9999
const { getDismissReasonLabel } = loadHelpers( FIXTURE_REASONS );
100100
expect( getDismissReasonLabel( 'false_positive' ) ).toBe( 'False positive' );
101101
expect( getDismissReasonLabel( 'remediated' ) ).toBe( 'Remediated' );
102-
expect( getDismissReasonLabel( 'accessible' ) ).toBe( 'Accessible' );
102+
expect( getDismissReasonLabel( 'accessible' ) ).toBe( 'Confirmed accessible' );
103103
} );
104104

105105
test( 'returns empty string for an unknown reason value', () => {
@@ -116,6 +116,7 @@ describe( 'dismissHelpers', () => {
116116
describe( 'getDismissReasonDescription', () => {
117117
test( 'returns the description for a known reason value', () => {
118118
const { getDismissReasonDescription } = loadHelpers( FIXTURE_REASONS );
119+
expect( getDismissReasonDescription( 'accessible' ) ).toBe( 'Reviewed and verified to meet accessibility requirements.' );
119120
expect( getDismissReasonDescription( 'false_positive' ) ).toBe( 'This issue does not apply to this content.' );
120121
expect( getDismissReasonDescription( 'remediated' ) ).toBe( 'This issue has been fixed.' );
121122
} );
@@ -131,4 +132,3 @@ describe( 'dismissHelpers', () => {
131132
} );
132133
} );
133134
} );
134-

0 commit comments

Comments
 (0)