0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 18:07:17 +01:00
posthog/cypress/integration/featureFlags.js
Karl-Aksel Puulmann da92f0bbac
Allow rolling feature flags out to multiple groups (#3030)
* Support multiple groups in feature flags model

This will be part of #3007

I did not do a migration since it would cause errors for decide endpoint
once migrations have run but new schema not up.

* Update analytics_metadata method

* Allow defining multiple groups in frontend

* Allow sorting

* Update tests, allow submit without filters.

* Update cypress

* Avoid N+1 queries

* Indicate filters better in table
2021-01-26 01:18:05 +02:00

48 lines
2.2 KiB
JavaScript

describe('Feature Flags', () => {
beforeEach(() => {
cy.visit('/feature_flags')
})
it('Create feature flag', () => {
cy.get('h1').should('contain', 'Feature Flags')
cy.get('[data-attr=new-feature-flag]').click()
cy.get('[data-attr=feature-flag-name').type('beta feature').should('have.value', 'beta feature')
cy.get('[data-attr=feature-flag-key').should('have.value', 'beta-feature')
// select "add filter" and "property"
cy.get('[data-attr=new-prop-filter-feature-flag-undefined-0-1').click()
// select the first property
cy.get('[data-attr=property-filter-dropdown]').click()
cy.get('[data-attr=prop-filter-person-0]').click({ force: true })
// selects the first value
cy.get('[data-attr=prop-val]').click()
cy.get('[data-attr=prop-val-0]').click({ force: true })
cy.get('[data-attr=feature-flag-switch').click()
cy.get('[data-attr=feature-flag-submit').click()
cy.get('[data-attr=feature-flag-table').should('contain', 'beta feature')
cy.get('[data-attr=feature-flag-table').should('contain', '30%')
cy.get('[data-attr=feature-flag-table').should('contain', 'is_demo')
cy.get('[data-attr=feature-flag-table] tr:first-child td:first-child').click()
cy.get('[data-attr=feature-flag-name').type(' updated').should('have.value', 'beta feature updated')
cy.get('[data-attr=feature-flag-submit').click()
cy.get('[data-attr=feature-flag-table').should('contain', 'beta feature updated')
})
it('Delete feature flag', () => {
cy.get('h1').should('contain', 'Feature Flags')
cy.get('[data-attr=new-feature-flag]').click()
cy.get('[data-attr=feature-flag-name').type('to be deleted').should('have.value', 'to be deleted')
cy.get('[data-attr=feature-flag-key').should('have.value', 'to-be-deleted')
cy.get('[data-attr=feature-flag-switch').click()
cy.get('[data-attr=feature-flag-submit').click()
cy.get('[data-attr=feature-flag-table').should('contain', 'to be deleted')
cy.get('[data-row-key="to-be-deleted"]').click()
cy.get('[data-attr=delete-flag]').click()
cy.contains('Click to undo').should('exist')
})
})