Thanks for reaching out ewelina274,
It sounds like you're having intermittent trouble with Wi-Fi. We can help.
Its great that you ran a diagnostic, but keep in mind that when you Use Apple Diagnostics to test your Mac you may be provided with a reference code regarding the status of your hardware components. While these might seem confusing at first, you can use this guide to look up and understand any Apple Diagnostics reference codes you might have seen.
If it turns out that there are no hardware issues, since the issue isn't constant our next thing to check is if there is any interference that might interrupt your Wi-Fi connection. Check out these steps identify and Resolve Wi-Fi and Bluetooth issues caused by wireless interference.
If necessary, you can take a look at the Recommended settings for Wi-Fi routers and access points as well.
Hope that helps.
Take care.