From ebcc0b66904a196e759d070b5d28a7daa9a7eecd Mon Sep 17 00:00:00 2001 From: Arnaud Ambroselli <31724752+arnaudambro@users.noreply.github.com> Date: Fri, 8 Sep 2023 09:29:58 +0200 Subject: [PATCH] =?UTF-8?q?fix(dashboard):=20apr=C3=A8s=20avoir=20navigu?= =?UTF-8?q?=C3=A9=20dans=20diff=C3=A9rentes=20tabs=20d'un=20CR,=20quand=20?= =?UTF-8?q?on=20clique=20sur=20Retour,=20=C3=A7a=20ne=20marchait=20pas=20-?= =?UTF-8?q?=20d=C3=A9sormais=20on=20retourne=20dans=20la=20liste=20des=20C?= =?UTF-8?q?R=20(#1644)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/scenes/report/view.js | 9 +++++++-- e2e/actions_comments_urgents.spec.ts | 2 +- e2e/consultations_test-navigate-to-consultation.spec.ts | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dashboard/src/scenes/report/view.js b/dashboard/src/scenes/report/view.js index 4c2ba2f3f..d9f2d023d 100644 --- a/dashboard/src/scenes/report/view.js +++ b/dashboard/src/scenes/report/view.js @@ -54,7 +54,6 @@ import SelectTeamMultiple from '../../components/SelectTeamMultiple'; import TagTeam from '../../components/TagTeam'; import ReceptionService from '../../components/ReceptionService'; import { useLocalStorage } from '../../services/useLocalStorage'; -import useSearchParamState from '../../services/useSearchParamState'; import { arrayOfitemsGroupedByActionSelector, arrayOfitemsGroupedByConsultationSelector, personsObjectSelector } from '../../recoil/selectors'; import { treatmentsState } from '../../recoil/treatments'; import { medicalFileState } from '../../recoil/medicalFiles'; @@ -145,7 +144,13 @@ const View = () => { const history = useHistory(); const location = useLocation(); const searchParams = new URLSearchParams(location.search); - const [activeTab, setActiveTab] = useSearchParamState('tab', ['restricted-access'].includes(user.role) ? 'reception' : 'resume'); + const [activeTab, setActiveTab] = useState(['restricted-access'].includes(user.role) ? 'reception' : 'resume'); + const searchParamTab = searchParams.get('tab'); + useEffect(() => { + if (searchParamTab) { + setActiveTab(searchParamTab); + } + }, [searchParamTab]); const { refresh } = useDataLoader(); diff --git a/e2e/actions_comments_urgents.spec.ts b/e2e/actions_comments_urgents.spec.ts index dd3324f3a..c0816aebb 100644 --- a/e2e/actions_comments_urgents.spec.ts +++ b/e2e/actions_comments_urgents.spec.ts @@ -134,7 +134,7 @@ test("Create action with comments", async ({ page }) => { await page.getByRole("button", { name: "Actions et commentaires urgents et vigilance" }).click(); await page.locator('[data-test-id="action avec commentaire"]').getByRole("cell", { name: "action avec commentaire" }).click(); - await expect(page).toHaveURL(/http:\/\/localhost:8090\/report\/.*\?reportsTeam=%5B%22.*%22%5D&tab=comment-created&actionId=.*/); + await expect(page).toHaveURL(/http:\/\/localhost:8090\/report\/.*\?reportsTeam=%5B%22.*%22%5D&actionId=.*/); await page.getByRole("button", { name: "Commentaires (1)" }).click(); await expect(page.getByRole("heading", { name: "Action: action avec commentaire (créée par User Admin Test - 7)" })).toBeVisible(); await page.getByRole("button", { name: "Fermer" }).first().click(); diff --git a/e2e/consultations_test-navigate-to-consultation.spec.ts b/e2e/consultations_test-navigate-to-consultation.spec.ts index 9b7d1e302..2e5782f39 100644 --- a/e2e/consultations_test-navigate-to-consultation.spec.ts +++ b/e2e/consultations_test-navigate-to-consultation.spec.ts @@ -134,7 +134,7 @@ test("test", async ({ page }) => { await page.locator('[data-test-id="faite"]').getByText("faite").click(); await expect(page).toHaveURL( - /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&tab=consultations-created&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ + /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ ); await page.getByRole("button", { name: "Fermer" }).first().click(); @@ -150,7 +150,7 @@ test("test", async ({ page }) => { await page.locator('[data-test-id="consult abc"]').getByText("consult abc").click(); await expect(page).toHaveURL( - /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&tab=consultations-created&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ + /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ ); await page.getByRole("button", { name: "Fermer" }).first().click(); @@ -161,11 +161,11 @@ test("test", async ({ page }) => { await page.locator('[data-test-id="faite"]').getByText("faite").click(); await expect(page).toHaveURL( - /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&tab=consultations&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ + /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ ); await page.getByRole("button", { name: "Fermer" }).first().click(); await expect(page).toHaveURL( - /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&tab=consultations/ + /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D/ ); });