Do you have real carts you want to keep? if not, a truncate on the table (assuming you're using serialzable carts) should be enough
other than that, if you don't keep the carts forever, they will be automatically deleted after 30 days with the remove expired carts scheduled job
otherwise, you can do a query to join with cls_Contact table (customerid should match with contactid if it is a registered account). you then can have a list of carts without registered accounts.
of course, those deletions should be done with cautions and back up should be performed
Yes, of course we have real cards we want to keep : D (we run these tests against PROD as well).
I am talking about Playwright tests, there is no access to the database, only the API.
As I've mentioned, it is tested with guest users, and the test is completed before the purchase, so no contact ids.
Some ideas
it will be a slow process however. you can leave it to the Remove Expired Carts to eventually clear the carts (those carts would have fairly small, if any, performance impact, I'd not worry about them, unless if you have tens of millions)
In our E2E test that we run on all the environments we are adding items to a cart, signing in as a guest user, filling in contact details; but are not completing the purchase. We are ending up with many fake carts even on our PROD environment.
From what I see a cart can be deleted with cart information, but for that we need the Order repository. In our tests we can only use the APIs. Is there a way to clean up after the testing via the API? (we do not have user id as we end the testing before the user is created)