From 0b923a03b41c69c9eb29c9070168417b91b315fa Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Sun, 28 Sep 2025 18:53:18 +0200 Subject: [PATCH] test: fix 'Missing required prop' warning during RepoActionView frontend tests (#9454) Fixes warnings in the `RepoActionView.test.js`, introduced in #9444 but caused by the frontend tests not providing all required properties to the component. ``` stderr | web_src/js/components/RepoActionView.test.js > processes ##[group] and ##[endgroup] [Vue warn]: Missing required prop: "runIndex" at at ``` ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [x] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [x] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9454 Reviewed-by: Earl Warren Co-authored-by: Mathieu Fenniak Co-committed-by: Mathieu Fenniak --- web_src/js/components/RepoActionView.test.js | 74 ++++++-------------- 1 file changed, 20 insertions(+), 54 deletions(-) diff --git a/web_src/js/components/RepoActionView.test.js b/web_src/js/components/RepoActionView.test.js index c304e1915d..8107b89c07 100644 --- a/web_src/js/components/RepoActionView.test.js +++ b/web_src/js/components/RepoActionView.test.js @@ -53,6 +53,18 @@ const minimalInitialJobData = { const minimalInitialArtifactData = { artifacts: [], }; +const defaultTestProps = { + actionsURL: 'https://example.com/example-org/example-repo/actions', + jobIndex: '1', + attemptNumber: '1', + runIndex: '10', + runID: '1001', + initialJobData: minimalInitialJobData, + initialArtifactData: minimalInitialArtifactData, + locale: testLocale, + workflowName: 'workflow name', + workflowURL: 'https://example.com/example-org/example-repo/actions?workflow=test.yml', +}; test('processes ##[group] and ##[endgroup]', async () => { Object.defineProperty(document.documentElement, 'lang', {value: 'en'}); @@ -105,13 +117,7 @@ test('processes ##[group] and ##[endgroup]', async () => { }); const wrapper = mount(RepoActionView, { - props: { - jobIndex: '1', - attemptNumber: '1', - initialJobData: minimalInitialJobData, - initialArtifactData: minimalInitialArtifactData, - locale: testLocale, - }, + props: defaultTestProps, }); await flushPromises(); await wrapper.get('.job-step-summary').trigger('click'); @@ -208,15 +214,7 @@ test('load multiple steps on a finished action', async () => { }); const wrapper = mount(RepoActionView, { - props: { - actionsURL: 'https://example.com/example-org/example-repo/actions', - initialJobData: minimalInitialJobData, - initialArtifactData: minimalInitialArtifactData, - runIndex: '1', - jobIndex: '2', - attemptNumber: '1', - locale: testLocale, - }, + props: defaultTestProps, }); wrapper.vm.loadJob(); // simulate intermittent reload immediately so UI switches from minimalInitialJobData to the mock data from the test's fetch spy. await flushPromises(); @@ -288,13 +286,11 @@ function configureForMultipleAttemptTests({viewHistorical}) { const wrapper = mount(RepoActionView, { props: { + ...defaultTestProps, runIndex: '123', - jobIndex: '1', attemptNumber: viewHistorical ? '1' : '2', actionsURL: toAbsoluteUrl('/user1/repo2/actions'), initialJobData: {...minimalInitialJobData, state: myJobState}, - initialArtifactData: minimalInitialArtifactData, - locale: testLocale, }, }); return wrapper; @@ -465,16 +461,7 @@ test('artifacts download links', async () => { }); const wrapper = mount(RepoActionView, { - props: { - actionsURL: 'https://example.com/example-org/example-repo/actions', - initialJobData: minimalInitialJobData, - initialArtifactData: minimalInitialArtifactData, - runIndex: '10', - runID: '1001', - jobIndex: '2', - attemptNumber: '1', - locale: testLocale, - }, + props: defaultTestProps, }); wrapper.vm.loadJob(); // simulate intermittent reload immediately so UI switches from minimalInitialJobData to the mock data from the test's fetch spy. await flushPromises(); @@ -501,11 +488,8 @@ test('initial load schedules refresh when job is not done', async () => { doneInitialJobData.state.run.done = true; const wrapper = mount(RepoActionView, { props: { - jobIndex: '1', - attemptNumber: '1', + ...defaultTestProps, initialJobData: doneInitialJobData, - initialArtifactData: minimalInitialArtifactData, - locale: testLocale, }, }); await flushPromises(); @@ -520,13 +504,7 @@ test('initial load schedules refresh when job is not done', async () => { const runningInitialJobData = structuredClone(minimalInitialJobData); runningInitialJobData.state.run.done = false; const wrapper = mount(RepoActionView, { - props: { - jobIndex: '1', - attemptNumber: '1', - initialJobData: runningInitialJobData, - initialArtifactData: minimalInitialArtifactData, - locale: testLocale, - }, + props: defaultTestProps, }); await flushPromises(); const container = wrapper.find('.action-view-container'); @@ -548,13 +526,7 @@ test('initial load data is used without calling fetch()', async () => { }); mount(RepoActionView, { - props: { - jobIndex: '1', - attemptNumber: '1', - initialJobData: minimalInitialJobData, - initialArtifactData: minimalInitialArtifactData, - locale: testLocale, - }, + props: defaultTestProps, }); await flushPromises(); expect(fetchSpy).not.toHaveBeenCalled(); @@ -564,11 +536,7 @@ test('view non-picked action run job', async () => { Object.defineProperty(document.documentElement, 'lang', {value: 'en'}); const wrapper = mount(RepoActionView, { props: { - actionsURL: 'https://example.com/example-org/example-repo/actions', - runIndex: '10', - runID: '1001', - jobIndex: '2', - attemptNumber: '1', + ...defaultTestProps, initialJobData: { ...minimalInitialJobData, // Definitions here should match the same type of content as the related backend test, @@ -613,8 +581,6 @@ test('view non-picked action run job', async () => { }, }, }, - initialArtifactData: minimalInitialArtifactData, - locale: testLocale, }, }); await flushPromises();