{% for link in links %}
-
{{ link.label }}
diff --git a/tests/behat/bootstrap/FeatureContext.php b/tests/behat/bootstrap/FeatureContext.php
index 4b96c2a1e..7b1dbb66e 100644
--- a/tests/behat/bootstrap/FeatureContext.php
+++ b/tests/behat/bootstrap/FeatureContext.php
@@ -294,6 +294,35 @@ public function shouldSeeImage(string $source): void
}
}
+ /**
+ * Échoue aussi si aucun lien ne correspond, pour ne pas passer à vide.
+ * exemple:
+ * all links with href containing "/joindin" should have rel containing "nofollow"
+ */
+ #[Then('/^all links with href containing "(?P(?:[^"]|\\")*)" should have rel containing "(?P(?:[^"]|\\")*)"$/')]
+ public function allLinksShouldHaveRel(string $href, string $rel): void
+ {
+ $links = $this->minkContext->getSession()->getPage()->findAll('css', sprintf('a[href*="%s"]', $href));
+
+ if ([] === $links) {
+ throw new ExpectationException(
+ sprintf('No link with href containing "%s" was found', $href),
+ $this->minkContext->getSession()->getDriver(),
+ );
+ }
+
+ foreach ($links as $link) {
+ $relTokens = preg_split('/\s+/', (string) $link->getAttribute('rel'), -1, PREG_SPLIT_NO_EMPTY);
+
+ if (!in_array($rel, $relTokens, true)) {
+ throw new ExpectationException(
+ sprintf('The link "%s" has rel "%s", which does not contain "%s"', $link->getAttribute('href'), $link->getAttribute('rel'), $rel),
+ $this->minkContext->getSession()->getDriver(),
+ );
+ }
+ }
+ }
+
#[Then('/^(?:|I )click on link with (class|id) "(?P(?:[^"]|\\")*)"$/')]
public function clickOnLink(string $type, string $text): void
{
diff --git a/tests/behat/features/PublicSite/Talks.feature b/tests/behat/features/PublicSite/Talks.feature
index db8a89bac..4432aa5ba 100644
--- a/tests/behat/features/PublicSite/Talks.feature
+++ b/tests/behat/features/PublicSite/Talks.feature
@@ -35,3 +35,17 @@ Feature: Site Public - Talks
When I go to "/talks/?q=&hPP=7&idx=afup_talks&p=0&fR[event.title][0]=AFUP Day 2019 Lyon&fR[speakers.label][0]=Un Speaker"
Then I should see "Les vidéos de Un Speaker"
And the response should contain ""
+
+ @reloadDbWithTestData
+ Scenario: Les liens vers joind.in d'un talk ne sont pas suivis par les robots
+ When I go to "/talks/1-jouons-tous-ensemble-a-un-petit-jeu"
+ Then I should see "Fiche joind.in"
+ And all links with href containing "/joindin" should have rel containing "nofollow"
+
+ Scenario: Le robots.txt interdit le crawl des redirections joind.in
+ When I go to "/robots.txt"
+ Then the response should contain the html
+ """
+ User-agent: *
+ Disallow: /talks/*/joindin
+ """