Skip to content

Get cypress passing, improve slidein accessibility#2056

Merged
Crabcyborg merged 2 commits into
masterfrom
get_cypress_passing
Oct 16, 2024
Merged

Get cypress passing, improve slidein accessibility#2056
Crabcyborg merged 2 commits into
masterfrom
get_cypress_passing

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Oct 16, 2024

  • Path checks in applications tests have been modified to remove the formidable-forms slug from the check. In many cases, the formidable name is used instead.
  • The alert role has been added to the slidein message to improve accessibility. A new slidein message appearing when running e2e tests is catching an accessibility issue with the slidein popup that we don't have in our exception list.
  • experimentalRunAllSpecs is now set. This allows you to run all specs when using Chrome.

…top including formidable-forms file path in URL checks
…t value is not a match, add a role to the slidein to improve accessibility
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 16, 2024

Walkthrough

The pull request introduces several updates across multiple files. The FrmAppController class now includes a new method for handling Black Friday redirection and enhances script dependency management. The FrmOnboardingWizardController class modifies the onboarding process during plugin activation. Updates to the cypress.config.js file enable an experimental feature for running all specs in one go. Accessibility improvements are made in the s11-floating-links.js file, and Cypress tests are adjusted to reflect changes in image source paths for the Applications page.

Changes

File Change Summary
classes/controllers/FrmAppController.php Added method redirect_blackfriday(). Updated enqueue_floating_links() to include dependency on formidable_admin.
classes/controllers/FrmOnboardingWizardController.php Removed line in do_admin_redirects() to display onboarding wizard regardless of transient values.
cypress.config.js Added property experimentalRunAllSpecs: true in the e2e configuration object.
js/packages/floating-links/s11-floating-links.js Updated getInboxSlideIn() to set role attribute of slideIn element to 'alert'.
tests/cypress/e2e/Applications/validateApplicationsPage.cy.js Updated image source paths and search functionality in tests for Applications page.

Possibly related PRs

  • Pro issue 5404 / Black friday #2020: This PR introduces a new method redirect_blackfriday in the FrmAppController class, which is directly related to the new redirect_blackfriday method added in the main PR, indicating a shared focus on Black Friday functionality.
  • Redirect immediately to onboarding when activating a single plugin #2046: Although primarily focused on onboarding redirection, this PR also modifies the FrmOnboardingWizardController, which may have indirect implications for user navigation and redirection features, aligning with the new redirection functionality introduced in the main PR.

Suggested reviewers

  • garretlaxton
  • shervElmi

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
tests/cypress/e2e/Applications/validateApplicationsPage.cy.js (1)

Line range hint 1-357: Summary: Image path updates and format consistency

The changes in this file primarily involve updating image source paths for various application templates. The new paths follow a consistent pattern: '/images/applications/thumbnails/{template-name}.{extension}'. This update improves the organization and clarity of the image references in the tests.

However, there's an inconsistency in the image formats used across different templates. Some use .png while others use .webp. It's recommended to review this inconsistency and consider standardizing the image format across all templates, unless there's a specific reason for using different formats.

Action items:

  1. Verify that all updated image paths are correct and the images exist in the specified locations.
  2. Review the use of .png vs .webp formats and consider standardizing if possible.
  3. Update any documentation or guidelines related to adding new application templates to reflect the new image path structure and preferred format.
classes/controllers/FrmAppController.php (3)

Line range hint 1362-1395: LGTM! Consider adding version comparison for Pro compatibility.

The enqueue_floating_links method is well-implemented, following WordPress best practices for enqueueing scripts and styles. It includes proper checks, internationalization support, and a hook for Pro version compatibility.

Consider adding a version comparison check for the Pro compatibility hook:

if ( defined('FRM_PRO_VERSION') && version_compare( FRM_PRO_VERSION, '5.0', '>=' ) ) {
    do_action( 'frm_enqueue_floating_links' );
}

This ensures compatibility with older Pro versions that might not support this hook.


Line range hint 1397-1453: Effective, but consider using WordPress filters for better compatibility.

The filter_admin_notices method successfully removes third-party admin notices on Formidable pages while preserving Formidable's own notices. However, directly modifying the $wp_filter global can potentially lead to conflicts or unexpected behavior.

Consider using WordPress's remove_all_actions() function instead of directly modifying $wp_filter. This approach is more aligned with WordPress standards and less likely to cause conflicts:

public static function filter_admin_notices() {
    if ( ! self::in_our_pages() ) {
        return;
    }

    $actions = array(
        'admin_notices',
        'network_admin_notices',
        'user_admin_notices',
        'all_admin_notices',
    );

    foreach ( $actions as $action ) {
        remove_all_actions( $action );
        add_action( $action, array( __CLASS__, 'show_formidable_notices' ) );
    }
}

public static function show_formidable_notices() {
    do_action( 'frm_admin_notices' );
}

This approach removes all notices and then adds back only Formidable notices through a custom action.


Line range hint 1455-1470: LGTM! Consider adding security checks and making the method more flexible.

The redirect_blackfriday method effectively redirects users to the Black Friday sales page. It's good that it uses FrmAppHelper::admin_upgrade_link for URL generation and tracking.

