From 4429a50e06f142ec494d2e44cc6ae01b4b0da6e0 Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 2 Feb 2026 20:19:01 +0100 Subject: [PATCH] snapshots --- web_src/js/render/log.test.ts | 91 ++++++++++++++++++++++++----------- web_src/js/render/log.ts | 3 -- 2 files changed, 63 insertions(+), 31 deletions(-) diff --git a/web_src/js/render/log.test.ts b/web_src/js/render/log.test.ts index 610d3cba0e..c8ea0a6508 100644 --- a/web_src/js/render/log.test.ts +++ b/web_src/js/render/log.test.ts @@ -17,26 +17,40 @@ test('filters workflow command lines from log output', () => { {index: 9, timestamp: 1008, message: 'Build complete'}, ]; - const expectedVisibleMessages = [ - 'Starting build process', - 'Running tests...', - 'Test suite started', - '::workflow-command::echo some-output', - 'All tests passed', - 'Build complete', - ]; - - const visibleLines = filterLogLines(inputLogLines); - - expect(visibleLines.length).toBe(6); - - const visibleMessages = visibleLines.map((line) => line.message); - expect(visibleMessages).toEqual(expectedVisibleMessages); - - expect(visibleMessages).not.toContain('::add-matcher::.github/problem-matcher.json'); - expect(visibleMessages).not.toContain('##[add-matcher].github/eslint.json'); - expect(visibleMessages).toContain('::workflow-command::echo some-output'); - expect(visibleMessages).not.toContain('::remove-matcher::owner=eslint'); + expect(filterLogLines(inputLogLines)).toMatchInlineSnapshot(` + [ + { + "index": 1, + "message": "Starting build process", + "timestamp": 1000, + }, + { + "index": 3, + "message": "Running tests...", + "timestamp": 1002, + }, + { + "index": 5, + "message": "Test suite started", + "timestamp": 1004, + }, + { + "index": 6, + "message": "::workflow-command::echo some-output", + "timestamp": 1005, + }, + { + "index": 7, + "message": "All tests passed", + "timestamp": 1006, + }, + { + "index": 9, + "message": "Build complete", + "timestamp": 1008, + }, + ] + `); }); test('preserves non-workflow command lines including group commands', () => { @@ -49,12 +63,33 @@ test('preserves non-workflow command lines including group commands', () => { {index: 6, timestamp: 1005, message: 'Done'}, ]; - const visibleLines = filterLogLines(inputLogLines); - - expect(visibleLines.length).toBe(5); - - const visibleMessages = visibleLines.map((line) => line.message); - expect(visibleMessages).toContain('::group::Installation'); - expect(visibleMessages).toContain('::endgroup::'); - expect(visibleMessages).not.toContain('::add-matcher::.github/npm.json'); + expect(filterLogLines(inputLogLines)).toMatchInlineSnapshot(` + [ + { + "index": 1, + "message": "Normal log line", + "timestamp": 1000, + }, + { + "index": 2, + "message": "::group::Installation", + "timestamp": 1001, + }, + { + "index": 3, + "message": "Installing dependencies", + "timestamp": 1002, + }, + { + "index": 5, + "message": "::endgroup::", + "timestamp": 1004, + }, + { + "index": 6, + "message": "Done", + "timestamp": 1005, + }, + ] + `); }); diff --git a/web_src/js/render/log.ts b/web_src/js/render/log.ts index 91ee9cd4f7..1409ca7a87 100644 --- a/web_src/js/render/log.ts +++ b/web_src/js/render/log.ts @@ -1,6 +1,3 @@ -// Copyright 2025 The Gitea Authors. All rights reserved. -// SPDX-License-Identifier: MIT - export type LogLine = { index: number; timestamp: number;