Revert "Revert "Rolling TexLive builds experiment"" (#28603)

* Revert "Revert "Rolling TexLive builds experiment""

* adding rolling image to allowed ones in staging (#28588)

GitOrigin-RevId: f377cacd6e4811a4bd9116c793ecbb29a7b72c33
This commit is contained in:
Jimmy Domagala-Tang
2025-09-19 10:06:15 -04:00
committed by Copybot
parent ba6edbb20a
commit 6f2381c8b6
14 changed files with 172 additions and 63 deletions
@@ -4,6 +4,12 @@ const { ObjectId } = require('mongodb-legacy')
const MODULE_PATH = '../../../../app/src/Features/Project/ProjectHelper.js'
function _mapToAllowed(images) {
return images.map(image => {
return { imageName: image.imageName, allowed: image.allowed }
})
}
describe('ProjectHelper', function () {
beforeEach(function () {
this.project = {
@@ -14,6 +20,8 @@ describe('ProjectHelper', function () {
_id: '588f3ddae8ebc1bac07c9fa4',
first_name: 'bjkdsjfk',
features: {},
labsProgram: true,
labsExperiments: ['monthly-texlive'],
}
this.adminUser = {
@@ -32,6 +40,11 @@ describe('ProjectHelper', function () {
imageDesc: 'TeX Live 2020',
alphaOnly: true,
},
{
imageName: 'texlive-full:2021.1',
imageDesc: 'TeX Live 2021',
monthlyExperimental: true,
},
],
}
@@ -128,31 +141,58 @@ describe('ProjectHelper', function () {
})
describe('getAllowedImagesForUser', function () {
it('filters out alpha-only images when the user is anonymous', function () {
it('marks alpha only images as not allowed when the user is anonymous', function () {
const images = this.ProjectHelper.getAllowedImagesForUser(null)
const imageNames = images.map(image => image.imageName)
const imageNames = _mapToAllowed(images)
expect(imageNames).to.deep.equal([
'texlive-full:2018.1',
'texlive-full:2019.1',
{ imageName: 'texlive-full:2018.1', allowed: true },
{ imageName: 'texlive-full:2019.1', allowed: true },
{ imageName: 'texlive-full:2020.1', allowed: false },
{ imageName: 'texlive-full:2021.1', allowed: false },
])
})
it('filters out alpha-only images when the user is not admin', function () {
const images = this.ProjectHelper.getAllowedImagesForUser(this.user)
const imageNames = images.map(image => image.imageName)
it('marks monthly labs images as not allowed when the user is anonymous', function () {
const images = this.ProjectHelper.getAllowedImagesForUser(null)
const imageNames = _mapToAllowed(images)
expect(imageNames).to.deep.equal([
'texlive-full:2018.1',
'texlive-full:2019.1',
{ imageName: 'texlive-full:2018.1', allowed: true },
{ imageName: 'texlive-full:2019.1', allowed: true },
{ imageName: 'texlive-full:2020.1', allowed: false },
{ imageName: 'texlive-full:2021.1', allowed: false },
])
})
it('marks monthly labs images as allowed when the user is enrolled', function () {
const images = this.ProjectHelper.getAllowedImagesForUser(this.user)
const imageNames = _mapToAllowed(images)
expect(imageNames).to.deep.equal([
{ imageName: 'texlive-full:2018.1', allowed: true },
{ imageName: 'texlive-full:2019.1', allowed: true },
{ imageName: 'texlive-full:2020.1', allowed: false },
{ imageName: 'texlive-full:2021.1', allowed: true },
])
})
it('marks alpha only images as not allowed when when the user is not admin', function () {
const images = this.ProjectHelper.getAllowedImagesForUser(this.user)
const imageNames = _mapToAllowed(images)
expect(imageNames).to.deep.equal([
{ imageName: 'texlive-full:2018.1', allowed: true },
{ imageName: 'texlive-full:2019.1', allowed: true },
{ imageName: 'texlive-full:2020.1', allowed: false },
{ imageName: 'texlive-full:2021.1', allowed: true },
])
})
it('returns all images when the user is admin', function () {
const images = this.ProjectHelper.getAllowedImagesForUser(this.adminUser)
const imageNames = images.map(image => image.imageName)
const imageNames = _mapToAllowed(images)
expect(imageNames).to.deep.equal([
'texlive-full:2018.1',
'texlive-full:2019.1',
'texlive-full:2020.1',
{ imageName: 'texlive-full:2018.1', allowed: true },
{ imageName: 'texlive-full:2019.1', allowed: true },
{ imageName: 'texlive-full:2020.1', allowed: true },
{ imageName: 'texlive-full:2021.1', allowed: false },
])
})
})