From 0241323b65fa2a8f6dc04d28712509242c7607aa Mon Sep 17 00:00:00 2001 From: taoerman Date: Thu, 30 Oct 2025 15:44:43 -0700 Subject: [PATCH 1/4] Add loader if channel is being published and community library side panel is open --- .../SubmitToCommunityLibrarySidePanel.spec.js | 49 ++++++++++ .../index.vue | 89 ++++++++++++++++--- .../strings/communityChannelsStrings.js | 5 ++ .../test_community_library_submission.py | 20 +++++ .../viewsets/community_library_submission.py | 6 ++ 5 files changed, 155 insertions(+), 14 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/sidePanels/SubmitToCommunityLibrarySidePanel/__tests__/SubmitToCommunityLibrarySidePanel.spec.js b/contentcuration/contentcuration/frontend/channelEdit/components/sidePanels/SubmitToCommunityLibrarySidePanel/__tests__/SubmitToCommunityLibrarySidePanel.spec.js index e66e568157..18c1cda437 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/sidePanels/SubmitToCommunityLibrarySidePanel/__tests__/SubmitToCommunityLibrarySidePanel.spec.js +++ b/contentcuration/contentcuration/frontend/channelEdit/components/sidePanels/SubmitToCommunityLibrarySidePanel/__tests__/SubmitToCommunityLibrarySidePanel.spec.js @@ -23,6 +23,9 @@ jest.mock('shared/data/resources', () => ({ CommunityLibrarySubmission: { create: jest.fn(() => Promise.resolve()), }, + Channel: { + fetchModel: jest.fn(), + }, })); const store = factory(); @@ -270,6 +273,52 @@ describe('SubmitToCommunityLibrarySidePanel', () => { }); }); + describe('publishing state', () => { + beforeEach(() => { + jest.useFakeTimers(); + }); + afterEach(() => { + jest.useRealTimers(); + }); + + it('disables form and shows loader when channel is publishing', async () => { + const channel = { ...publishedNonPublicChannel, publishing: true }; + const wrapper = await makeWrapper({ channel, publishedData, latestSubmission: null }); + + // Loader/message container should exist + expect(wrapper.find('.publishing-loader').exists()).toBe(true); + + // Fields and submit are disabled while publishing + const descriptionTextbox = wrapper.findComponent('.description-textbox'); + expect(descriptionTextbox.props('disabled')).toBe(true); + const submitButton = wrapper.find('[data-test="submit-button"]'); + expect(submitButton.attributes('disabled')).toBe('disabled'); + }); + + it('enables form after publishing flips to false (poll-driven)', async () => { + const { Channel } = require('shared/data/resources'); + Channel.fetchModel.mockResolvedValueOnce({ + id: publishedNonPublicChannel.id, + publishing: false, + version: 3, + }); + + const channel = { ...publishedNonPublicChannel, publishing: true }; + const wrapper = await makeWrapper({ channel, publishedData, latestSubmission: null }); + + jest.advanceTimersByTime(2100); + await wrapper.vm.$nextTick(); + + const descriptionTextbox = wrapper.findComponent('.description-textbox'); + expect(descriptionTextbox.props('disabled')).toBe(false); + + await descriptionTextbox.vm.$emit('input', 'Some description'); + await wrapper.vm.$nextTick(); + const submitButton = wrapper.find('[data-test="submit-button"]'); + expect(submitButton.attributes('disabled')).toBeUndefined(); + }); + }); + describe('show less button', () => { it('is displayed when additional info is shown', async () => { const wrapper = await makeWrapper({ diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/sidePanels/SubmitToCommunityLibrarySidePanel/index.vue b/contentcuration/contentcuration/frontend/channelEdit/components/sidePanels/SubmitToCommunityLibrarySidePanel/index.vue index d3d4e91d5f..f32c0c9fca 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/sidePanels/SubmitToCommunityLibrarySidePanel/index.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/sidePanels/SubmitToCommunityLibrarySidePanel/index.vue @@ -12,9 +12,16 @@