Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Comptoir du Libre v3 - Upcoming version
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Comptoir
Comptoir du Libre v3 - Upcoming version
Commits
d6acaf52
Commit
d6acaf52
authored
2 months ago
by
Fabrice Gangler
Browse files
Options
Downloads
Patches
Plain Diff
test: check footer links, in particular aria-current attribute
parent
7114d5ff
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
webapp/tests/Functional/TestHelperFooterTrait.php
+94
-0
94 additions, 0 deletions
webapp/tests/Functional/TestHelperFooterTrait.php
webapp/tests/Functional/TestHelperTrait.php
+7
-33
7 additions, 33 deletions
webapp/tests/Functional/TestHelperTrait.php
with
101 additions
and
33 deletions
webapp/tests/Functional/TestHelperFooterTrait.php
0 → 100644
+
94
−
0
View file @
d6acaf52
<?php
/*
* This file is part of the Comptoir-du-Libre software.
* <https://gitlab.adullact.net/Comptoir/comptoir-du-libre>
*
* Copyright (c) ADULLACT <https://adullact.org>
* Association des Développeurs et Utilisateurs de Logiciels Libres
* pour les Administrations et les Collectivités Territoriales
*
* Comptoir-du-Libre is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* You should have received a copy of the GNU Affero General Public License
* along with this software. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>.
*/
declare
(
strict_types
=
1
);
namespace
App\Tests\Functional
;
use
App\Tests\Functional\TestHelperTrait
;
use
Symfony\Component\DomCrawler\Crawler
;
use
function
PHPUnit\Framework\isNull
;
trait
TestHelperFooterTrait
{
use
TestHelperTrait
;
/**
* @param Crawler $crawler
* @param string $locale
* @param string|null $currentPageUrl default is NULL
* @return void
*/
public
function
checkFooter
(
Crawler
$crawler
,
string
$locale
=
'en'
,
null
|
string
$currentPageUrl
=
null
,
):
void
{
$footerMainNavLinks
=
[
'/en/'
=>
'Home'
,
'/en/pages/contact'
=>
'Contact'
,
'/en/pages/about'
=>
'About'
,
'/en/pages/legal'
=>
'Legal'
,
'/en/pages/accessibility'
=>
'Accessibility'
,
'/en/pages/opendata'
=>
'Open Data'
,
];
if
(
$locale
===
'fr'
)
{
$footerMainNavLinks
=
[
'/fr/'
=>
'Accueil'
,
'/fr/pages/contact'
=>
'Contact'
,
'/fr/pages/about'
=>
'À Propos'
,
'/fr/pages/legal'
=>
'Mentions légales'
,
'/fr/pages/accessibility'
=>
'Accessibilité : non conforme'
,
'/fr/pages/opendata'
=>
'Données ouvertes'
,
];
}
// Check the number of items in footer main nav
$footerMainNavCssSelector
=
"footer#page_footer nav > ul"
;
$this
->
assertEquals
(
expected
:
count
(
$footerMainNavLinks
),
actual
:
$crawler
->
filter
(
"
$footerMainNavCssSelector
> li"
)
->
count
(),
message
:
'Number of links in footer main nav is different from expected.'
);
// Check each links in footer main nav
foreach
(
$footerMainNavLinks
as
$url
=>
$linkText
)
{
$linkSelector
=
"
$footerMainNavCssSelector
a[href='
$url
']"
;
$this
->
checkAttribute
(
crawler
:
$crawler
,
cssFilter
:
"
$linkSelector
"
,
attributesExpected
:
[
'_text'
=>
"
$linkText
"
,
'href'
=>
"
$url
"
],
);
if
(
$currentPageUrl
===
$url
)
{
$this
->
assertEquals
(
expected
:
'page'
,
actual
:
$crawler
->
filter
(
"
$linkSelector
"
)
->
attr
(
'aria-current'
),
message
:
"Footer: missing [ aria-current ] attribut"
.
"
\n
- current page:
$currentPageUrl
\n
- footer link:
$url
-->
$linkText
"
,
);
}
else
{
$this
->
assertNull
(
actual
:
$crawler
->
filter
(
"
$linkSelector
"
)
->
attr
(
'aria-current'
),
message
:
"Footer: not allowed [ aria-current ] attribut"
.
"
\n
- current page:
$currentPageUrl
\n
- footer link:
$url
-->
$linkText
"
,
);
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/tests/Functional/TestHelperTrait.php
+
7
−
33
View file @
d6acaf52
...
...
@@ -124,37 +124,6 @@ public function checkRedirectionToNewUrl(
$this
->
assertResponseStatusCodeSame
(
Response
::
HTTP_OK
);
// HTTP status code = 200
}
/**
* @todo FIXME
*/
public
function
checkFooter
(
Crawler
$crawler
,
bool
$displayVersion
=
false
):
void
{
$version
=
''
;
if
(
$displayVersion
===
true
)
{
$version
=
' major.minor.patch'
;
}
$footerExpectedLink1
=
[
'_name'
=>
'a'
,
'_text'
=>
"Comptoir
$version
"
,
'href'
=>
'https://gitlab.adullact.net/Comptoir/comptoir-du-libre'
];
$footerExpectedLink2
=
[
'_name'
=>
'a'
,
'_text'
=>
'Adullact'
,
'href'
=>
'https://adullact.org'
];
$footerExpectedLink3
=
[
'_name'
=>
'a'
,
'_text'
=>
'GNU AGPL v3'
,
'href'
=>
'https://www.gnu.org/licenses/agpl-3.0.html'
];
// $this->checkAttribute($crawler, '#footer_link-to-repository', $footerExpectedLink1);
// $this->checkAttribute($crawler, '#footer_link-to-creator-website', $footerExpectedLink2);
// $this->checkAttribute($crawler, '#footer_link-to-license', $footerExpectedLink3);
dump
(
"------------------> TODO fix checkFooter()"
);
}
/**
* @todo refactor
* @group refactor
...
...
@@ -348,6 +317,9 @@ public function commonCheckerUserCanLoginV2(
$this
->
assertSelectorTextSame
(
'.connected_user_email'
,
"
$mail
"
);
}
/**
* @todo no used yet
*/
public
function
commonCheckerUserCanLogout
(
string
$mail
,
string
$locale
=
'en'
,
...
...
@@ -364,11 +336,13 @@ public function commonCheckerUserCanLogout(
$this
->
assertResponseHasHeader
(
"Location"
);
$this
->
assertResponseHeaderSame
(
"Location"
,
"http://localhost/
$locale
/"
);
$crawler
=
$kernelBrowser
->
request
(
'GET'
,
'/'
);
$crawler
=
$kernelBrowser
->
request
(
'GET'
,
"/
$locale
/"
);
$this
->
assertResponseStatusCodeSame
(
Response
::
HTTP_OK
);
// HTTP status code = 200
$this
->
assertSelectorNotExists
(
'.connected_user_email'
);
$this
->
assertSelectorTextNotContains
(
'body'
,
"
$mail
"
);
$this
->
checkFooter
(
$crawler
,
false
);
// HTML content checks footer
$this
->
checkFooter
(
crawler
:
$crawler
,
locale
:
$locale
,
currentPageUrl
:
"/
$locale
/"
);
}
/// ///////////////////////////////////////////////////////////////////////////////////////////
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment