Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(test): write gate summary fixtures into private mkdtemp directories

M9fcf282b97f9
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 609d6da58..7496c0a55 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.737",
+ "version": "0.1.738",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.737",
+ "version": "0.1.738",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index 6c036e6f1..71eef4fcc 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.737",
+ "version": "0.1.738",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/control-ui/test/__tests__/gfsDragAndDropGate.test.ts b/control-ui/test/__tests__/gfsDragAndDropGate.test.ts
index 550057070..5ca7157bd 100644
--- a/control-ui/test/__tests__/gfsDragAndDropGate.test.ts
+++ b/control-ui/test/__tests__/gfsDragAndDropGate.test.ts
@@ -246,59 +246,69 @@ describe('EvenDrive drag-and-drop E2E gate', () => {
describe('sanitized run summary', () => {
it('binds the revision, the selected cases, the outcomes and the exit code', () => {
- const filePath = path.join(os.tmpdir(), `gfs-dnd-summary-${LANE}.json`)
- const report = journeyReport([{ title: 'journey one' }, { title: 'journey two' }])
- const summary = writeSanitizedRunSummary({
- lane: LANE,
- revision: 'abc123',
- branch: 'feat/example',
- command: COMMAND,
- report,
- run: { status: 0 },
- selectedJourneys: collectReportJourneys(report),
- verdict: 'pass',
- filePath,
- })
+ // A uniquely created directory, never a predictably named file directly
+ // in the system temporary directory (CodeQL js/insecure-temporary-file).
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gfs-dnd-summary-'))
+ const filePath = path.join(dir, 'playwright-summary.json')
+ try {
+ const report = journeyReport([{ title: 'journey one' }, { title: 'journey two' }])
+ const summary = writeSanitizedRunSummary({
+ lane: LANE,
+ revision: 'abc123',
+ branch: 'feat/example',
+ command: COMMAND,
+ report,
+ run: { status: 0 },
+ selectedJourneys: collectReportJourneys(report),
+ verdict: 'pass',
+ filePath,
+ })
- expect(summary).toMatchObject({
- lane: LANE,
- revision: 'abc123',
- branch: 'feat/example',
- command: COMMAND,
- processExit: 0,
- verdict: 'pass',
- })
- expect(summary.selected).toEqual(['journey one', 'journey two'])
- expect(summary.journeys).toEqual([
- { title: 'journey one', status: 'expected' },
- { title: 'journey two', status: 'expected' },
- ])
- expect(JSON.parse(fs.readFileSync(filePath, 'utf8'))).toEqual(summary)
- fs.rmSync(filePath, { force: true })
+ expect(summary).toMatchObject({
+ lane: LANE,
+ revision: 'abc123',
+ branch: 'feat/example',
+ command: COMMAND,
+ processExit: 0,
+ verdict: 'pass',
+ })
+ expect(summary.selected).toEqual(['journey one', 'journey two'])
+ expect(summary.journeys).toEqual([
+ { title: 'journey one', status: 'expected' },
+ { title: 'journey two', status: 'expected' },
+ ])
+ expect(JSON.parse(fs.readFileSync(filePath, 'utf8'))).toEqual(summary)
+ } finally {
+ fs.rmSync(dir, { recursive: true, force: true })
+ }
})
it('does not carry the raw report text into the summary', () => {
- const filePath = path.join(os.tmpdir(), `gfs-dnd-summary-private-${LANE}.json`)
- const report = {
- ...journeyReport([{ title: 'journey one', outcome: 'unexpected' }]),
- errors: [{ message: 'the upstream said: private-token-value' }],
- }
- const summary = writeSanitizedRunSummary({
- lane: LANE,
- revision: 'abc123',
- branch: 'feat/example',
- command: COMMAND,
- report,
- run: { status: 1 },
- selectedJourneys: collectReportJourneys(report),
- verdict: 'fail',
- filePath,
- })
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gfs-dnd-summary-'))
+ const filePath = path.join(dir, 'playwright-summary.json')
+ try {
+ const report = {
+ ...journeyReport([{ title: 'journey one', outcome: 'unexpected' }]),
+ errors: [{ message: 'the upstream said: private-token-value' }],
+ }
+ const summary = writeSanitizedRunSummary({
+ lane: LANE,
+ revision: 'abc123',
+ branch: 'feat/example',
+ command: COMMAND,
+ report,
+ run: { status: 1 },
+ selectedJourneys: collectReportJourneys(report),
+ verdict: 'fail',
+ filePath,
+ })
- expect(JSON.stringify(summary)).not.toContain('private-token-value')
- expect(summary.processExit).toBe(1)
- expect(summary.verdict).toBe('fail')
- fs.rmSync(filePath, { force: true })
+ expect(JSON.stringify(summary)).not.toContain('private-token-value')
+ expect(summary.processExit).toBe(1)
+ expect(summary.verdict).toBe('fail')
+ } finally {
+ fs.rmSync(dir, { recursive: true, force: true })
+ }
})
})
diff --git a/desktop-app/test/__tests__/gfsDragAndDropGate.test.ts b/desktop-app/test/__tests__/gfsDragAndDropGate.test.ts
index cf476f516..b40f0b914 100644
--- a/desktop-app/test/__tests__/gfsDragAndDropGate.test.ts
+++ b/desktop-app/test/__tests__/gfsDragAndDropGate.test.ts
@@ -252,59 +252,69 @@ describe('EvenDrive drag-and-drop Desktop E2E gate', () => {
describe('sanitized run summary', () => {
it('binds the revision, the selected cases, the outcomes and the exit code', () => {
- const filePath = path.join(os.tmpdir(), `gfs-dnd-summary-${LANE}.json`)
- const report = journeyReport([{ title: 'journey one' }, { title: 'journey two' }])
- const summary = writeSanitizedRunSummary({
- lane: LANE,
- revision: 'abc123',
- branch: 'feat/example',
- command: COMMAND,
- report,
- run: { status: 0 },
- selectedJourneys: collectReportJourneys(report),
- verdict: 'pass',
- filePath,
- })
+ // A uniquely created directory, never a predictably named file directly
+ // in the system temporary directory (CodeQL js/insecure-temporary-file).
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gfs-dnd-summary-'))
+ const filePath = path.join(dir, 'playwright-summary.json')
+ try {
+ const report = journeyReport([{ title: 'journey one' }, { title: 'journey two' }])
+ const summary = writeSanitizedRunSummary({
+ lane: LANE,
+ revision: 'abc123',
+ branch: 'feat/example',
+ command: COMMAND,
+ report,
+ run: { status: 0 },
+ selectedJourneys: collectReportJourneys(report),
+ verdict: 'pass',
+ filePath,
+ })
- expect(summary).toMatchObject({
- lane: LANE,
- revision: 'abc123',
- branch: 'feat/example',
- command: COMMAND,
- processExit: 0,
- verdict: 'pass',
- })
- expect(summary.selected).toEqual(['journey one', 'journey two'])
- expect(summary.journeys).toEqual([
- { title: 'journey one', status: 'expected' },
- { title: 'journey two', status: 'expected' },
- ])
- expect(JSON.parse(fs.readFileSync(filePath, 'utf8'))).toEqual(summary)
- fs.rmSync(filePath, { force: true })
+ expect(summary).toMatchObject({
+ lane: LANE,
+ revision: 'abc123',
+ branch: 'feat/example',
+ command: COMMAND,
+ processExit: 0,
+ verdict: 'pass',
+ })
+ expect(summary.selected).toEqual(['journey one', 'journey two'])
+ expect(summary.journeys).toEqual([
+ { title: 'journey one', status: 'expected' },
+ { title: 'journey two', status: 'expected' },
+ ])
+ expect(JSON.parse(fs.readFileSync(filePath, 'utf8'))).toEqual(summary)
+ } finally {
+ fs.rmSync(dir, { recursive: true, force: true })
+ }
})
it('does not carry the raw report text into the summary', () => {
- const filePath = path.join(os.tmpdir(), `gfs-dnd-summary-private-${LANE}.json`)
- const report = {
- ...journeyReport([{ title: 'journey one', outcome: 'unexpected' }]),
- errors: [{ message: 'the upstream said: private-token-value' }],
- }
- const summary = writeSanitizedRunSummary({
- lane: LANE,
- revision: 'abc123',
- branch: 'feat/example',
- command: COMMAND,
- report,
- run: { status: 1 },
- selectedJourneys: collectReportJourneys(report),
- verdict: 'fail',
- filePath,
- })
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gfs-dnd-summary-'))
+ const filePath = path.join(dir, 'playwright-summary.json')
+ try {
+ const report = {
+ ...journeyReport([{ title: 'journey one', outcome: 'unexpected' }]),
+ errors: [{ message: 'the upstream said: private-token-value' }],
+ }
+ const summary = writeSanitizedRunSummary({
+ lane: LANE,
+ revision: 'abc123',
+ branch: 'feat/example',
+ command: COMMAND,
+ report,
+ run: { status: 1 },
+ selectedJourneys: collectReportJourneys(report),
+ verdict: 'fail',
+ filePath,
+ })
- expect(JSON.stringify(summary)).not.toContain('private-token-value')
- expect(summary.processExit).toBe(1)
- expect(summary.verdict).toBe('fail')
- fs.rmSync(filePath, { force: true })
+ expect(JSON.stringify(summary)).not.toContain('private-token-value')
+ expect(summary.processExit).toBe(1)
+ expect(summary.verdict).toBe('fail')
+ } finally {
+ fs.rmSync(dir, { recursive: true, force: true })
+ }
})
})