diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index e50303c6b8..5d8905ab66 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -232,7 +232,6 @@ jobs: - name: Apply extra config options run: | cat web/cypress/test/extra-config.yaml >> local-dev/stack/config.yaml - sed -ie 's/TESTING: false/TESTING: true/g' local-dev/stack/config.yaml docker restart quay-quay sleep 30 diff --git a/util/marketplace.py b/util/marketplace.py index efe66b19ba..0fe987a9c5 100644 --- a/util/marketplace.py +++ b/util/marketplace.py @@ -293,8 +293,6 @@ def get_list_of_subscriptions( "username": "free_user", } -E2E_TEST_USER_EMAIL = "user1@redhat.com" - class FakeUserApi(RedHatUserApi): """ @@ -302,7 +300,7 @@ class FakeUserApi(RedHatUserApi): """ def lookup_customer_id(self, email): - if email == TEST_USER["email"] or email == E2E_TEST_USER_EMAIL: + if email == TEST_USER["email"]: return TEST_USER["account_number"] if email == FREE_USER["email"]: return FREE_USER["account_number"] diff --git a/web/cypress/e2e/marketplace.cy.ts b/web/cypress/e2e/marketplace.cy.ts index 4b9a3f6170..ef13a4149e 100644 --- a/web/cypress/e2e/marketplace.cy.ts +++ b/web/cypress/e2e/marketplace.cy.ts @@ -1,3 +1,105 @@ +const marketplaceOrgResponse = [ + { + id: 1, + subscription_id: 12345678, + user_id: 36, + org_id: 37, + quantity: 2, + sku: 'MW02701', + metadata: { + title: 'premium', + privateRepos: 9007199254740991, + stripeId: 'not_a_stripe_plan', + rh_sku: 'MW02701', + sku_billing: true, + plans_page_hidden: true, + }, + }, +]; + +const marketplaceUnlimitedResponse = [ + { + id: 1, + subscription_id: 12345678, + user_id: 36, + org_id: 37, + quantity: 2, + sku: 'MW02702', + metadata: { + title: 'premium', + privateRepos: 9007199254740991, + stripeId: 'not_a_stripe_plan', + rh_sku: 'MW02702', + sku_billing: true, + plans_page_hidden: true, + }, + }, +]; + +const marketplaceUserResponse = [ + { + id: 12345678, + masterEndSystemName: 'Quay', + createdEndSystemName: 'SUBSCRIPTION', + createdDate: 1675957362000, + lastUpdateEndSystemName: 'SUBSCRIPTION', + lastUpdateDate: 1675957362000, + installBaseStartDate: 1707368400000, + installBaseEndDate: 1707368399000, + webCustomerId: 123456, + subscriptionNumber: '12399889', + quantity: 2, + effectiveStartDate: 1707368400000, + effectiveEndDate: 3813177600, + sku: 'MW02701', + assigned_to_org: null, + metadata: { + title: 'premium', + privateRepos: 100, + stripeId: 'not_a_stripe_plan', + rh_sku: 'MW02701', + sku_billing: true, + plans_page_hidden: true, + }, + }, + { + id: 11223344, + masterEndSystemName: 'Quay', + createdEndSystemName: 'SUBSCRIPTION', + createdDate: 1675957362000, + lastUpdateEndSystemName: 'SUBSCRIPTION', + lastUpdateDate: 1675957362000, + installBaseStartDate: 1707368400000, + installBaseEndDate: 1707368399000, + webCustomerId: 123456, + subscriptionNumber: '12399889', + quantity: 1, + effectiveStartDate: 1707368400000, + effectiveEndDate: 3813177600, + sku: 'MW02701', + assigned_to_org: null, + metadata: { + title: 'premium', + privateRepos: 100, + stripeId: 'not_a_stripe_plan', + rh_sku: 'MW02701', + sku_billing: true, + plans_page_hidden: true, + }, + }, +]; + +const plansResponse = { + hasSubscription: false, + isExistingCustomer: true, + plan: 'free', + usedPrivateRepos: 0, +}; +const privateResponse = { + privateAllowed: true, + privateCount: 0, +}; + describe('Marketplace Section', () => { beforeEach(() => { cy.exec('npm run quay:seed'); @@ -10,6 +112,9 @@ describe('Marketplace Section', () => { }); it('ListSubscriptions', () => { + cy.intercept('GET', '/api/v1/user/marketplace', marketplaceUserResponse); + cy.intercept('GET', '/api/v1/user/private', privateResponse); + cy.intercept('GET', '/api/v1/user/plan', plansResponse); cy.visit('/organization/user1?tab=Settings'); cy.get('#pf-tab-1-billinginformation').click(); cy.get('#user-subscription-list').contains( @@ -21,37 +126,55 @@ describe('Marketplace Section', () => { }); it('ManageSubscription', () => { + cy.intercept('GET', '/api/v1/plans', {fixture: 'plans.json'}); + cy.intercept('GET', '/api/v1/user/private', privateResponse); + cy.intercept('GET', '/api/v1/user/plan', plansResponse); + cy.intercept('GET', '/api/v1/organization/projectquay/plan', plansResponse); + cy.intercept('GET', '/api/v1/user/marketplace', marketplaceUserResponse); + cy.intercept( + 'GET', + '/api/v1/organization/projectquay/marketplace', + marketplaceOrgResponse, + ); + cy.intercept( + 'POST', + '/api/v1/organization/projectquay/marketplace', + 'Okay', + ); + cy.visit('/organization/projectquay?tab=Settings'); cy.get('#pf-tab-1-billinginformation').click(); cy.get('#attach-subscription-button').click(); cy.get('#subscription-select-toggle').click(); cy.get('#subscription-select-list').contains('2x MW02701').click(); cy.get('#confirm-subscription-select').click(); - cy.get('#org-subscription-list') - .contains('2x MW02701 attached') - .should('exist'); + cy.contains('Successfully attached subscription').should('exist'); cy.get('#remove-subscription-button').click(); cy.get('#subscription-select-toggle').click(); cy.get('#subscription-select-list').contains('2x MW02701').click(); cy.get('#confirm-subscription-select').click(); - cy.get('#org-subscription-list') - .contains('2x MW02701 attached') - .should('not.exist'); + cy.contains('Successfully removed subscription').should('exist'); }); it('ViewUnlimitedSubscriptions', () => { - cy.intercept('GET', '/api/v1/organization/projectquay/marketplace', { - fixture: 'marketplace-org.json', - }); + cy.intercept('GET', '/api/v1/plans', {fixture: 'plans.json'}); + cy.intercept( + 'GET', + '/api/v1/organization/projectquay/marketplace', + marketplaceUnlimitedResponse, + ); + cy.intercept('GET', '/api/v1/user/private', privateResponse); + cy.intercept( + 'GET', + '/api/v1/organization/projectquay/private', + privateResponse, + ); + cy.intercept('GET', '/api/v1/user/plan', plansResponse); + cy.intercept('GET', '/api/v1/organization/projectquay/plan', plansResponse); + cy.visit('/organization/projectquay?tab=Settings'); cy.get('#pf-tab-1-billinginformation').click(); - cy.get('#attach-subscription-button').click(); - cy.get('#subscription-select-toggle').click(); - cy.get('#subscription-select-list').contains('2x MW02701').click(); - cy.get('#confirm-subscription-select').click(); - cy.get('#pf-tab-0-generalsettings').click(); - cy.get('#pf-tab-1-billinginformation').click(); cy.get('#form-form') .contains('0 of unlimited private repositories used') .should('exist'); diff --git a/web/cypress/fixtures/marketplace-org.json b/web/cypress/fixtures/marketplace-org.json deleted file mode 100644 index de07a7e4c0..0000000000 --- a/web/cypress/fixtures/marketplace-org.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "id": 1, - "subscription_id": 12345678, - "user_id": 36, - "org_id": 37, - "quantity": 2, - "sku": "MW02702", - "metadata": { - "title": "premium", - "privateRepos": 9007199254740991, - "stripeId": "not_a_stripe_plan", - "rh_sku": "MW02702", - "sku_billing": true, - "plans_page_hidden": true - } - } -] diff --git a/web/cypress/test/extra-config.yaml b/web/cypress/test/extra-config.yaml index b0ecf61c51..b690e104fe 100644 --- a/web/cypress/test/extra-config.yaml +++ b/web/cypress/test/extra-config.yaml @@ -1,5 +1,3 @@ FEATURE_AUTO_PRUNE: true FEATURE_UI_V2_BUILDS: true FEATURE_BUILD_SUPPORT: true -FEATURE_BILLING: true -FEATURE_RH_MARKETPLACE: true