diff --git a/lib/Listeners/BeforeTemplateRenderedListener.php b/lib/Listeners/BeforeTemplateRenderedListener.php index 13ddc6f89..21b3c5b46 100644 --- a/lib/Listeners/BeforeTemplateRenderedListener.php +++ b/lib/Listeners/BeforeTemplateRenderedListener.php @@ -19,6 +19,7 @@ use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventListener; +use OCP\Files\Template\ITemplateManager; use OCP\IUserSession; use OCP\Util; @@ -29,6 +30,7 @@ public function __construct( private UserFolderHelper $userFolderHelper, private IEventDispatcher $eventDispatcher, private IInitialState $initialState, + private ITemplateManager $templateManager, ) { } @@ -62,5 +64,6 @@ public function handle(Event $event): void { // Provide Collectives user folder as initial state $this->initialState->provideInitialState('user_folder', $userFolder); + $this->initialState->provideInitialState('templates', $this->templateManager->listCreators()); } } diff --git a/playwright/e2e/page-content.spec.ts b/playwright/e2e/page-content.spec.ts new file mode 100644 index 000000000..1c8c20f2d --- /dev/null +++ b/playwright/e2e/page-content.spec.ts @@ -0,0 +1,28 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { runOcc } from '@nextcloud/e2e-test-server/docker' +import { expect, mergeTests } from '@playwright/test' +import { test as createCollectiveTest } from '../support/fixtures/create-collectives.ts' +import { test as editorTest } from '../support/fixtures/editor.ts' + +const test = mergeTests(createCollectiveTest, editorTest) + +test.describe('Page content', () => { + test('create whiteboard from attachments menu', async ({ user, page, collective, editor }) => { + test.slow() + await runOcc(['app:enable', '--force', 'whiteboard']) + const collectivePage = await collective.createPage({ title: 'Page with whiteboard', user, page }) + await collectivePage.open(true) + + editor.setMode(true) + await editor.clickMenu('attachment', 'New whiteboard') + await expect(editor.getContent() + .locator('.widget-file.whiteboard')) + .toBeVisible() + + await runOcc(['app:disable', 'whiteboard']) + }) +}) diff --git a/playwright/support/sections/EditorSection.ts b/playwright/support/sections/EditorSection.ts index 0e7038e39..c910929fa 100644 --- a/playwright/support/sections/EditorSection.ts +++ b/playwright/support/sections/EditorSection.ts @@ -9,21 +9,35 @@ import { expect } from '@playwright/test' export class EditorSection { public isEdit: boolean - public readonly editorContent: Locator - public readonly readerContent: Locator + public readonly editor: Locator + public readonly reader: Locator constructor(public readonly page: Page) { this.isEdit = false - this.editorContent = this.page.locator('[data-cy-collectives="editor"] .ProseMirror') - this.readerContent = this.page.locator('[data-cy-collectives="reader"] .ProseMirror') + this.editor = this.page.locator('[data-cy-collectives="editor"]') + this.reader = this.page.locator('[data-cy-collectives="reader"]') } public setMode(edit: boolean) { this.isEdit = edit } + public getMenu(name: string): Locator { + return this.editor.getByRole('button', { name }) + } + + public getMenuItem(name: string): Locator { + return this.editor.getByRole('menuitem', { name }) + } + + public async clickMenu(menu: string, item: string): Promise { + await this.getMenu(menu).click() + await this.getMenuItem(item).click() + } + public getContent() { - return this.isEdit ? this.editorContent : this.readerContent + return (this.isEdit ? this.editor : this.reader) + .locator('.ProseMirror') } public async hasImage(filename: string): Promise {