Skip to content

Commit

Permalink
fixing other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcusk19 committed Feb 5, 2024
1 parent fd16e5a commit 67f2cf1
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 39 deletions.
1 change: 0 additions & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions util/marketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,14 @@ def get_list_of_subscriptions(
"username": "free_user",
}

E2E_TEST_USER_EMAIL = "user1@redhat.com"


class FakeUserApi(RedHatUserApi):
"""
Fake class used for tests
"""

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"]
Expand Down
153 changes: 138 additions & 15 deletions web/cypress/e2e/marketplace.cy.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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(
Expand All @@ -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');
Expand Down
18 changes: 0 additions & 18 deletions web/cypress/fixtures/marketplace-org.json

This file was deleted.

2 changes: 0 additions & 2 deletions web/cypress/test/extra-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
FEATURE_AUTO_PRUNE: true
FEATURE_UI_V2_BUILDS: true
FEATURE_BUILD_SUPPORT: true
FEATURE_BILLING: true
FEATURE_RH_MARKETPLACE: true

0 comments on commit 67f2cf1

Please sign in to comment.