How to login to git lab agent and then trigger the script

My application over web supports only SSO login. I order to test this application, first I have to login with user who can access this application.
I am writing CI/CD pipeline in gitlab. Is there any way to login to an agent with specific username and password credentials and execute test script using npm test command

Lots of ways; there are testing libraries for web apps, and for web clients. It would depend on what language you wrote the software in. Software testing is entire profession.