Samsung galaxy S9 unauthorized power down/restart

In the past few days my galaxy S9 has started to restart itself and then power down by itself. I have went through the settings and have also booted into safe mode, wiped the cache partition and factory rese . I haven't seen it power down while plugged into the charger. There haven't been any drops, falls or anything that could damage it to cause this and even though the phone is waterproof/resistant it hasn't been in or near water. is there a way to test the battery or troubleshoot further on my own or is it something I can't fix by mysel . 

Who I have the same questioned this topic