Repository navigation
Allow Extra NR catalogues to be included from the TeamType #8946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5b8f9f6
dc45bd1
e37d811
4a3f382
1463d86
f9ba1b5
b8175d5
79a8f01
ee3c360
d1a1eb6
ed3f32c
b99d779
e8e85b4
226db2e
acdd648
6a0892b
ce6402c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1907,6 +1907,34 @@ describe('Device API', async function () { | |
| `) | ||
| }) | ||
| }) | ||
| describe('Extra Catalogues from TeamType', function () { | ||
| async function setTeamTypeCatalogues (cats) { | ||
| const defaultTeamTypeProperties = app.defaultTeamType.properties | ||
| defaultTeamTypeProperties.extraCatalogues = cats | ||
| app.defaultTeamType.properties = defaultTeamTypeProperties | ||
| await app.defaultTeamType.save() | ||
| } | ||
|
Comment on lines
+1911
to
+1916
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this mutates deaullt team type. Maybe a before (to store original) and an afterEach (to reset it) is needed? |
||
| let cats | ||
| before(async function () { | ||
| const defaultTeamTypeProperties = app.defaultTeamType.properties | ||
| cats = defaultTeamTypeProperties.extraCatalogues | ||
| }) | ||
| afterEach(async function () { | ||
| const defaultTeamTypeProperties = app.defaultTeamType.properties | ||
| defaultTeamTypeProperties.extraCatalogues = cats | ||
| app.defaultTeamType.properties = defaultTeamTypeProperties | ||
| await app.defaultTeamType.save() | ||
| }) | ||
| it('should include catalogues from TeamType', async function () { | ||
| await setTeamTypeCatalogues([ | ||
| 'https://example.com/cat-from-team-type.json' | ||
| ]) | ||
| const device = await createDevice({ name: 'CertifiedNodes', type: '', team: TestObjects.ATeam.hashid, as: TestObjects.tokens.alice }) | ||
| const liveSettings = await getLiveSettings(device) | ||
| liveSettings.palette.should.have.property('catalogues') | ||
| liveSettings.palette.catalogues.should.containEql('https://example.com/cat-from-team-type.json') | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| describe('device remote editor (unlicensed)', function () { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1111,6 +1111,109 @@ describe('Project API', function () { | |
| `) | ||
| }) | ||
| }) | ||
| describe('Apply TeamType extra Catalogues', function () { | ||
| async function setTeamTypeCatalogues (cats) { | ||
| const defaultTeamTypeProperties = app.defaultTeamType.properties | ||
| defaultTeamTypeProperties.extraCatalogues = cats | ||
| app.defaultTeamType.properties = defaultTeamTypeProperties | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same mutation as device tests - should we have before (to capture starting value) and afterEach (to restoire)? |
||
| await app.defaultTeamType.save() | ||
| } | ||
| let cats | ||
| before(async function () { | ||
| const defaultTeamTypeProperties = app.defaultTeamType.properties | ||
| cats = defaultTeamTypeProperties.extraCatalogues | ||
| }) | ||
| afterEach(async function () { | ||
| const defaultTeamTypeProperties = app.defaultTeamType.properties | ||
| defaultTeamTypeProperties.extraCatalogues = cats | ||
| app.defaultTeamType.properties = defaultTeamTypeProperties | ||
| await app.defaultTeamType.save() | ||
| }) | ||
| it('Should add extra catalogue to project', async function () { | ||
| await setTeamTypeCatalogues([ | ||
| 'https://example.com/team-type-cat.json' | ||
| ]) | ||
|
|
||
| const projectName = generateProjectName() | ||
| const response = await app.inject({ | ||
| method: 'POST', | ||
| url: '/api/v1/projects', | ||
| payload: { | ||
| name: projectName, | ||
| applicationId: TestObjects.ApplicationA.hashid, | ||
| projectType: TestObjects.projectType1.hashid, | ||
| template: TestObjects.template1.hashid, | ||
| stack: TestObjects.stack1.hashid | ||
| }, | ||
| cookies: { sid: TestObjects.tokens.alice } | ||
| }) | ||
| response.statusCode.should.equal(200) | ||
| const result = response.json() | ||
|
|
||
| const newProject = await app.db.models.Project.byId(result.id) | ||
| const newAccessToken = (await newProject.refreshAuthTokens()).token | ||
| const runtimeSettings = (await app.inject({ | ||
| method: 'GET', | ||
| url: `/api/v1/projects/${newProject.id}/settings`, | ||
| headers: { | ||
| authorization: `Bearer ${newAccessToken}` | ||
| } | ||
| })).json() | ||
|
|
||
| const settings = runtimeSettings.settings | ||
| settings.should.have.property('palette') | ||
| settings.palette.should.have.property('npmrc') | ||
| settings.palette.should.have.property('catalogue') | ||
| settings.palette.catalogue.should.containEql('https://example.com/team-type-cat.json') | ||
| }) | ||
| it('Should add extra catalogue to project only if not present', async function () { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sends a duplicate but never asserts it appears. It splices the two entries out and then asserts Noted the device spec has no dedupe test either. Additionally, I think a test that uses URLs which differ only in form but resolve to the same catalogue (e.g. |
||
| await setTeamTypeCatalogues([ | ||
| 'https://example.com/team-type-cat.json', | ||
| 'https://EXAMPLE.com/team-type-cat.json', | ||
| 'https://example.com/cat2.json' | ||
| ]) | ||
|
|
||
| const projectName = generateProjectName() | ||
| const response = await app.inject({ | ||
| method: 'POST', | ||
| url: '/api/v1/projects', | ||
| payload: { | ||
| name: projectName, | ||
| applicationId: TestObjects.ApplicationA.hashid, | ||
| projectType: TestObjects.projectType1.hashid, | ||
| template: TestObjects.template1.hashid, | ||
| stack: TestObjects.stack1.hashid | ||
| }, | ||
| cookies: { sid: TestObjects.tokens.alice } | ||
| }) | ||
| response.statusCode.should.equal(200) | ||
| const result = response.json() | ||
|
|
||
| const newProject = await app.db.models.Project.byId(result.id) | ||
| const newAccessToken = (await newProject.refreshAuthTokens()).token | ||
| const runtimeSettings = (await app.inject({ | ||
| method: 'GET', | ||
| url: `/api/v1/projects/${newProject.id}/settings`, | ||
| headers: { | ||
| authorization: `Bearer ${newAccessToken}` | ||
| } | ||
| })).json() | ||
|
|
||
| const settings = runtimeSettings.settings | ||
| settings.should.have.property('palette') | ||
| settings.palette.should.have.property('npmrc') | ||
| settings.palette.should.have.property('catalogue') | ||
| settings.palette.catalogue.should.have.length(6) | ||
| settings.palette.catalogue.should.containEql('https://example.com/team-type-cat.json') | ||
| settings.palette.catalogue.should.containEql('https://example.com/cat2.json') | ||
| let index = settings.palette.catalogue.indexOf('https://example.com/team-type-cat.json') | ||
| settings.palette.catalogue.splice(index, 1) | ||
| index = settings.palette.catalogue.indexOf('https://example.com/cat2.json') | ||
| settings.palette.catalogue.splice(index, 1) | ||
| settings.palette.catalogue.should.not.containEql('https://example.com/cat2.json') | ||
| settings.palette.catalogue.should.have.length(4) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| describe('Apply Flow Blueprint', function () { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getProperty('extraCatalogues')is the guard, but the loop readsteam.TeamType.properties.extraCataloguesdirectly. If a team-level override ever exists, the check and the value come from different places. Use one source, e.g.const extra = team.getProperty('extraCatalogues', null)and loop overextra.Array.isArray(extra)and skip entries that are not valid URL strings, so bad stored data can't break the block (or add a character per iteration if it is a string).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this only runs inside the
platformNPMEnabled && (certifiedNodes || ffNodes)block, but the UI disables the field based oncertifiedNodesonly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because ffNodes adds a URL to the list, but the override box is to ONLY add more certified nodes catalogues