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 all 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
18 changes: 17 additions & 1 deletion .github/workflows/code_formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ jobs:
git config user.email [email protected]
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}

# Prettify js+css code with prettier
# Prettify .js | .json | .side | .css files with prettier
- name: Running prettier
run: |
npx prettier --write pod/*/static/**/*.js
npx prettier --write pod/*/static/**/*.json
npx prettier --write --parser json pod/**/*.side
npx prettier --write pod/*/static/**/*.css

- name: Check for modified files
Expand Down Expand Up @@ -67,3 +69,17 @@ jobs:
run: |
git commit -am "Auto-update configuration files"
git push

# Compile lang files
- name: Compile lang files in fr and nl
run: make compilelang

- name: Check for modified files
id: compilelang-git-check
run: echo modified=$(if git diff --quiet; then echo "false"; else echo "true"; fi) >> $GITHUB_OUTPUT

- name: Push lang compilation changes
if: steps.compilelang-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,10 +7,13 @@ on:
pull_request:
branches: ["*"]

permissions:
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest

permissions: write-all
strategy:
max-parallel: 4
matrix:
Expand Down Expand Up @@ -51,7 +54,7 @@ jobs:

- name: Flake8 compliance
run: |
flake8 --max-complexity=7 --ignore=E501,W503,E203 --exclude .git,pod/*/migrations/*.py,*_settings.py
flake8 --max-complexity=7 --ignore=E501,W503,E203 --exclude .git,pod/*/migrations/*.py,*_settings.py,side_*.py

- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@refactor_with_plugins
Expand All @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ transcription/*
# Unit test utilities #
#######################
chromedriver
**/integration_tests/**/*.png

## Others
pod/static/
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 @@ -26,6 +26,17 @@ RUN apt-get clean && apt-get update \
imagemagick \
gettext

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
185 changes: 185 additions & 0 deletions pod/completion/integration_tests/tests/subtitles_staff.side
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
"id": "9ea49e3a-2f6e-49aa-b1c7-975e8c0f70d3",
"version": "2.0",
"name": "pod-front",
"url": "http://localhost:9090/",
"tests": [{
"id": "pod-sous-titres-mode-edition",
"name": "Untitled",
"commands": [{
"id": "bb668b94-3724-482f-b0e9-ba055f0e3000",
"comment": "Ouvre la page de complétion",
"command": "open",
"target": "/video/completion/0002-video-staff/",
"targets": [],
"value": ""
}, {
"id": "833e6f0f-cfb0-494d-b62f-4dd944b3df42",
"comment": "Ouvre l'accordéon des sous-titres",
"command": "click",
"target": "id=section_track",
"targets": [
["id=section_track", "id"],
["linkText=Sous-titres et légendes", "linkText"],
["css=#section_track", "css:finder"],
["xpath=//a[contains(text(),'Sous-titres et légendes')]", "xpath:link"],
["xpath=//a[@id='section_track']", "xpath:attributes"],
["xpath=//div[@id='accordeon']/li[3]/a", "xpath:idRelative"],
["xpath=(//a[contains(@href, '#')])[3]", "xpath:href"],
["xpath=//div/li[3]/a", "xpath:position"],
["xpath=//a[contains(.,'Sous-titres et légendes ')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "9292c6ab-76d7-43d6-9102-cf80e772acac",
"comment": "",
"command": "waitForElementVisible",
"target": "linkText=Outil de création de fichier de sous-titres/légende",
"targets": [
["linkText=Outil de création de fichier de sous-titres/légende", "linkText"],
["css=p > .btn", "css:finder"],
["xpath=//a[contains(text(),'Outil de création de fichier de sous-titres/légende')]", "xpath:link"],
["xpath=//div[@id='accordeon']/li[4]/div/p/a", "xpath:idRelative"],
["xpath=//a[contains(@href, '/video/completion/caption_maker/0002-video-staff/')]", "xpath:href"],
["xpath=//p/a", "xpath:position"],
["xpath=//a[contains(.,'Outil de création de fichier de sous-titres/légende')]", "xpath:innerText"]
],
"value": "30000"
}, {
"id": "18f5e568-9ae1-4e43-920d-8e7aca81aa83",
"comment": "Clique sur le bouton pour ouvrir l'outil de création de sous-titres",
"command": "click",
"target": "linkText=Outil de création de fichier de sous-titres/légende",
"targets": [
["linkText=Outil de création de fichier de sous-titres/légende", "linkText"],
["css=p > .btn", "css:finder"],
["xpath=//a[contains(text(),'Outil de création de fichier de sous-titres/légende')]", "xpath:link"],
["xpath=//div[@id='accordeon']/li[4]/div/p/a", "xpath:idRelative"],
["xpath=//a[contains(@href, '/video/completion/caption_maker/33955-bbb/')]", "xpath:href"],
["xpath=//p/a", "xpath:position"],
["xpath=//a[contains(.,'Outil de création de fichier de sous-titres/légende')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "80aceab9-1cac-42ce-ba1e-e4e0ffb5fa27",
"comment": "Clique sur le bouton pour ajouter un sous-titre",
"command": "click",
"target": "id=addSubtitle",
"targets": [
["id=addSubtitle", "id"],
["css=#addSubtitle", "css:finder"],
["xpath=//button[@id='addSubtitle']", "xpath:attributes"],
["xpath=//div[@id='newCaptionsEditor']/button", "xpath:idRelative"],
["xpath=//div[2]/div[2]/button", "xpath:position"],
["xpath=//button[contains(.,' Ajouter un(e) légende / sous-titre')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "042569e8-f390-40c1-a04f-413c88519950",
"comment": "Sélectionne le champ des sous-titres",
"command": "click",
"target": "name=captionTextInput",
"targets": [
["id=c40389510", "id"],
["name=captionTextInput", "name"],
["css=#c40389510", "css:finder"],
["xpath=//textarea[@id='c40389510']", "xpath:attributes"],
["xpath=//div[@id='newCaptionsEditor']/form/div[2]/textarea", "xpath:idRelative"],
["xpath=//div[2]/textarea", "xpath:position"]
],
"value": ""
}, {
"id": "3f6c5cb2-d467-4e35-9d55-3b69bba7dd13",
"comment": "Écrit le contenu du sous-titre",
"command": "type",
"target": "name=captionTextInput",
"targets": [
["id=c40389510", "id"],
["name=captionTextInput", "name"],
["css=#c40389510", "css:finder"],
["xpath=//textarea[@id='c40389510']", "xpath:attributes"],
["xpath=//div[@id='newCaptionsEditor']/form/div[2]/textarea", "xpath:idRelative"],
["xpath=//div[2]/textarea", "xpath:position"]
],
"value": "Texte initial"
}, {
"id": "ffed3160-9509-4730-8478-c0c6543419a2",
"comment": "Change le mode d'édition",
"command": "click",
"target": "id=switchOldEditMode",
"targets": [
["id=switchOldEditMode", "id"],
["css=#switchOldEditMode", "css:finder"],
["xpath=//button[@id='switchOldEditMode']", "xpath:attributes"],
["xpath=//div[@id='pod-mainContent']/div[2]/div/div/div/div[7]/button", "xpath:idRelative"],
["xpath=//div[7]/button", "xpath:position"],
["xpath=//button[contains(.,' Changer le mode d’édition')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "50f96a38-c5bd-49bb-babe-47227a1a022e",
"comment": "Sélectionne le champ des sous-titres",
"command": "click",
"target": "id=captionContent",
"targets": [
["id=captionContent", "id"],
["css=#captionContent", "css:finder"],
["xpath=//textarea[@id='captionContent']", "xpath:attributes"],
["xpath=//div[@id='rawCaptionsEditor']/textarea", "xpath:idRelative"],
["xpath=//div[2]/div/textarea", "xpath:position"]
],
"value": ""
}, {
"id": "0ee2ab41-f02e-4a7f-a865-4caf1500d8ed",
"comment": "Modifie le contenu du sous-titre",
"command": "type",
"target": "id=captionContent",
"targets": [
["id=captionContent", "id"],
["css=#captionContent", "css:finder"],
["xpath=//textarea[@id='captionContent']", "xpath:attributes"],
["xpath=//div[@id='rawCaptionsEditor']/textarea", "xpath:idRelative"],
["xpath=//div[2]/div/textarea", "xpath:position"]
],
"value": "WEBVTT\\n\\n00:00.000 --> 00:02.000\\nTexte corrigé"
}, {
"id": "0bd7bfef-23b1-4eee-82aa-e8e10daf2541",
"comment": "Reviens au mode d'édition par défaut",
"command": "click",
"target": "id=switchOldEditMode",
"targets": [
["id=switchOldEditMode", "id"],
["css=#switchOldEditMode", "css:finder"],
["xpath=//button[@id='switchOldEditMode']", "xpath:attributes"],
["xpath=//div[@id='pod-mainContent']/div[2]/div/div/div/div[7]/button", "xpath:idRelative"],
["xpath=//div[7]/button", "xpath:position"],
["xpath=//button[contains(.,' Changer le mode d’édition')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "bf33e57c-b117-4d43-ba0f-ce246565ed15",
"comment": "Récupère la valeur du champ du sous-titre",
"command": "storeValue",
"target": "name=captionTextInput",
"targets": [],
"value": "sousTitre"
}, {
"id": "ee3f5108-139c-4e56-8ecd-5f4fe90208ad",
"comment": "Vérifie si la valeur modifiée est bien prise en compte d'un mode d'édition à l'autre",
"command": "assert",
"target": "sousTitre",
"targets": [],
"value": "Texte corrigé"
}]
}],
"suites": [{
"id": "pod-front",
"name": "Esup Pod test selenium",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["pod-sous-titres-mode-edition"]
}],
"urls": ["http://localhost:9090/"],
"plugins": []
}
1 change: 1 addition & 0 deletions pod/completion/static/js/caption_maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ document
}
} else {
oldModeSelected = !oldModeSelected;
parseAndLoadWebVTT(document.getElementById("captionContent").value);
document.getElementById("rawCaptionsEditor").style.display = "none";
document.getElementById("newCaptionsEditor").style.display = "block";
}
Expand Down
21 changes: 20 additions & 1 deletion pod/main/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -4034,7 +4034,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 @@ -4045,6 +4047,23 @@
"pod_version_end": "",
"pod_version_init": "3.1"
},
"USE_DEBUG_TOOLBAR": {
AymericJak marked this conversation as resolved.
Show resolved Hide resolved
"default_value": false,
"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.
12 changes: 12 additions & 0 deletions pod/main/integration_tests/commands/cookies_commands.side
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"commands": [
{
"id": "pod-accept-cookies",
"comment": "Valide les cookies du navigateur",
"command": "click",
"target": "id=okcookie",
"targets": [],
"value": ""
}
]
}
Loading