Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Anto59290 committed Jun 26, 2024
1 parent fe0f3c8 commit 8a99a75
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/templates/core/_documents.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="fr-btns-group--right fr-mb-2w">
<button class="fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-add-circle-line" data-fr-opened="false" aria-controls="fr-modal-2">
<button class="fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-add-circle-line" data-testid="documents-add" data-fr-opened="false" aria-controls="fr-modal-2">
Ajouter un document
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion core/templates/core/_fiche_bloc_commun.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<button id="tabpanel-405" class="fr-tabs__tab fr-icon-checkbox-line fr-tabs__tab--icon-left" tabindex="-1" role="tab" aria-selected="false" aria-controls="tabpanel-405-panel">Contacts</button>
</li>
<li role="presentation">
<button id="tabpanel-406" class="fr-tabs__tab fr-icon-checkbox-line fr-tabs__tab--icon-left" tabindex="-1" role="tab" aria-selected="false" aria-controls="tabpanel-406-panel">Documents</button>
<button id="tabpanel-406" class="fr-tabs__tab fr-icon-checkbox-line fr-tabs__tab--icon-left" tabindex="-1" role="tab" aria-selected="false" aria-controls="tabpanel-406-panel" data-testid="documents">Documents</button>
</li>
</ul>
<div id="tabpanel-404-panel" class="fr-tabs__panel fr-tabs__panel--selected" role="tabpanel" aria-labelledby="tabpanel-404" tabindex="0">
Expand Down
2 changes: 1 addition & 1 deletion core/templates/core/_modale_ajout_document.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</div>
<div class="fr-modal__footer">
<div class="fr-btns-group fr-btns-group--right fr-btns-group--inline-lg">
<button type="submit" class="fr-btn">Envoyer</button>
<button type="submit" class="fr-btn" data-testid="documents-send">Envoyer</button>
</div>
</div>
</form>
Expand Down
30 changes: 30 additions & 0 deletions sv/tests/test_fichedetection_documents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from playwright.sync_api import Page, expect
from ..models import FicheDetection

def test_can_add_document_to_fiche_detection(
live_server, page: Page, fiche_detection: FicheDetection
):
page.goto(f"{live_server.url}{fiche_detection.get_absolute_url()}")
page.get_by_test_id("documents").click()
expect(page.get_by_test_id("documents-add")).to_be_visible()
page.get_by_test_id("documents-add").click()

expect(page.locator("#fr-modal-2-title")).to_be_visible()

page.locator("#id_nom").fill("Name of the document")
page.locator("#id_document_type").select_option("autre")
page.locator("#id_description").fill("Description")
page.locator("#id_file").set_input_files('README.md')
page.get_by_test_id("documents-send").click()

page.wait_for_timeout(200)
assert fiche_detection.documents.count() == 1
document = fiche_detection.documents.get()

assert document.document_type == "autre"
assert document.nom == "Name of the document"
assert document.description == "Description"

# Check the document is now listed on the page
page.get_by_test_id("documents").click()
expect(page.get_by_text("Name of the document")).to_be_visible()

0 comments on commit 8a99a75

Please sign in to comment.