Consider the following improvements:

  1. Add a nonce check for security:

    check_admin_referer( 'frm_black_friday_redirect' );
  2. Make the method more flexible by accepting parameters:

    public static function redirect_blackfriday( $campaign = 'black-friday', $medium = 'black-friday-submenu' ) {
        check_admin_referer( 'frm_black_friday_redirect' );
        $content = self::is_cyber_monday() ? 'cyber-monday-submenu' : $campaign . '-submenu';
        wp_redirect(
            FrmAppHelper::admin_upgrade_link(
                array(
                    'medium'  => $medium,
                    'content' => $content,
                ),
                $campaign
            )
        );
        die();
    }

This allows for easier reuse and testing of the method with different campaigns.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d2cba79 and 2100c9b.

📒 Files selected for processing (5)
  • classes/controllers/FrmAppController.php (1 hunks)
  • classes/controllers/FrmOnboardingWizardController.php (0 hunks)
  • cypress.config.js (1 hunks)
  • js/packages/floating-links/s11-floating-links.js (1 hunks)
  • tests/cypress/e2e/Applications/validateApplicationsPage.cy.js (21 hunks)
💤 Files with no reviewable changes (1)
  • classes/controllers/FrmOnboardingWizardController.php
🧰 Additional context used
🔇 Additional comments (19)
cypress.config.js (1)

18-18: Verify the impact of enabling experimentalRunAllSpecs

The addition of experimentalRunAllSpecs: true enables an experimental Cypress feature to run all specs in a single execution. While this can potentially speed up overall test execution, it's important to consider the following:

  1. As an experimental feature, it may introduce unexpected behavior or instability.
  2. Running all specs at once could impact performance and resource usage, especially for larger test suites.
  3. This change might affect how developers run and debug tests locally.
  4. It could alter the execution pattern in CI/CD pipelines.

To ensure this change doesn't negatively impact your testing process:

  1. Run the following command to check if there are any warnings or deprecation notices related to this feature:

  2. Compare the execution time and resource usage:

  3. Check for any changes in test behavior or stability:

If these checks pass without issues, the change can be considered safe to merge.

js/packages/floating-links/s11-floating-links.js (1)

116-116: Excellent accessibility improvement!

Adding the 'alert' role to the slide-in element enhances the accessibility of the component. This change ensures that users relying on assistive technologies will be immediately notified of important, time-sensitive information when the slide-in appears.

This modification:

  1. Improves the user experience for those using screen readers.
  2. Enhances compliance with accessibility guidelines.
  3. Provides clearer semantic meaning to the element's purpose.

Great job on prioritizing accessibility in your code!

tests/cypress/e2e/Applications/validateApplicationsPage.cy.js (16)

42-42: LGTM: Updated image path for Business Directory template

The image source path has been updated to a more concise and consistent format. This change aligns with the overall update to image paths in the test file.


54-54: LGTM: Updated placeholder image path

The placeholder image path has been updated to align with the new directory structure. This change is consistent with the overall update to image paths in the test file.


87-87: LGTM: Updated image path for Business Hours template

The image source path for the Business Hours template has been updated to follow the new consistent pattern. This change aligns with the overall update to image paths in the test file.


111-111: LGTM: Updated image path for Charity Tracker template

The image source path for the Charity Tracker template has been updated to follow the new consistent pattern. The use of the .webp format is consistent with the Certificate template.


123-123: LGTM: Updated image path for Contract Agreement template

The image source path for the Contract Agreement template has been updated to follow the new consistent pattern. The use of the .webp format is consistent with the recent template updates.


147-147: LGTM: Updated image path for Freelance Invoice Generator template

The image source path for the Freelance Invoice Generator template has been updated to follow the new consistent pattern. The use of the .webp format is consistent with most recent template updates.


159-159: LGTM: Updated image path for Invoice PDF template

The image source path for the Invoice PDF template has been updated to follow the new consistent pattern. The use of the .webp format is consistent with most recent template updates.


170-170: LGTM: Updated image path for Letter of Recommendation template

The image source path for the Letter of Recommendation template has been updated to follow the new consistent pattern. The use of the .webp format is consistent with most recent template updates.


182-182: LGTM: Consistent update to modal placeholder image path

The image source path for the modal placeholder has been updated to '/images/applications/placeholder.png'. This change is consistent with the previous update to the modal placeholder image path (line 54), maintaining consistency across all modal placeholder image assertions.


215-215: LGTM: Updated image path for Link in Bio Instagram Page template

The image source path for the Link in Bio Instagram Page template has been updated to follow the new consistent pattern. The use of the .webp format is consistent with most recent template updates.


227-227: LGTM: Updated image path for Member Directory template

The image source path for the Member Directory template has been updated to follow the new consistent pattern. The use of the .webp format is consistent with most recent template updates.


251-251: LGTM: Updated image path for Real Estate Listing template

The image source path for the Real Estate Listing template has been updated to follow the new consistent pattern. The use of the .png format is consistent with the previous template (Product Review and Purchase). However, it's worth noting that this differs from the .webp format used in most other recent template updates. Ensure that this is intentional and aligns with the overall image format strategy.


