Open panteo opened 1 year ago
Hmmmmm that's odd since the tests pass. Mind setting up a PR? Would rather select the right element to click though.
Sure, I'll do it :muscle:
The tests pass probably because the spending approval is not tested, or at least I was not able to find the test.
@panteo . Could it be related to https://github.com/TenKeyLabs/dappwright/issues/227#issuecomment-1775141409?
@panteo . Could it be related to https://github.com/TenKeyLabs/dappwright/issues/227#issuecomment-1775141409?
Don't think so @alejogranerorequest .
I solved it by manually interacting with the popup in my tests. Until the library includes a new action to approve spending, you can use this helper:
const approveSpending = async (page: Page) => {
const popup = await page.context().waitForEvent("page");
await popup.getByRole("button", { name: "Next" }).click();
await popup.getByRole("button", { name: "Approve" }).click();
};
I am not using the data-testid
because it doesn't change between "Next" and "Approve" and sometimes we end up in an unpredictable race condition, generating flaky results.
Looks like it'll be a good addition! 👏🏾
Hi guys, Is there an update here?
I think @panteo lined up a solution for a PR but I'm not sure they got around to it?
I made the same thing he has shown here - thank you all. Buy now I faced with another one from another issue - still repro + with circle CI too (i've been doing with both) https://github.com/TenKeyLabs/dappwright/issues/269
It'd be nice to fix that - you just can't approve on CI
Problem Till Metamask v10 the spending approval was done in one step, so the
confirmTransaction
action could be used for this, but now, with Metamask v11.3.0 it is done in two steps and a new action is needed.Possible solution Add a new action:
approveSpending
, similar to theconfirmTransaction
, but with two clicks onpage-container-footer-next
.Alternative considered I considered to simply call twice the
confirmTransaction
in my test, but it is not working since it is expecting to close the popup after the first one, and this is not the case.Code snippet
If options are not required in this case, the action could be as easy as follow: