horizontal line for local TOC in chapters

 \newcommand{\chaptertoc}[1][Contents]{%
\localtableofcontents%
\noindent\makebox[\linewidth]{\rule{\textwidth}{0.4pt}}
}


The result looks like this:

Instead, I would like to have a line separation between the text Contents and the localtoc. It should look something similar to this:

I tried adding the line  \noindent\makebox[\linewidth]{\rule{\textwidth}{0.4pt}} before \etocsettocstyle{\addsec*{#1}}{}%  but it is not working as desired.

You can use the minitoc package:

\documentclass{book}
\usepackage{minitoc}

\begin{document}
\dominitoc
\tableofcontents

\chapter{Chapter title}
\minitoc

\section{Test 1}
hello
\section{Test 2}
hello
\section{Test 3}
hello

\end{document}