|
5 | 5 |
|
6 | 6 | import { expect } from '@playwright/test' |
7 | 7 | import { test } from '../../support/fixtures/random-user-session.ts' |
| 8 | +import { BackgroundFilePickerDialogPage } from '../../support/sections/BackgroundFilePickerDialogPage.ts' |
| 9 | +import { mkdir, uploadContent } from '../../support/utils/dav.ts' |
8 | 10 | import { getBodyThemingSnapshot, pickColor } from '../../support/utils/theming.ts' |
9 | 11 |
|
10 | 12 | test('User can configure background and plain color', async ({ page }) => { |
@@ -32,3 +34,26 @@ test('User can configure background and plain color', async ({ page }) => { |
32 | 34 | await page.reload() |
33 | 35 | await expect.poll(async () => (await getBodyThemingSnapshot(page)).backgroundImage).toBe('none') |
34 | 36 | }) |
| 37 | + |
| 38 | +test('User can pick a custom background from their files', async ({ page, user }) => { |
| 39 | + await mkdir(page.request, user, '/folder') |
| 40 | + |
| 41 | + // this is a minimal image (1x1 red pixel), encoded as base64 |
| 42 | + const imageBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4AWL6z8DwHwAAAP//A3ONEwAAAAZJREFUAwAFCgIByRpMngAAAABJRU5ErkJggg==' |
| 43 | + // Buffer.alloc(0) did not work when selecting image as background, using base64 image instead |
| 44 | + await uploadContent(page.request, user, Buffer.from(imageBase64, 'base64'), 'image/jpeg', '/folder/image.jpg') |
| 45 | + |
| 46 | + await page.goto('settings/user/theming') |
| 47 | + await page.getByRole('heading', { name: 'Background and color' }).waitFor({ state: 'visible' }) |
| 48 | + |
| 49 | + await page.getByRole('button', { name: 'Custom background' }).click() |
| 50 | + |
| 51 | + const filePicker = new BackgroundFilePickerDialogPage(page) |
| 52 | + await filePicker.openFolder('folder') |
| 53 | + await filePicker.selectFile('image.jpg') |
| 54 | + await filePicker.confirm() |
| 55 | + |
| 56 | + await expect(page.getByRole('button', { name: 'Custom background', pressed: true })).toBeVisible() |
| 57 | + // backgroundImage is like this: "url(\"<nc-instance>/apps/theming/background?v=<hash>\")" |
| 58 | + await expect.poll(async () => (await getBodyThemingSnapshot(page)).backgroundImage).toContain('/apps/theming/background?') |
| 59 | +}) |
0 commit comments