Repository: remix-run/react-router
File: packages/react-router-dom/__tests__/data-browser-router-test.tsx (TypeScript)

Code before:
          expect(container.querySelector("form")?.getAttribute("action")).toBe(
            "/foo"
          );
        });
      });

      it("allows user to specify search params and hash", async () => {
        let router = createTestRouter(
          createRoutesFromElements(
            <Route path="/">
              <Route path="foo">
                <Route path="bar" element={<Form action=".?a=1#newhash" />} />
              </Route>
            </Route>
          ),
          { window: getWindow("/foo/bar?a=1#hash") }
        );
        let { container } = render(<RouterProvider router={router} />);

        expect(container.querySelector("form")?.getAttribute("action")).toBe(
          "/foo/bar?a=1#newhash"
        );
      });
    });

    describe('<Form action relative="path">', () => {
      it("navigates relative to the URL for static routes", async () => {
        let router = createTestRouter(
          createRoutesFromElements(
            <Route path="inbox">
              <Route path="messages" />
              <Route
                path="messages/edit"
                element={<Form action=".." relative="path" />}
              />
            </Route>
          ),
          {
            window: getWindow("/inbox/messages/edit"),
          }
        );
        let { container } = render(<RouterProvider router={router} />);

        expect(container.querySelector("form")?.getAttribute("action")).toBe(
          "/inbox/messages"
        );
      });

      it("navigates relative to the URL for dynamic routes", async () => {
        let router = createTestRouter(
          createRoutesFromElements(

Review comment (bug):
When we have an `?index` around from a prior submission, we were incorrectly letting that apply to a `submit(data, { method: 'post' })` in the parent component and then it would try to submit to the child index route action and not the proper contextual parent route action

Code after:
          expect(container.querySelector("form")?.getAttribute("action")).toBe(
            "/foo"
          );
        });
      });

      describe("submitting to self from parent/index when ?index param exists", () => {
        it("useSubmit", async () => {
          let router = createTestRouter(
            createRoutesFromElements(
              <Route
                id="parent"
                path="/parent"
                element={<Parent />}
                action={({ request }) => "PARENT ACTION: " + request.url}
              >
                <Route
                  id="index"
                  index
                  element={<Index />}
                  action={({ request }) => "INDEX ACTION: " + request.url}
                />
              </Route>
            ),
            {
              window: getWindow("/parent?index&index=keep"),
            }
          );
          let { container } = render(<RouterProvider router={router} />);

          function Parent() {
            let actionData = useActionData();
            let submit = useSubmit();
            return (
              <>
                <p id="parent">{actionData}</p>
                <button onClick={() => submit({}, { method: "post" })}>
                  Submit from parent
                </button>
                <Outlet />
              </>
            );
          }

          function Index() {
            let actionData = useActionData();
            let submit = useSubmit();
            return (
              <>
                <p id="index">{actionData}</p>
                <button onClick={() => submit({}, { method: "post" })}>