239-239: LGTM: Updated image path for Product Review and Purchase template

The image source path for the Product Review and Purchase template has been updated to follow the new consistent pattern. However, note that this image uses the .png format, which differs from the .webp format used in most recent template updates. Ensure that this difference is intentional and consistent with the overall image format strategy.

#!/bin/bash
# Verify that the Product Review and Purchase template image exists and is in .png format
file_path="/images/applications/thumbnails/product-review.png"
if [ -f "$file_path" ]; then
    file_type=$(file -b --mime-type "$file_path")
    if [ "$file_type" == "image/png" ]; then
        echo "Product Review and Purchase template image exists and is in .png format"
    else
        echo "Product Review and Purchase template image exists but is not in .png format"
    fi
else
    echo "Product Review and Purchase template image does not exist at the specified path"
fi

263-263: LGTM: Updated image paths for multiple templates

The image source paths for Restaurant Menu, Team Directory, Testimonials, Business Directory, and Business Hours templates have been updated to follow the new consistent pattern. The modal placeholder image path has also been updated consistently.

However, there's an inconsistency in the image formats used:

  • Restaurant Menu, Team Directory, Business Directory, and Business Hours use .png
  • Testimonials uses .webp

Consider standardizing the image format across all templates for consistency, unless there's a specific reason for using different formats.

#!/bin/bash
# Check for consistency in image formats across all templates
echo "Image format distribution in /images/applications/thumbnails/:"
find /images/applications/thumbnails -type f | sed 's/.*\.//' | sort | uniq -c | sort -rn

# List any templates that don't have both .png and .webp versions
echo "\nTemplates missing either .png or .webp version:"
for template in $(find /images/applications/thumbnails -type f | sed 's/\.[^.]*$//' | sort | uniq); do
    png_exists=$(find "${template}.png" -maxdepth 0 -type f 2>/dev/null)
    webp_exists=$(find "${template}.webp" -maxdepth 0 -type f 2>/dev/null)
    if [ -z "$png_exists" ] || [ -z "$webp_exists" ]; then
        echo "$template"
    fi
done

Also applies to: 275-275, 286-286, 299-299, 341-341, 351-351


135-135: LGTM: Updated image path for FAQ template

The image source path for the FAQ template has been updated to follow the new consistent pattern. However, there are two points to note:

  1. This image uses the .png format, which differs from the .webp format used in recent template updates.
  2. The filename includes "wordpress", which is unique compared to other templates.

Ensure that these differences are intentional and consistent with the overall image naming and format strategy.

✅ Verification successful

Verified: Image path and format are correct

  • The FAQ template image exists at images/applications/thumbnails/faq-template-wordpress.png and is in .png format.
  • The thumbnails directory contains 7 .png files and 9 .webp files, maintaining consistency in image formats.

No issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that the FAQ template image exists and check its format
file_path="/images/applications/thumbnails/faq-template-wordpress.png"
if [ -f "$file_path" ]; then
    file_type=$(file -b --mime-type "$file_path")
    if [ "$file_type" == "image/png" ]; then
        echo "FAQ template image exists and is in .png format"
    else
        echo "FAQ template image exists but is not in .png format"
    fi
else
    echo "FAQ template image does not exist at the specified path"
fi

# Check for consistency in image formats
png_count=$(find /images/applications/thumbnails -name "*.png" | wc -l)
webp_count=$(find /images/applications/thumbnails -name "*.webp" | wc -l)
echo "Number of .png files in thumbnails directory: $png_count"
echo "Number of .webp files in thumbnails directory: $webp_count"

Length of output: 650


Script:

#!/bin/bash
# Search for the FAQ template image in the repository
fd "faq-template-wordpress\.png" --type f

Length of output: 101


Script:

#!/bin/bash
# Check number of .png and .webp files in thumbnails directory
thumbnail_dir="images/applications/thumbnails"
png_count=$(find "$thumbnail_dir" -type f -name "*.png" | wc -l)
webp_count=$(find "$thumbnail_dir" -type f -name "*.webp" | wc -l)
echo "Number of .png files in thumbnails directory: $png_count"
echo "Number of .webp files in thumbnails directory: $webp_count"

Length of output: 428


99-99: LGTM: Updated image path for Certificate template

The image source path for the Certificate template has been updated to follow the new consistent pattern. Note that this image uses the .webp format, which differs from the .png format used in some other templates. Ensure that this is intentional and that the correct image format is being used.

classes/controllers/FrmAppController.php (1)

Line range hint 225-227: LGTM! Good optimization for floating links.

The conditional call to enqueue_floating_links using the should_show_floating_links method is a good optimization. This ensures that floating links assets are only loaded when necessary, potentially improving page load times on pages where they're not needed.

@Crabcyborg Crabcyborg added this to the 6.16 milestone Oct 16, 2024
@Crabcyborg Crabcyborg merged commit 907a004 into master Oct 16, 2024
@Crabcyborg Crabcyborg deleted the get_cypress_passing branch October 16, 2024 13:59
@Crabcyborg Crabcyborg changed the title Get cypress passing Get cypress passing, improve slidein accessibility Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant