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

[WIP] Ptitloup/add selenium test #955

Draft
wants to merge 58 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b7f0719
add selenium test in pod main app, add selenium, geckodriver and fire…
ptitloup Sep 20, 2023
3ecb4e1
rename selenium integration test to not run it with other tests
ptitloup Sep 20, 2023
7083b9e
add integration test in pod workflow action
ptitloup Sep 21, 2023
676f2cf
try : add comment if accessibilty is ok
ptitloup Sep 21, 2023
3631e52
try : echo pa11y
ptitloup Sep 21, 2023
05ef9e2
try : pa11y no error
ptitloup Sep 21, 2023
192fd56
try : add permissions
ptitloup Sep 21, 2023
ac6877a
try : test comment
ptitloup Sep 21, 2023
f08759c
classic usage of actions comment
ptitloup Sep 21, 2023
cdd5afe
classic usage of actions comment - add permissions
ptitloup Sep 21, 2023
d9d9407
classic usage of actions comment - add GITHUB TOKEN
ptitloup Sep 21, 2023
635cf3b
add permissions and test issues
ptitloup Sep 21, 2023
1872b38
change order
ptitloup Sep 21, 2023
4ad22b3
try curl
ptitloup Sep 21, 2023
6a3c128
try script
ptitloup Sep 21, 2023
b8a6506
try script with issue
ptitloup Sep 21, 2023
1f89280
try script with issue and read permissions
ptitloup Sep 21, 2023
822516e
try another use curl
ptitloup Sep 21, 2023
101f4de
try another use curl 2
ptitloup Sep 21, 2023
2576eb5
pull request target
ptitloup Sep 21, 2023
b794c66
pull request target 2
ptitloup Sep 21, 2023
13edd02
pull request target add type and branche
ptitloup Sep 21, 2023
32d88c2
pull request target remove type
ptitloup Sep 21, 2023
4655644
pull request target star
ptitloup Sep 21, 2023
780a19a
pull request target another try
ptitloup Sep 21, 2023
bcbd751
test pull-request-target-branch-action
ptitloup Sep 21, 2023
4c07fd6
test all types
ptitloup Sep 21, 2023
36f00d7
remove pull_request_targat
ptitloup Sep 21, 2023
ee39dd3
little test
ptitloup Sep 22, 2023
7feb000
add integration test in pod workflow - remove add comment
ptitloup Sep 22, 2023
1750786
add python 3.8 and 3.10 in matrix test
ptitloup Sep 22, 2023
ed79b40
add directory to store side selenium. rename test selenium suite and …
ptitloup Sep 25, 2023
5e47555
Implement selenium integration tests
AymericJak Oct 4, 2023
f86d25c
Fix conflicts
AymericJak Oct 4, 2023
826f14b
Add USE_DEBUG_TOOLBAR parameter
AymericJak Oct 5, 2023
aadaca6
Add automatic compilation when merging
AymericJak Oct 5, 2023
5eb3861
Add custom commands
AymericJak Oct 6, 2023
0dc7a7c
Simplify function run()
AymericJak Oct 6, 2023
d110424
Add initial datas
AymericJak Oct 6, 2023
23389a5
Add documentation
AymericJak Oct 6, 2023
81a134e
Improve code
AymericJak Oct 6, 2023
5aff4ed
Styling & Linting
AymericJak Oct 6, 2023
db414c3
Fix conflicts and change import path of override_settings
AymericJak Oct 10, 2023
fc58774
Rework SeleniumTestCase and it's execution
AymericJak Oct 12, 2023
87aadde
Test tearDownClass
AymericJak Oct 12, 2023
65487d5
Change suite_url
AymericJak Oct 12, 2023
ff0a6a3
Add connexion test and improve code
AymericJak Oct 12, 2023
441e9b3
Add order for tests
AymericJak Oct 13, 2023
209520e
update branch
ptitloup Oct 25, 2023
c9d1f05
Fix conflicts
AymericJak Nov 2, 2023
7d889d9
Add pause function
AymericJak Nov 2, 2023
d4b1311
Improve gitignore
AymericJak Nov 2, 2023
13e83ea
Merge branch 'ptitloup/add_selenium_test' of https://github.com/ptitl…
ptitloup Nov 7, 2023
8cdddd5
fix click and clear for simulate typing text function
ptitloup Nov 7, 2023
f8c8bb5
Merge branch 'develop' of https://github.com/EsupPortail/Esup-Pod int…
ptitloup Nov 7, 2023
a8c4494
add side for subtitles and fix load web vtt from old caption
ptitloup Nov 7, 2023
3f57994
workon selenium side - add simple side and staff side.
ptitloup Nov 9, 2023
8a14fef
workon selenium python test instead of side selenium files
ptitloup Nov 17, 2023
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
14 changes: 14 additions & 0 deletions .github/workflows/code_formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ jobs:
run: |
git commit -am "Auto-update configuration files"
git push

# Compile lang files
- name: Compile lang files in fr and nl
run: python manage.py compilemessages -l fr -l nl
AymericJak marked this conversation as resolved.
Show resolved Hide resolved

- name: Check for modified files
id: compilation-git-check
AymericJak marked this conversation as resolved.
Show resolved Hide resolved
run: echo modified=$(if git diff --quiet; then echo "false"; else echo "true"; fi) >> $GITHUB_OUTPUT

- name: Push lang compilation changes
if: steps.compilation-git-check.outputs.modified == 'true'
run: |
git commit -am "Compile lang files"
git push
35 changes: 19 additions & 16 deletions .github/workflows/pod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ on:
pull_request:
branches: ["*"]

permissions:
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest

permissions: write-all
strategy:
max-parallel: 4
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9'] # ['3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -74,6 +77,20 @@ jobs:
run: |
coverage run --append --source='.' manage.py test -v 3 --settings=pod.main.test_settings

- name: Add Gecko driver
if: matrix.python-version == '3.9'
uses: browser-actions/setup-geckodriver@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Run Integration Tests
if: matrix.python-version == '3.9'
run: |
export DISPLAY=:99
geckodriver &
Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
python manage.py test -v 3 --settings=pod.main.test_settings pod.main.integration_tests.selenium_pod_integration_tests

## Start Accessibility tests with pa11y ##

- name: Install pa11y-ci dependencies.
Expand Down Expand Up @@ -106,20 +123,6 @@ jobs:
with:
path: ./pa11y_output.txt

- name: Comment on pull request.
if: contains(steps.pa11y_output.outputs.content, 'Errors in http://')
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: '<details><summary>Pa11y testing results</summary>


```

${{ steps.pa11y_output.outputs.content }}```


</details>'
- name: Check for pa11y failures.
if: contains(steps.pa11y_output.outputs.content, 'Errors in http://')
run: |
Expand Down
11 changes: 11 additions & 0 deletions dockerfile-dev-with-volumes/pod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ RUN apt-get clean && apt-get update \
ffmpegthumbnailer \
imagemagick

RUN apt-get install -y firefox-esr xvfb

# Download, unzip, and install geckodriver
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz
RUN tar -zxf geckodriver-v0.33.0-linux64.tar.gz -C /usr/local/bin
RUN chmod +x /usr/local/bin/geckodriver

# Set display port and dbus env to avoid hanging
ENV DISPLAY=:99
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null

Comment on lines +29 to +39
Copy link
Contributor

Choose a reason for hiding this comment

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

Je suggère cette approche pour gérer Selenium avec une image docker.
https://github.com/SeleniumHQ/docker-selenium

# https://github.com/SeleniumHQ/docker-selenium/blob/trunk/docker-compose-v3.yml
selenium-chrome:
  image: selenium/standalone-chrome:116.0-chromedriver-116.0
  container_name: selenium-chrome
  volumes:
    - /dev/shm:/dev/shm
  network_mode: host

Quelques avantages (permet de):

  • Alleger un peu l'image de l'app.
  • Assez facilement gérer la compatibilité entre les versions geckodriver et navigateur (Chrome,Firefox etc...) puisqu'il utilise le package webdriver-manager pour gérer tout ca (voir https://pypi.org/project/webdriver-manager/)
  • et enfin pouvoir (si on le souhaite) rajouter, facilement, differents navigateurs pour nos tests fronts

Désavantage:

  • Les tests depuis un container docker aucun soucis mais depuis la machine locale(django) + containers docker(bdd, redis, etc...), on est naturellement amené à utilisé l'options network_mode: host mais cette option n'est pas bien supportée sur Windows et Mac (voir: https://docs.docker.com/network/drivers/host/)

image

Issue: docker/roadmap#238
Roadmap State(Considering): https://github.com/docker/roadmap/projects/1#card-85911349

Il y a, cependant, des solutions de contournement, que je n'ai pas explorées, exemple pour Mac: https://github.com/chipmk/docker-mac-net-connect

WORKDIR /usr/src/app

COPY ./requirements.txt .
Expand Down
1 change: 1 addition & 0 deletions dockerfile-dev-with-volumes/pod/my-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ fi
# Le serveur de développement permet de tester vos futures modifications facilement.
# N'hésitez pas à lancer le serveur de développement pour vérifier vos modifications au fur et à mesure.
# À ce niveau, vous devriez avoir le site en français et en anglais et voir l'ensemble de la page d'accueil.
Xvfb -ac :99 -screen 0 1280x1024x24 -nolisten tcp &
python3 manage.py runserver 0.0.0.0:8080 --insecure
sleep infinity
21 changes: 20 additions & 1 deletion pod/main/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -4021,7 +4021,9 @@
"default_value": true,
"description": {
"en": [
""
"A boolean value to enable or disable debug mode.<br>",
"Never deploy a production site with DEBUG enabled.<br>",
"__ref: [https://docs.djangoproject.com/fr/3.2/ref/settings/#debug]()__"
],
"fr": [
"Une valeur booléenne qui active ou désactive le mode de débogage.<br>",
Expand All @@ -4032,6 +4034,23 @@
"pod_version_end": "",
"pod_version_init": "3.1"
},
"USE_DEBUG_TOOLBAR": {
AymericJak marked this conversation as resolved.
Show resolved Hide resolved
"default_value": true,
"description": {
"en": [
"A boolean value that enables or disables the debugging tool.<br>",
"Never deploy a production site with USE_DEBUG_TOOLBAR enabled.<br>",
"__ref: [https://django-debug-toolbar.readthedocs.io/en/latest/]()__"
],
"fr": [
"Une valeur booléenne qui active ou désactive l'outil de débogage.<br>",
"Ne déployez jamais de site en production avec le réglage USE_DEBUG_TOOLBAR activé.<br>",
"__ref: [https://django-debug-toolbar.readthedocs.io/en/latest/]()__"
]
},
"pod_version_end": "",
"pod_version_init": "3.5.0"
},
"LOGIN_URL": {
"default_value": "/authentication_login/",
"description": {
Expand Down
Empty file.
35 changes: 35 additions & 0 deletions pod/main/integration_tests/cookies.side
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"id": "f060a750-1757-4b5d-8ed0-ce6b1c49b62b",
"version": "2.0",
"name": "pod-front",
"url": "http://localhost:9090/",
"tests": [{
"id": "pod-accept-cookies",
"name": "cookies",
"commands": [{
"id": "pod-open-home",
"comment": "Ouvre la page d'accueil",
"command": "open",
"target": "/",
"targets": [],
"value": ""
}, {
"id": "pod-accept-cookies",
"comment": "Valide les cookies du navigateur",
"command": "click",
"target": "id=okcookie",
"targets": [],
"value": ""
}]
}],
"suites": [{
"id": "pod-front",
"name": "Esup Pod test selenium",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["pod-accept-cookies"]
}],
"urls": ["http://localhost:9090/"],
"plugins": []
}
92 changes: 92 additions & 0 deletions pod/main/integration_tests/lang.side
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"id": "f060a750-1757-4b5d-8ed0-ce6b1c49b62b",
"version": "2.0",
"name": "pod-front",
"url": "http://localhost:9090/",
"tests": [{
"id": "pod-change-lang",
"name": "lang",
"commands": [{
"id": "pod-open-home",
"comment": "Ouvre la page d'accueil",
"command": "open",
"target": "/",
"targets": [],
"value": ""
},{
"id": "pod-open-configuration",
"comment": "Ouvre la page de configuration",
"command": "click",
"target": "id=pod-param-buttons__button",
"targets": [
["id=pod-param-buttons__button", "id"],
["css=#pod-param-buttons__button", "css:finder"],
["xpath=//button[@id='pod-param-buttons__button']", "xpath:attributes"],
["xpath=//li[@id='pod-param-buttons']/button", "xpath:idRelative"],
["xpath=//nav/div/ul/li/button", "xpath:position"]
],
"value": ""
}, {
"id": "pod-toggle-langue-menu",
"comment": "Sélectionne menu choix langue",
"command": "mouseOver",
"target": "id=pod-lang-select",
"targets": [
["id=pod-lang-select", "id"],
["css=#pod-lang-select", "css:finder"],
["xpath=//button[@id='pod-lang-select']", "xpath:attributes"],
["xpath=//div[@id='pod-navbar__menusettings']/div[2]/ul/li/div/div/button", "xpath:idRelative"],
["xpath=//div[2]/ul/li/div/div/button", "xpath:position"]
],
"value": ""
}, {
"id": "pod-toggle-lang-select",
"comment": "Sélectionne la langue",
"command": "click",
"target": "id=pod-lang-select",
"targets": [
["id=pod-lang-select", "id"],
["css=#pod-lang-select", "css:finder"],
["xpath=//button[@id='pod-lang-select']", "xpath:attributes"],
["xpath=//div[@id='pod-navbar__menusettings']/div[2]/ul/li/div/div/button", "xpath:idRelative"],
["xpath=//div[2]/ul/li/div/div/button", "xpath:position"]
],
"value": ""
}, {
"id": "pod-toggle-lang-deselect",
"comment": "Déselectionne langue actuelle",
"command": "mouseOut",
"target": "id=pod-lang-select",
"targets": [
["id=pod-lang-select", "id"],
["css=#pod-lang-select", "css:finder"],
["xpath=//button[@id='pod-lang-select']", "xpath:attributes"],
["xpath=//div[@id='pod-navbar__menusettings']/div[2]/ul/li/div/div/button", "xpath:idRelative"],
["xpath=//div[2]/ul/li/div/div/button", "xpath:position"]
],
"value": ""
}, {
"id": "pod-toggle-lang-confirmation",
"comment": "Sélectionne langue ciblée",
"command": "click",
"target": "css=.dropdown-item",
"targets": [
["css=.dropdown-item", "css:finder"],
["xpath=//input[@value='English (en)']", "xpath:attributes"],
["xpath=//div[@id='pod-navbar__menusettings']/div[2]/ul/li/div/div/div/form/input[3]", "xpath:idRelative"],
["xpath=//input[3]", "xpath:position"]
],
"value": ""
}]
}],
"suites": [{
"id": "pod-front",
"name": "Esup Pod test selenium",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["pod-change-lang"]
}],
"urls": ["http://localhost:9090/"],
"plugins": []
}
82 changes: 82 additions & 0 deletions pod/main/integration_tests/search.side
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"id": "f060a750-1757-4b5d-8ed0-ce6b1c49b62b",
"version": "2.0",
"name": "pod-front",
"url": "http://localhost:9090/",
"tests": [{
"id": "pod-searchbar",
"name": "search",
"commands": [{
"id": "pod-open-home",
"comment": "Ouvre la page d'accueil",
"command": "open",
"target": "/",
"targets": [],
"value": ""
}, {
"id": "pod-search",
"comment": "Sélectionne barre recherche",
"command": "click",
"target": "id=s",
"targets": [
["id=s", "id"],
["name=q", "name"],
["css=#s", "css:finder"],
["xpath=//input[@id='s']", "xpath:attributes"],
["xpath=//form[@id='nav-search']/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": ""
}, {
"id": "pod-search-type",
"comment": "Tape mot clé",
"command": "type",
"target": "id=s",
"targets": [
["id=s", "id"],
["name=q", "name"],
["css=#s", "css:finder"],
["xpath=//input[@id='s']", "xpath:attributes"],
["xpath=//form[@id='nav-search']/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "pas de résultat attendu"
}, {
"id": "pod-search-enter",
"comment": "Appuie touche entrée",
"command": "sendKeys",
"target": "id=s",
"targets": [
["id=s", "id"],
["name=q", "name"],
["css=#s", "css:finder"],
["xpath=//input[@id='s']", "xpath:attributes"],
["xpath=//form[@id='nav-search']/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "${KEY_ENTER}"
}, {
"id": "pod-accueil-ariane",
"comment": "Retour à la page d'accueil via logo pod",
"command": "click",
"target": "xpath=//div[@id='nav-mainbar']/a/strong",
"targets": [
["css=strong", "css:finder"],
["xpath=//div[@id='nav-mainbar']/a/strong", "xpath:idRelative"],
["xpath=//strong", "xpath:position"],
["xpath=//strong[contains(.,'Lille.Pod')]", "xpath:innerText"]
],
"value": ""
}]
}],
"suites": [{
"id": "pod-front",
"name": "Esup Pod test selenium",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["pod-searchbar"]
}],
"urls": ["http://localhost:9090/"],
"plugins": []
}
Loading
Loading