Don't forget that Scotland very nearly did leave the UK, with the government's consent, in 2014 (but the referendum didn't pass).
The Catalonia case is a bit murkier, since the Catalan government did not actually reach an agreement with the Spanish government before they went ahead with the referendum. Also because of irregularities seen by international observers during the referendum, the Catalonia referendum result was generally not recognized.