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

Updated test data to cover scenario #6585

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$html_links_without_duplicate = '<!DOCTYPE html><html class="no-js" lang="en-US"><head><title></title><link href="https://fonts.gstatic.com" crossorigin rel="preconnect" /><link rel="stylesheet" id="wp-block-library-css" href="https://example.org/wp-includes/css/dist/block-library/style.min.css?ver=6.4.3" media="all" /></head><body><button data-link="https://example.org/hello-world">Click Here</button><a href="https://example.org/hello-world">Hello World</a><a href="https://example.org/another-day">Another Day</a><a href="https://example.org/rich-dad-poor-dad">Rich Dad Poor Dad</a><a href="https://example.org/hello-world">Hello World</a><a href="https://example.org/another-day">Another Day</a><a href="https://example.org/rich-dad-poor-dad">Rich Dad Poor Dad</a><a href="https://example.org/rebecca-brown-he-came-to-set-the-captives-free">Buy (He came to set the captives free) - Rebecca Brown</a></body></html>';
$html_links_with_relative_url = '<!DOCTYPE html><html class="no-js" lang="en-US"><head><title></title><link href="https://fonts.gstatic.com" crossorigin rel="preconnect" /><link rel="stylesheet" id="wp-block-library-css" href="https://example.org/wp-includes/css/dist/block-library/style.min.css?ver=6.4.3" media="all" /></head><body><button data-link="https://example.org/hello-world">Click Here</button><a href="https://example.org/hello-world">Hello World</a><a href="https://example.org/another-day">Another Day</a><a href="/rich-dad-poor-dad">Rich Dad Poor Dad</a><a href="/rebecca-brown-he-came-to-set-the-captives-free">Buy (He came to set the captives free) - Rebecca Brown</a></body></html>';
$html_with_ten_links_and_home = '<!DOCTYPE html><html class="no-js" lang="en-US"><head><title></title><link href="https://fonts.gstatic.com" crossorigin="preconnect"/><link rel="stylesheet" id="wp-block-library-css" href="https://example.org/wp-includes/css/dist/block-library/style.min.css?ver=6.4.3" media="all"/></head><body><button data-link="https://example.org/hello-world">Click Here</button><a href="https://example.org/hello-world-2">Hello World 2</a><a href="https://example.org/hello-world-3">Hello World 3</a><a href="https://example.org/hello-world-4">Hello World 4</a><a href="https://example.org/hello-world-5">Hello World 5</a><a href="https://example.org/hello-world-6">Hello World 6</a><a href="https://example.org/hello-world-7">Hello World 7</a><a href="https://example.org/hello-world-8">Hello World 8</a><a href="https://example.org/hello-world-9">Hello World 9</a><a href="https://example.org/rich-dad-poor-dad">Rich Dad Poor Dad</a><a href="https://example.org/rebecca-brown-he-came-to-set-the-captives-free">Buy (He came to set the captives free) - Rebecca Brown</a><a href="https://example.org">Home</a></body></html>';
$html_with_external_links_before_internal = '<!DOCTYPE html><html class="no-js" lang="en-US"><head><title></title><link href="https://fonts.gstatic.com" crossorigin="preconnect"><link rel="stylesheet" id="wp-block-library-css" href="https://example.org/wp-includes/css/dist/block-library/style.min.css?ver=6.4.3" media="all"></head><body><ul><li><a href="/delay-js-script-add-to-any">Link internal relative 1/1</a></li><li><a href="https://beautifier.io/">Link external 1//2</a></li><li><a href="https://translate.google.com/">Link external 2/3</a></li><li><a href="https://www.timeanddate.com/">Link external 3/4</a></li><li><a href="https://loremipsum.io/">Link external 4/5</a></li><li><a href="https://wordpress.org/plugins/wp-dummy-content-generator/">Link external 5/6</a></li><li><a href="https://validator.w3.org/#validate_by_uri">Link external 6/7</a></li><li><a href="">Link missing 8</a></li><li><a href="/accordion-toggle">Link internal relative 2</a></li><li><a href="https://example.org/cover-galleries">Link internal absolute 1/9</a></li><li><a href="https://example.org/countdown-timer">Link internal absolute 2/10</a></li><li><a href="https://example.org/cover-galleries">Link internal absolute 3/11</a></li><li><a href="https://example.org/cover-galleries">Link internal absolute 4/12</a></li><li><a href="https://example.org/cover-galleries">Link internal absolute 5/13</a></li><li><a href="https://example.org/cover-galleries">Link internal absolute 6/14</a></li><li><a href="https://example.org/cover-galleries">Link internal absolute 7/15</a></li><li><a href="https://example.org/cover-galleries">Link internal absolute 8/16</a></li><li><a href="https://example.org/cover-galleries">Link internal absolute 9/17</a></li><li><a href="https://example.org/cover-galleries">Link internal absolute 10/18</a></li><li><a href="https://example.org/cover-galleries-2">Link internal absolute 11/19</a></li><li><a href="https://example.org/cover-galleries-3">Link internal absolute 12/20</a></li><li><a href="https://example.org/cover-galleries-4">Link internal absolute 13/21</a></li><li><a href="https://example.org/cover-galleries-5">Link internal absolute 14/22</a></li><li><a href="https://example.org/cover-galleries-6">Link internal absolute 15/23</a></li><li><a href="https://example.org/cover-galleries-7">Link internal absolute 16/24</a></li></ul></body></html>';

return [
'shouldReturnEmptyWhenLicenseExpired' => [
Expand Down Expand Up @@ -213,4 +214,33 @@
'https://example.org',
],
],
];
'shouldReturnTenLinksWithExternalLinksBeforeInternal' => [
'config' => [
'license_expired' => false,
'headers' => [
'user-agent' => 'WP Rocket/Pre-fetch Home Links',
'timeout' => 60,
],
'found_link' => true,
'response' => [
'body' => $html_with_external_links_before_internal,
'response' => [
'code' => 200,
],
],
],
'expected' => [
'https://example.org/delay-js-script-add-to-any',
'https://example.org/accordion-toggle',
'https://example.org/cover-galleries',
'https://example.org/countdown-timer',
'https://example.org/cover-galleries-2',
'https://example.org/cover-galleries-3',
'https://example.org/cover-galleries-4',
'https://example.org/cover-galleries-5',
'https://example.org/cover-galleries-6',
'https://example.org/cover-galleries-7',
'https://example.org',
],
],
];
Loading