This could easily be different from country to country or region to region, but I think I would generally use "coffee" instead of "a coffee" in most of those examples. If I were going to a coffee shop for "a coffee" though, I might use the second example, but it could easily be "coffee" or "a coffee". Regardless, I agree that leaving out "cup of" isn't necessarily improper.
There are a lot of places where you can order “a coffee” which may come in a cup or a mug. For some unknown reason, I have yet to hear anyone say “
a tea”. I don’t know if it is considered a more formal item or if “a cup of tea” and just “tea” have become ingrained as the way to do it. It is just the way it is. Coffee as an item that you can order as “a coffee” is rather a recent phenomenon, but it does exist. You can try reporting “a cup of coffee” if no one says “a coffee” in your area and indicate general location for Duolingo, but where I live the alternate would be “a mug of coffee” and I don’t believe that Duolingo accepts that either.