Automatic light in bathroom

If there’s a bathroom where if you walk in the light goes on , is it permitted to walk in on shabbos ?

Is that the only light?

Doesn’t Rav Abadi permit in his Or Yis-hak one to open the fridge door knowing that the light will turn on because of a necessity (i.e., food)? Is Goldylocks’ question any different?

Not exactly the same. The Ohr Yitzchak permits opening the refrigerator only if there is light in tbe room so you don’t care for or need the light in the refrigerator. If the room was dark it would not be permissible to open the refrigerator if the light inside would turn on since you very much want that light.

If it’s the only light But I’m fine going to the bathroom in the dark is it okay ?
If not , When would it be permitted to walk into a bathroom whose light turns on automatically?

If it’s pitch dark, then even though you don’t need the light, it’s still nicha and therefore prohibited.