Skip to content

Commit

Permalink
Remove tenant plan tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janslifka committed Dec 2, 2024
1 parent 315ec08 commit bf126a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 196 deletions.
186 changes: 1 addition & 185 deletions cypress/e2e/tenants/tenants.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ describe('Tenants', () => {
cy.getListingItem(tenant.tenantName).find('.title a').click()
}

const fillPlan = (plan, trial) => {
cy.fillFields(plan)
if (trial) {
cy.checkToggle('test')
} else {
cy.uncheckToggle('test')
}
cy.clickModalAction()
cy.getCy('modal_tenant_plan-edit').should('not.be.visible')
}

const createPlan = (plan, trial, expectActive) => {
cy.getCy('tenant-detail_add-plan').click()
fillPlan(plan, trial)
}

const expectAppName = (tenantName) => {
cy.getCy('detail-page_header-title').contains(tenantName).should('exist')
}
Expand All @@ -56,30 +40,12 @@ describe('Tenants', () => {
cy.getCy('detail-page_metadata_enabled').find('.badge.bg-success').contains('Enabled').should('exist')
}

const expectDisabled = () => {
cy.getCy('detail-page_metadata_enabled').find('.badge.bg-danger').contains('Disabled').should('exist')
}

const expectPlan = (plan, trial, expectActive) => {
cy.getCy('plans-list_name').contains(plan.name).should('exist')
if (trial) {
cy.getCy('plans-list_name').find('.badge.bg-secondary').contains('Trial').should('exist')
}

cy.getCy('plans-list_name').find('.badge.bg-success').should(expectActive ? 'exist' : 'not.exist')
cy.getCy('plans-list_users').contains(plan.users || '-').should('exist')
cy.getCy('plans-list_from').contains(`${plan.sinceDay}. ${plan.sinceMonth}. ${plan.sinceYear}`).should('exist')
cy.getCy('plans-list_to').contains(`${plan.untilDay}. ${plan.untilMonth}. ${plan.untilYear}`).should('exist')
}


before(() => {
cy.task('user:delete', { email: superAdmin.email })
cy.createUser(superAdmin)
cy.task('user:addPermission', { perm: 'TENANT_PERM', email: superAdmin.email })
})


beforeEach(() => {
cy.task('tenant:delete', { tenant_id: tenant.tenantId })
cy.task('tenant:delete', { tenant_id: newApp.tenantId })
Expand Down Expand Up @@ -112,154 +78,4 @@ describe('Tenants', () => {
expectAppId(newApp.tenantId)
expectEnabled()
})


it('add past plan', () => {
createApp()

const plan = {
name: 'Past plan',
users: '10',
sinceDay: '10',
sinceMonth: '10',
sinceYear: '2020',
untilDay: '20',
untilMonth: '12',
untilYear: '2020',
}
createPlan(plan, true, false)
expectPlan(plan, true, false)
expectDisabled()
})


it('add current plan', () => {
createApp()

const plan = {
name: 'Current plan',
users: '10',
sinceDay: '10',
sinceMonth: '10',
sinceYear: '2020',
untilDay: '20',
untilMonth: '12',
untilYear: '2050',
}
createPlan(plan, false, true)
expectPlan(plan, false, true)
expectEnabled()
})


it('add future plan', () => {
createApp()

const plan = {
name: 'Future plan',
users: '10',
sinceDay: '10',
sinceMonth: '10',
sinceYear: '2070',
untilDay: '20',
untilMonth: '12',
untilYear: '2080',
}
createPlan(plan, false, false)
expectPlan(plan, false, false)
expectDisabled()
})


it('edit plan', () => {
createApp()

// create current plan
const plan = {
name: 'Current plan',
users: '10',
sinceDay: '10',
sinceMonth: '10',
sinceYear: '2020',
untilDay: '24',
untilMonth: '12',
untilYear: '2050',
}
createPlan(plan, false, true)
expectPlan(plan, false, true)
expectEnabled()

// edit it to be a past plan
const plan2 = {
name: 'Past plan now',
users: '13',
sinceDay: '10',
sinceMonth: '10',
sinceYear: '2020',
untilDay: '23',
untilMonth: '12',
untilYear: '2020',
}
cy.getCy('tenant-detail_plan_edit').click()
fillPlan(plan2, true)
expectPlan(plan2, true, false)
expectDisabled()

// edit it to be a future plan
const plan3 = {
name: 'Future plan now',
users: '16',
sinceDay: '10',
sinceMonth: '10',
sinceYear: '2060',
untilDay: '22',
untilMonth: '12',
untilYear: '2070',
}
cy.getCy('tenant-detail_plan_edit').click()
fillPlan(plan3, false)
expectPlan(plan3, false, false)
expectDisabled()

// edit it to be a current plan again
const plan4 = {
name: 'Current plan now',
users: '19',
sinceDay: '10',
sinceMonth: '10',
sinceYear: '2000',
untilDay: '21',
untilMonth: '12',
untilYear: '2070',
}
cy.getCy('tenant-detail_plan_edit').click()
fillPlan(plan4, false)
expectPlan(plan4, false, true)
expectEnabled()
})


it('delete plan', () => {
createApp()

// create current plan
const plan = {
name: 'Current plan',
users: '10',
sinceDay: '10',
sinceMonth: '10',
sinceYear: '2020',
untilDay: '24',
untilMonth: '12',
untilYear: '2050',
}
createPlan(plan, false, true)
expectPlan(plan, false, true)
expectEnabled()

cy.getCy('tenant-detail_plan_delete').click()
cy.clickModalAction()
cy.getCy('modal_tenant_plan-delete').should('not.be.visible')
expectDisabled()
})
})
})
22 changes: 11 additions & 11 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ module.exports = (on, config) => {
await userDelete({ tenant_uuid: uuid })
await pg.delete({ table: 'action_key', where: { tenant_uuid: uuid } })
await pg.delete({ table: 'locale', where: { tenant_uuid: uuid } })
await pg.delete({ table: 'tenant_plan', where: { tenant_uuid: uuid } })
await pg.delete({ table: 'tenant', where: { uuid } })
}
return true
Expand Down Expand Up @@ -221,16 +220,16 @@ module.exports = (on, config) => {
return pg.update({
table: 'tenant_limit_bundle',
values: {
active_users: null,
branches: null,
document_template_drafts: null,
document_templates: null,
documents: null,
knowledge_models: null,
locales: null,
questionnaires: null,
storage: null,
users: null,
active_users: -10000,
branches: -10000,
document_template_drafts: -10000,
document_templates: -10000,
documents: -10000,
knowledge_models: -10000,
locales: -10000,
questionnaires: -10000,
storage: -10000,
users: -10000,
},
where
})
Expand All @@ -255,6 +254,7 @@ module.exports = (on, config) => {
const result = await pg.get({ table: 'user_entity', where })
for (let i = 0; i < result.rows.length; i++) {
const { uuid } = result.rows[i]
await pg.delete({ table: 'audit', where: { created_by: uuid } })
await pg.delete({ table: 'action_key', where: { identity: uuid } })
await pg.delete({ table: 'user_token', where: { user_uuid: uuid } })
await pg.delete({ table: 'persistent_command', where: { created_by: uuid } })
Expand Down

0 comments on commit bf126a0

Please sign in to comment.