Taskforce – Primo Workflow Testing with Cypress
Nishen Naidoo, Macquarie University
Special interest working group on interoperability has restructured with a focus on taskforces focusing on specific community issues. First one has been Primo Workflows – Lee Houghton is project leader, 18 people involved. Working on:
- workflow requirements gathering (documentation)
- workflow testing implementation (coding for automatic testing)
Manual testing takes time – there’s more and more to test, more and more often, and less and less time. This means we’re forced to only test the most vital things while other things slip off the radar – especially accessibility.
Cmd.exe. You need Node.js installed. Then in empty directory
> npm install cypress
> npx cypress open
This sets up example files and tests. Four folders in the cypress directory: fixtures (static config files, eg Primo url, username/password etc), integration (example tests), plugins (for extending functionality), and support (commands – lets you package up steps in a task).
Looking at integration tests – to run something just click and it goes and runs a whole series of tests at lightning speed. Test sets up context which groups everything together. BeforeEach() gets triggered before each test (eg to open a fresh Primo page). it() is a test with a bunch of actions eg type content into a field and test that it’s there, click on different parts of the page, get specific parts of the DOM. If we don’t get what we expect, Cypress tells you the test failed.
As well as just saving you time because it’s so fast, you can schedule it to run in the background and just notify you if something’s broken.
cy.get(“searchBar”).type(“economics journal”); //types economics journal into the search bar
cy.get(“div.search-actions”).click(); //clicks the search button
After running it (and seeing the result) you can ‘time-travel’ to hover on each command and see at what the browser looked like at that stage.
One downside is you can’t change out of one domain – this is a big problem with testing single sign on which relies on a lot of transitions between domains – gets a cross origin error. Makes it hard to test things that rely on a user being logged in. How single sign-in works:
Identity Provider <—-pre-configured certificates—> Service Provider (Primo PDS)
All communication between the two goes through the user so we can simulate that using Cypress Request Agent. Fixtures with urls and passwords. Before() runs before all tests (is the login), then beforeEach() (goes to a new Primo page, then function to test if the username shows in the menu.
Q: Aim to share these tests with the community?
A: Yes. 🙂