Skip to content

Commit

Permalink
Add E2E tests to mimic FF Cloud Free Tier
Browse files Browse the repository at this point in the history
  • Loading branch information
joepavitt committed Dec 23, 2024
1 parent 61bcbc7 commit 0c84d0a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/src/pages/instance/components/InstanceForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ export default {
...this.preDefinedInputs
}
}
if (this.teamInstanceLimitReached || this.teamRuntimeLimitReached) {
if (this.teamInstanceLimitReached || this.teamRuntimeLimitReached || !this.instancesAvailable) {
this.input.createInstance = false
}
},
Expand Down
22 changes: 22 additions & 0 deletions test/e2e/frontend/cypress/tests-ee/free-tier/free-tier.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
describe('FlowFuse EE - Free Tier', () => {
beforeEach(() => {
cy.login('freddie', 'ffPassword')
cy.home()
})

it('shows that Hosted Instances are a premium feature in the side navigation', () => {
cy.get('[data-nav="team-instances"]').get('[data-el="premium-feature"]').should('exist')
})

it('shows that Hosted Instances are a premium feature when on the /team/<teamId>/instances page', () => {
cy.get('[data-nav="team-instances"]').click()
cy.get('[data-el="page-banner-feature-unavailable-to-team"]').should('exist')
})

it('redirects to /application/devices after creating an Application when Hosted Instances are not enabled', () => {
cy.get('[data-el="empty-state"] [data-action="create-application"]').click()
cy.get('[data-form="application-name"] input[type="text"]').type('My Application')
cy.get('[data-action="create-project"]').click()
cy.url().should('include', '/devices')
})
})
21 changes: 21 additions & 0 deletions test/e2e/frontend/test_environment_ee.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ const { Roles } = FF_UTIL.require('forge/lib/roles')
}
})

// Mimic the FF Cloud "Free" Team Type
const userFreddie = await factory.createUser({ username: 'freddie', name: 'Freddie Fett', email: '[email protected]', password: 'ffPassword', email_verified: true, password_expired: false })
const freeTeamType = await factory.createTeamType({
name: 'Free Team',
description: 'team type description',
active: true,
order: 4,
properties: {
instances: { [flowforge.projectTypes[0].hashid]: { active: false } },
devices: {},
users: {},
features: {}
}
})
const freeTeam = await factory.createTeam({
name: 'FFeam',
TeamTypeId: freeTeamType.id
})
await factory.createSubscription(freeTeam)
await freeTeam.addUser(userFreddie, { through: { role: Roles.Owner } })

// create a snapshot on DeviceB
const deviceB = flowforge.applicationDevices.find((device) => device.name === 'application-device-b')
await factory.createDeviceSnapshot({ name: 'application-device-b snapshot 1' }, deviceB, userTerry)
Expand Down

0 comments on commit 0c84d0a

Please sign in to comment.