Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create coupon code via Magento REST api #45

Merged
merged 3 commits into from
Mar 29, 2022

Conversation

kolaente
Copy link
Collaborator

@kolaente kolaente commented Mar 29, 2022

This PR adds a method to the REST API helper to create random coupon codes on the fly during a test.

Use it like this:

it('Can add a coupon to the cart', () => {
    Magento2RestApi.createRandomCouponCode()
        .then(coupon => {
            Cart.addCouponCode(coupon)
            cy.get(cartLuma.cartSummaryTable)
                .should('include.text', 'Discount')
                .should('be.visible')
        })
})

I'll do a follow-up PR to add this to the tests.

@peterjaap
Copy link
Contributor

Love it! But why the insanely high timeout of 100000?

@kolaente
Copy link
Collaborator Author

Good question! I copied the cy.request statement from createCustomerAccount and it was already in there.

What would be a better timeout? Might make sense to set this to the same value for all requests in the file? (logCustomerIn has a timeout of 50000, the other ones have 100000)

@peterjaap
Copy link
Contributor

@kolaente I think you can just remove it, so it will use the default timeout set in Cypress (5000 by default). Unless there's a specific (and valid) reason to raise it, just leave it at the default.

@kolaente
Copy link
Collaborator Author

Done!

@peterjaap
Copy link
Contributor

I still see timeouts in the commit?

@kolaente
Copy link
Collaborator Author

kolaente commented Mar 29, 2022

Looks like I forgot one, whoops. Should I also remove the ones which were already present in the other commands?

@peterjaap
Copy link
Contributor

I still see 3;

image

image

@kolaente
Copy link
Collaborator Author

Gotcha, I've removed all of them.

@peterjaap
Copy link
Contributor

I realized now some of those weren't yours, haha. Thanks! :)

@peterjaap peterjaap merged commit 3e83c61 into elgentos:main Mar 29, 2022
@kolaente kolaente deleted the feature/coupong-via-rest branch March 29, 2022 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants