2020-07-09 09:49:02 -04:00
|
|
|
const { expect } = require('chai')
|
|
|
|
const UserHelper = require('../src/helpers/UserHelper')
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('BetaProgram', function () {
|
2020-07-09 09:49:02 -04:00
|
|
|
let email, userHelper
|
2021-04-14 09:17:21 -04:00
|
|
|
beforeEach(async function () {
|
2020-07-09 09:49:02 -04:00
|
|
|
userHelper = new UserHelper()
|
|
|
|
email = userHelper.getDefaultEmail()
|
|
|
|
userHelper = await UserHelper.createUser({ email })
|
|
|
|
userHelper = await UserHelper.loginUser({
|
|
|
|
email,
|
2021-04-27 03:52:58 -04:00
|
|
|
password: userHelper.getDefaultPassword(),
|
2020-07-09 09:49:02 -04:00
|
|
|
})
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should opt in', async function () {
|
2022-10-17 09:53:55 -04:00
|
|
|
const response = await userHelper.fetch('/beta/opt-in', { method: 'POST' })
|
|
|
|
expect(response.status).to.equal(302)
|
|
|
|
expect(response.headers.get('location')).to.equal(
|
|
|
|
UserHelper.url('/beta/participate').toString()
|
|
|
|
)
|
|
|
|
const user = (await UserHelper.getUser({ email })).user
|
2020-07-09 09:49:02 -04:00
|
|
|
expect(user.betaProgram).to.equal(true)
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
it('should opt out', async function () {
|
2022-10-17 09:53:55 -04:00
|
|
|
const response = await userHelper.fetch('/beta/opt-out', { method: 'POST' })
|
|
|
|
expect(response.status).to.equal(302)
|
|
|
|
expect(response.headers.get('location')).to.equal(
|
|
|
|
UserHelper.url('/beta/participate').toString()
|
|
|
|
)
|
|
|
|
const user = (await UserHelper.getUser({ email })).user
|
2020-07-09 09:49:02 -04:00
|
|
|
expect(user.betaProgram).to.equal(false)
|
|
|
|
})
|
|
|
|
})
|