-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests and workflows for sub product with signup fee (#1809)
* Added tests and workflows for sub product with signup fee * Break out function * Minor change to setup checkout function * Update API and e2e utils packages and delete user via rest API
- Loading branch information
1 parent
56b0e2b
commit 6fb8d94
Showing
8 changed files
with
132 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
tests/e2e/specs/subscriptions/purchase-sign-up-fee-subscription.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import config from 'config'; | ||
|
||
const { merchant, shopper, withRestApi } = require( '@woocommerce/e2e-utils' ); | ||
|
||
import { RUN_SUBSCRIPTIONS_TESTS, describeif, merchantWCP } from '../../utils'; | ||
|
||
import { fillCardDetails, setupCheckout } from '../../utils/payments'; | ||
|
||
const productName = 'Subscription signup fee product'; | ||
const productSlug = 'subscription-signup-fee-product'; | ||
|
||
const customerBilling = config.get( 'addresses.customer.billing' ); | ||
|
||
describeif( RUN_SUBSCRIPTIONS_TESTS )( | ||
'Subscriptions > Purchase subscription with signup fee', | ||
() => { | ||
beforeAll( async () => { | ||
await merchant.login(); | ||
|
||
// Create subscription product with signup fee | ||
await merchantWCP.createSubscriptionProduct( productName, true ); | ||
|
||
await merchant.logout(); | ||
} ); | ||
|
||
afterAll( async () => { | ||
await merchant.logout(); | ||
|
||
// Delete the user created with the subscription | ||
await withRestApi.deleteCustomerByEmail( customerBilling.email ); | ||
} ); | ||
|
||
it( 'should be able to purchase a subscription with signup fee', async () => { | ||
// Open the subscription product we created in the store | ||
await page.goto( config.get( 'url' ) + `product/${ productSlug }`, { | ||
waitUntil: 'networkidle0', | ||
} ); | ||
|
||
// Add it to the cart and proceed to check out | ||
await expect( page ).toClick( '.single_add_to_cart_button' ); | ||
await page.waitForNavigation( { waitUntil: 'networkidle0' } ); | ||
|
||
await setupCheckout( customerBilling ); | ||
|
||
const card = config.get( 'cards.basic' ); | ||
await fillCardDetails( page, card ); | ||
await shopper.placeOrder(); | ||
await expect( page ).toMatch( 'Order received' ); | ||
} ); | ||
|
||
it( 'should have an active subscription', async () => { | ||
await merchant.login(); | ||
|
||
await merchantWCP.openSubscriptions(); | ||
|
||
// Verify we have an active subscription for the product | ||
await expect( page ).toMatchElement( '.subscription-status', { | ||
text: 'Active', | ||
} ); | ||
await expect( page ).toMatchElement( '.order-item', { | ||
text: productName, | ||
} ); | ||
await expect( page ).toMatchElement( '.recurring_total', { | ||
text: '$9.99 / month', | ||
} ); | ||
} ); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters