Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests. #361

Merged
merged 5 commits into from
Feb 23, 2022
Merged

Update tests. #361

merged 5 commits into from
Feb 23, 2022

Conversation

ADmad
Copy link
Member

@ADmad ADmad commented Feb 23, 2022

No description provided.

@codecov
Copy link

codecov bot commented Feb 23, 2022

Codecov Report

Merging #361 (15755de) into master (7dcf728) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #361      +/-   ##
============================================
- Coverage     99.25%   99.19%   -0.06%     
- Complexity      329      335       +6     
============================================
  Files            21       20       -1     
  Lines           934      869      -65     
============================================
- Hits            927      862      -65     
  Misses            7        7              
Impacted Files Coverage Δ
src/View/Helper/FlashHelper.php 100.00% <ø> (ø)
src/View/Helper/FormHelper.php 99.20% <100.00%> (-0.04%) ⬇️
src/View/Widget/InputgroupTrait.php 96.00% <0.00%> (-0.62%) ⬇️
src/Command/InstallCommand.php 98.46% <0.00%> (-0.04%) ⬇️
src/View/UIViewTrait.php 100.00% <0.00%> (ø)
src/View/Helper/HtmlHelper.php 100.00% <0.00%> (ø)
src/View/Widget/FileWidget.php 100.00% <0.00%> (ø)
src/Command/BootstrapCommand.php 100.00% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7dcf728...15755de. Read the comment docs.

@ADmad
Copy link
Member Author

ADmad commented Feb 23, 2022

@ndm2 What do you propose we do about the "prefer-lowest" job? It's not practical to have a separate set of expectations for Cake < 4.3 due to the addition of ARIA attributes. I don't want to update the core constraints in composer since the code actually works fine for lower versions of 4.x.

@ndm2
Copy link
Collaborator

ndm2 commented Feb 23, 2022

I'd say we inject the two attributes manually if they're not present. I did that for the BS5 version (aria-describedby can be omitted):

protected function _ariaOptions(string $fieldName, array $options): array
{
if (
$options['type'] === 'hidden' ||
(
isset($options['aria-required']) &&
isset($options['aria-describedby']) &&
isset($options['aria-invalid'])
)
) {
return $options;
}
$isError =
$options['error'] !== false &&
$this->isFieldError($fieldName);
// `aria-invalid` and `aria-required` are injected for backwards
// compatibility reasons, as support for this has only been
// introduced in the core form helper with CakePHP 4.3. This can
// be removed once the required minimum CakePHP version is bumped
// accordingly.
if (
$isError &&
!isset($options['aria-invalid'])
) {
$options['aria-invalid'] = 'true';
}
if (
$options['required'] &&
!isset($options['aria-required'])
) {
$options['aria-required'] = 'true';
}
if (isset($options['aria-describedby'])) {
return $options;
}
$describedByIds = [];
if ($isError) {
$describedByIds[] = $this->_domId($fieldName . '-error');
}
if ($options['help']) {
if (
is_array($options['help']) &&
isset($options['help']['id'])
) {
$descriptorId = $options['help']['id'];
} else {
$descriptorId = $this->_domId($fieldName . '-help');
}
$describedByIds[] = $descriptorId;
}
if ($describedByIds) {
$options['aria-describedby'] = $describedByIds;
}
return $options;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants