Skip to content

Commit f2787e0

Browse files
Salve de retours sur le maintien de la localisation sur l'assistant (#1687)
1 parent 21f64b4 commit f2787e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+606
-299
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ media
3737
_build
3838
.obsidian
3939
*.pem
40+
41+
tmpbackup

.secrets.baseline

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@
9090
{
9191
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
9292
},
93-
{
94-
"path": "detect_secrets.filters.common.is_baseline_file",
95-
"filename": ".secrets.baseline"
96-
},
9793
{
9894
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
9995
"min_level": 2
@@ -142,7 +138,7 @@
142138
"filename": "core/settings.py",
143139
"hashed_secret": "1ee34e26aeaf89c64ecc2c85efe6a961b75a50e9",
144140
"is_verified": false,
145-
"line_number": 288
141+
"line_number": 290
146142
}
147143
],
148144
"dbt/package-lock.yml": [
@@ -191,5 +187,5 @@
191187
}
192188
]
193189
},
194-
"generated_at": "2025-06-18T13:56:44Z"
190+
"generated_at": "2025-06-23T15:32:22Z"
195191
}

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ createsuperuser:
102102
.PHONY: seed-database
103103
seed-database:
104104
$(DJANGO_ADMIN) loaddata categories labels sources actions produits acteur_services acteur_types objets synonymes suggestions
105-
$(DJANGO_ADMIN) loadacteurs acteurs propositions_services
105+
$(DJANGO_ADMIN) loadacteurs acteurs
106+
$(DJANGO_ADMIN) loaddata propositions_services
106107

108+
FIXTURES_ACTEURS_PKS = "communautelvao_LWTYYUPBDMWM","6554f1bb-82d2-567f-8453-eec5405e5b5d","65791ef2-bb37-4569-b011-8cece03dcdcf","antiquites_du_poulbenn_152575_reparation","refashion_TLC-REFASHION-PAV-3445001","communautelvao_VBOFDJDBOCTW","refashion_TLC-REFASHION-REP-603665791852778329","ocad3e_SGS-02069" # pragma: allowlist secret
107109
.PHONY: generate-fixtures-acteurs
108110
generate-fixtures-acteurs:
109-
$(DJANGO_ADMIN) dumpdata qfdmo.displayedacteur $(FIXTURES_OPTIONS) --pk "65791ef2-bb37-4569-b011-8cece03dcdcf","antiquites_du_poulbenn_152575_reparation","refashion_TLC-REFASHION-PAV-3445001","communautelvao_VBOFDJDBOCTW","refashion_TLC-REFASHION-REP-603665791852778329","ocad3e_SGS-02069" -o qfdmo/fixtures/acteurs.json # pragma: allowlist secret
110-
$(DJANGO_ADMIN) dumpdata qfdmo.displayedpropositionservice $(FIXTURES_OPTIONS) --pk 2163243,2163244,2163245,243160,435885,1699381,738371,738372,719100 -o qfdmo/fixtures/propositions_services.json
111+
$(DJANGO_ADMIN) dumpdata qfdmo.displayedacteur $(FIXTURES_OPTIONS) --pk $(FIXTURES_ACTEURS_PKS) -o qfdmo/fixtures/acteurs.json # pragma: allowlist secret
112+
@IDS=$$(poetry run python manage.py shell -c "from qfdmo.models import DisplayedActeur; pks = '$(FIXTURES_ACTEURS_PKS)'.split(','); print(','.join(map(str, DisplayedActeur.objects.filter(pk__in=pks).values_list('proposition_services__pk', flat=True))))"); \
113+
echo "Generate fixtures for Propositions services: IDS=$$IDS"; \
114+
$(DJANGO_ADMIN) dumpdata qfdmo.displayedpropositionservice $(FIXTURES_OPTIONS) --pk $$IDS -o qfdmo/fixtures/propositions_services.json
111115

112116
.PHONY: generate-fixtures
113117
generate-fixtures:
@@ -148,6 +152,10 @@ test-dags:
148152
e2e-test:
149153
npx playwright test --update-snapshots
150154

155+
.PHONY: e2e-test-ui
156+
e2e-test-ui:
157+
npx playwright test --update-snapshots --ui
158+
151159
.PHONY: a11y
152160
a11y:
153161
npx playwright test --reporter=list ./e2e_tests/accessibility.spec.ts

core/context_processors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def environment(request):
1616
"BLOCK_ROBOTS": settings.BLOCK_ROBOTS,
1717
"is_embedded": True,
1818
"turbo": request.headers.get("Turbo-Frame"),
19+
"VERSION": settings.VERSION,
20+
"APP": settings.APP,
1921
}
2022

2123

core/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
POSTHOG_DEBUG = decouple.config("POSTHOG_DEBUG", default=False, cast=bool)
8383
BLOCK_ROBOTS = decouple.config("BLOCK_ROBOTS", default=False, cast=bool)
8484
ENVIRONMENT = decouple.config("ENVIRONMENT", default="development", cast=str)
85+
VERSION = decouple.config("CONTAINER_VERSION", default="version", cast=str)
86+
APP = decouple.config("APP", default="local", cast=str)
8587
BASE_URL = ASSISTANT.get("BASE_URL")
8688
BASE_ALLOWED_HOSTS = [
8789
urlparse(config.get("BASE_URL")).hostname for config in [ASSISTANT, LVAO]

e2e_tests/acteurs.spec.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { expect, test } from "@playwright/test";
2+
import { hideDjangoToolbar, searchDummyAdresse } from "./helpers";
3+
function getItemSelector(index) {
4+
return `#mauvais_etat #id_adresseautocomplete-list.autocomplete-items div:nth-of-type(${index})`
5+
}
6+
7+
8+
test.skip("Desktop | Les acteurs sont visibles sur la carte du formulaire fonctionne", async ({ page }) => {
9+
// Navigate to the carte page
10+
await page.goto(`/test_iframe`, { waitUntil: "networkidle" });
11+
// await hideDjangoToolbar(page)
12+
const sessionStorage = await page.evaluate(() => window.sessionStorage)
13+
const iframeElement = await page.$("#formulaire iframe");
14+
const iframe = await iframeElement?.contentFrame();
15+
16+
// Select a Produit
17+
let inputSelector = "#id_sous_categorie_objet"
18+
await iframe.locator(inputSelector).click()
19+
await iframe.locator(inputSelector).fill("perceuse");
20+
await iframe.locator("#id_sous_categorie_objetautocomplete-list.autocomplete-items div:nth-child(1)").click()
21+
22+
// Fill adresse
23+
inputSelector = "#id_adresse"
24+
await iframe.locator(inputSelector).click()
25+
await iframe.locator(inputSelector).fill("auray");
26+
await iframe.locator("#id_adresseautocomplete-list.autocomplete-items div:nth-child(2)").click()
27+
28+
// Submit form
29+
await iframe?.getByTestId("formulaire-rechercher-adresses-submit").click()
30+
const markers = iframe?.locator(".leaflet-marker-icon")
31+
32+
// Remove the home marker (red dot) that prevents Playwright from clicking other markers
33+
await page.evaluate(() => {
34+
document.querySelector('.leaflet-marker-icon.home-icon')?.remove()
35+
});
36+
37+
// Ensure we have at least one marker, and let's click on a marker.
38+
// The approach is feels cumbersome, this is because Playwright has a
39+
// hard time clicking on leaflet markers.
40+
// Hence the force option in click's method call.
41+
await expect(markers?.nth(0)).toBeAttached()
42+
const count = await markers?.count() || 0
43+
for (let i = 0; i < count; i++) {
44+
const item = markers?.nth(i);
45+
46+
try {
47+
await item!.click({ force: true, timeout: 100 });
48+
break
49+
} catch (e) {
50+
console.log("cannot click", e)
51+
}
52+
}
53+
54+
await expect(iframe?.locator("#acteurDetailsPanel")).toBeVisible()
55+
})
56+
57+
test.skip("Desktop | Les acteurs digitaux sont visibles sur le formulaire", async ({ page }) => {
58+
test.slow()
59+
// Navigate to the carte page
60+
await page.goto(`/test_iframe`, { waitUntil: "networkidle" });
61+
// await hideDjangoToolbar(page)
62+
const sessionStorage = await page.evaluate(() => window.sessionStorage)
63+
const iframeElement = await page.$("#formulaire iframe");
64+
const iframe = await iframeElement?.contentFrame();
65+
66+
// Select a Produit
67+
let inputSelector = "#id_sous_categorie_objet"
68+
await iframe.locator(inputSelector).click()
69+
await iframe.locator(inputSelector).fill("perceuse");
70+
await iframe.locator("#id_sous_categorie_objetautocomplete-list.autocomplete-items div:nth-child(1)").click()
71+
72+
// Fill adresse
73+
inputSelector = "#id_adresse"
74+
await iframe.locator(inputSelector).click()
75+
await iframe.locator(inputSelector).fill("auray");
76+
await iframe.locator("#id_adresseautocomplete-list.autocomplete-items div:nth-child(2)").click()
77+
78+
// Submit form
79+
await iframe?.getByTestId("formulaire-rechercher-adresses-submit").click()
80+
// Wait for results to laod en being added to leaflet
81+
const someLeafletMarker = iframe?.locator(".leaflet-marker-icon").first()
82+
await expect(someLeafletMarker).toBeAttached()
83+
84+
// Digital acteurs
85+
await iframe?.locator("#id_digital_1").click({ force: true })
86+
await iframe?.locator("[aria-controls=acteurDetailsPanel]").first().click()
87+
await expect(iframe?.locator("#acteurDetailsPanel")).toBeVisible()
88+
})
89+

e2e_tests/assistant.spec.ts

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,90 @@ function getItemSelector(index) {
44
return `#mauvais_etat #id_adresseautocomplete-list.autocomplete-items div:nth-of-type(${index})`
55
}
66

7-
test("Desktop | La carte s'affiche sur une fiche déchet/objet", async ({ page }) => {
8-
// Navigate to the carte page
9-
await page.goto(`/dechet/lave-linge`, { waitUntil: "networkidle" });
10-
await hideDjangoToolbar(page)
7+
async function searchOnProduitPage(page, searchedAddress: string) {
118
const inputSelector = "#mauvais_etat input#id_adresse"
12-
const adresseFill = "Auray"
9+
1310
// Autour de moi
1411
await page.locator(inputSelector).click();
15-
await page.locator(inputSelector).fill(adresseFill);
12+
await page.locator(inputSelector).fill(searchedAddress);
1613
expect(page.locator(getItemSelector(1)).innerText()).not.toBe("Autour de moi")
1714
await page.locator(getItemSelector(1)).click();
15+
}
16+
17+
test("Desktop | La carte s'affiche sur une fiche déchet/objet", async ({ page }) => {
18+
// Navigate to the carte page
19+
await page.goto(`/dechet/lave-linge`, { waitUntil: "networkidle" });
20+
// await hideDjangoToolbar(page)
21+
await searchOnProduitPage(page, "Auray")
1822
const sessionStorage = await page.evaluate(() => window.sessionStorage)
19-
expect(sessionStorage.adresse).toBe(adresseFill)
23+
expect(sessionStorage.adresse).toBe("Auray")
2024
expect(sessionStorage.latitude).toContain("47.6")
2125
expect(sessionStorage.longitude).toContain("-2.9")
26+
})
27+
28+
test.skip("Desktop | Le tracking PostHog fonctionne comme prévu", async ({ page }) => {
29+
// Check that homepage scores 1
30+
await page.goto(`/`, { waitUntil: "networkidle" });
31+
// await hideDjangoToolbar(page)
32+
let sessionStorage = await page.evaluate(() => window.sessionStorage)
33+
expect(sessionStorage.homePageView).toBe("0")
34+
35+
// Navigate to a produit page and check that it scores 1
36+
await page.goto(`/dechet/lave-linge`, { waitUntil: "networkidle" });
37+
sessionStorage = await page.evaluate(() => window.sessionStorage)
38+
expect(sessionStorage.produitPageView).toBe("1")
39+
40+
// Click on a pin on the map and check that it scores 1
41+
await searchOnProduitPage(page, "Auray")
42+
const markers = page.locator(".leaflet-marker-icon")
43+
// Remove the home marker (red dot) that prevents Playwright from clicking other markers
44+
await page.evaluate(() => {
45+
document.querySelector('.leaflet-marker-icon.home-icon')?.remove()
46+
});
47+
48+
// Ensure we have at least one marker, and let's click on a marker.
49+
// The approach is feels cumbersome, this is because Playwright has a
50+
// hard time clicking on leaflet markers.
51+
// Hence the force option in click's method call.
52+
await expect(markers?.nth(0)).toBeAttached()
53+
const count = await markers?.count()
54+
for (let i = 0; i < count; i++) {
55+
const item = markers?.nth(i);
56+
57+
try {
58+
await item!.click({ force: true, timeout: 100 });
59+
break
60+
} catch (e) {
61+
console.log("cannot click", e)
62+
}
63+
}
64+
65+
sessionStorage = await page.evaluate(() => window.sessionStorage)
66+
expect(sessionStorage.userInteractionWithMap).toBe("1")
67+
68+
// Click on another pin on the map and check that it scores 1 more (2 in total)
69+
for (let i = 0; i < count; i++) {
70+
const item = markers?.nth(i);
71+
72+
try {
73+
await item!.click({ force: true, timeout: 100 });
74+
break
75+
} catch (e) {
76+
console.log("cannot click", e)
77+
}
78+
}
79+
80+
sessionStorage = await page.evaluate(() => window.sessionStorage)
81+
expect(sessionStorage.userInteractionWithMap).toBe("2")
82+
83+
// Click on share button in solution details
84+
await page.locator("#mauvais_etat [aria-describedby=mauvais_etat:shareTooltip]").click()
85+
sessionStorage = await page.evaluate(() => window.sessionStorage)
86+
expect(sessionStorage.userInteractionWithSolutionDetails).toBe("1")
2287

23-
// await expect(page.locator(".leaflet-marker-icon [data-animated]")).toBeVisible()
24-
// await page.locator(".leaflet-marker-icon [data-animated]").click()
25-
// expect(page.locator("#acteurDetailsPanel")).toBeVisible()
88+
// Ensure that the scores does not increases after
89+
// several homepage visits
90+
await page.goto(`/`, { waitUntil: "networkidle" });
91+
sessionStorage = await page.evaluate(() => window.sessionStorage)
92+
expect(sessionStorage.homePageView).toBe("0")
2693
})

e2e_tests/search_update.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test("Recherche et modification d'une recherche", async ({ page }) => {
2020
await searchDummyAdresse(page)
2121

2222
// Submit the search form
23-
await page.locator("button[data-testid=rechercher-adresses-submit]").click()
23+
await page.locator("button[data-testid=formulaire-rechercher-adresses-submit]").click()
2424

2525
// Expect the Proposer une adresse button to be visible
2626
await expect(page.getByTestId("formulaire-proposer-une-adresse")).toBeVisible()

jinja2/layout/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</head>
3838

3939
<body
40-
class="qf-flex qf-flex-col qf-h-svh qf-h-screen qf-overflow-hidden"
40+
class="qf-flex qf-flex-col qf-h-svh qf-h-screen qf-overflow-hidden {% block body_classes %}{% endblock %}"
4141
data-controller="state"
4242
data-state-adresse-value=""
4343
data-state-longitude-value=""

jinja2/qfdmo/_addresses_partials/filters/_modal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class='fr-container
22
qf-px-0
33
qf-absolute qf-z-50 qf-top-auto qf-left-0 qf-right-0 qf-mt-auto
4-
qf-h-[90vh] qf-h-[90svh] {# Keep both values help keep support for vh in firefox #}
4+
qf-h-[90%] {# Keep both values help keep support for vh in firefox #}
55
qf-inset-0 qf-font-black qf-bg-white
66
qf-flex qf-flex-col
77
qf-overflow-auto

0 commit comments

Comments
 (0)