Skip to content

Commit af73c0b

Browse files
authored
Merge pull request #7143 from LibreSign/backport/7142/stable32
[stable32] test: add playwright regression for Files new signature request flow
2 parents d1c825d + 02e89c7 commit af73c0b

10 files changed

Lines changed: 91 additions & 3 deletions
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { expect, test } from '@playwright/test'
7+
import { login } from '../support/nc-login'
8+
import { configureOpenSsl, setAppConfig } from '../support/nc-provisioning'
9+
10+
test('new signature request opens LibreSign tab and does not duplicate file row', async ({ page }) => {
11+
await login(
12+
page.request,
13+
process.env.NEXTCLOUD_ADMIN_USER ?? 'admin',
14+
process.env.NEXTCLOUD_ADMIN_PASSWORD ?? 'admin',
15+
)
16+
17+
await configureOpenSsl(page.request, 'LibreSign Test', {
18+
C: 'BR',
19+
OU: ['Organization Unit'],
20+
ST: 'Rio de Janeiro',
21+
O: 'LibreSign',
22+
L: 'Rio de Janeiro',
23+
})
24+
25+
await setAppConfig(
26+
page.request,
27+
'libresign',
28+
'identify_methods',
29+
JSON.stringify([
30+
{ name: 'account', enabled: true, mandatory: true, signatureMethods: { clickToSign: { enabled: true } } },
31+
{ name: 'email', enabled: false, mandatory: false },
32+
]),
33+
)
34+
35+
const uniqueName = `libresign-upload-${Date.now()}.pdf`
36+
const pdfResponse = await page.request.get('https://raw.githubusercontent.com/LibreSign/libresign/main/tests/php/fixtures/pdfs/small_valid.pdf', {
37+
failOnStatusCode: true,
38+
})
39+
const pdfBuffer = Buffer.from(await pdfResponse.body())
40+
41+
await page.goto('./apps/files')
42+
43+
await page.getByRole('button', { name: 'New' }).click()
44+
const newSignatureRequest = page.getByText('New signature request', { exact: true })
45+
await expect(newSignatureRequest).toBeVisible()
46+
const fileChooserPromise = page.waitForEvent('filechooser')
47+
await newSignatureRequest.click()
48+
const libresignCreateResponsePromise = page.waitForResponse(
49+
(response) => response.url().includes('/ocs/v2.php/apps/libresign/api/v1/file') && response.request().method() === 'POST',
50+
{ timeout: 20000 },
51+
)
52+
const chooser = await fileChooserPromise
53+
await chooser.setFiles({
54+
name: uniqueName,
55+
mimeType: 'application/pdf',
56+
buffer: pdfBuffer,
57+
})
58+
const libresignCreateResponse = await libresignCreateResponsePromise
59+
const libresignCreateBody = await libresignCreateResponse.json() as { ocs: { data: { nodeId: number } } }
60+
61+
// On stable32, Files sidebar internals differ; a successful LibreSign OCS creation call is
62+
// the stable evidence that "New signature request" executed the LibreSign flow.
63+
await expect(libresignCreateResponse.ok()).toBeTruthy()
64+
65+
const filesTable = page.getByRole('table', {
66+
name: /List of your files and folders/i,
67+
})
68+
const matchingRequestRows = filesTable.locator(
69+
`[data-cy-files-list-row][data-cy-files-list-row-fileid="${libresignCreateBody.ocs.data.nodeId}"]`,
70+
)
71+
72+
await expect(matchingRequestRows).toHaveCount(1, { timeout: 15000 })
73+
})

src/init.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ import axios from '@nextcloud/axios'
77
import { addNewFileMenuEntry, Permission } from '@nextcloud/files'
88
import type { NewMenuEntry, IFolder, INode } from '@nextcloud/files'
99
import { registerDavProperty } from '@nextcloud/files/dav'
10-
import { getClient, resultToNode } from '@nextcloud/files/dav'
10+
import { getClient, getDefaultPropfind, getRootPath, resultToNode } from '@nextcloud/files/dav'
1111
import { t } from '@nextcloud/l10n'
1212
import { generateOcsUrl } from '@nextcloud/router'
1313
import { getUploader } from '@nextcloud/upload'
1414
import type { Uploader } from '@nextcloud/upload'
1515
import type { FileStat, ResponseDataDetailed } from 'webdav'
1616

1717
import logger from './logger'
18+
import './actions/openInLibreSignAction.js'
19+
import './actions/showStatusInlineAction.js'
1820
import LibreSignLogoSvg from '../img/app-colored.svg?raw'
1921
import LibreSignLogoDarkSvg from '../img/app-dark.svg?raw'
2022
import { useIsDarkTheme } from './helpers/useIsDarkTheme'
@@ -64,9 +66,12 @@ addNewFileMenuEntry({
6466
name: file.name,
6567
})
6668

67-
// Fetch the complete node object from the Files API
69+
// Fetch the complete node object including NC-specific DAV properties.
6870
const client = getClient()
69-
const result = await client.stat(path, { details: true }) as ResponseDataDetailed<FileStat>
71+
const result = await client.stat(`${getRootPath()}${path}`, {
72+
details: true,
73+
data: getDefaultPropfind(),
74+
}) as ResponseDataDetailed<FileStat>
7075
const node = resultToNode(result.data)
7176

7277
// Open sidebar with LibreSign tab

src/store/files.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ export const useFilesStore = function(...args) {
406406
}
407407
},
408408
signerUpdate(signer) {
409+
if (!this.selectedFileId || !this.files[this.selectedFileId]) {
410+
return
411+
}
409412
this.addIdentifierToSigner(signer)
410413
if (!this.getFile().signers?.length) {
411414
this.getFile().signers = []

src/tests/utils/timePresets.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getTimePresetRange, getTimePresets } from '../../utils/timePresets.js'
99

1010
vi.mock('@nextcloud/l10n', () => ({
1111
t: (_app: string, text: string) => text,
12+
isRTL: vi.fn(() => false),
1213
}))
1314

1415
describe('getTimePresets', () => {

src/tests/views/FilesList/FileListFilter/FileListFilter.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import FileListFilter from '../../../../views/FilesList/FileListFilter/FileListF
1212

1313
vi.mock('@nextcloud/l10n', () => ({
1414
t: vi.fn((_app: string, text: string) => text),
15+
isRTL: vi.fn(() => false),
1516
}))
1617

1718
vi.mock('@nextcloud/logger', () => ({

src/tests/views/FilesList/FileListFilter/FileListFilterChips.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useFiltersStore } from '../../../../store/filters.js'
1313

1414
vi.mock('@nextcloud/l10n', () => ({
1515
t: vi.fn((_app: string, text: string) => text),
16+
isRTL: vi.fn(() => false),
1617
}))
1718

1819
vi.mock('@nextcloud/logger', () => ({

src/tests/views/FilesList/FileListFilter/FileListFilterModified.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ vi.mock('@nextcloud/l10n', () => ({
2121
}
2222
return text
2323
}),
24+
isRTL: vi.fn(() => false),
2425
}))
2526

2627
vi.mock('@nextcloud/logger', () => ({

src/tests/views/FilesList/FileListFilter/FileListFilterStatus.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { FILE_STATUS } from '../../../../constants.js'
1414

1515
vi.mock('@nextcloud/l10n', () => ({
1616
t: vi.fn((_app: string, text: string) => text),
17+
isRTL: vi.fn(() => false),
1718
}))
1819

1920
vi.mock('@nextcloud/logger', () => ({

src/tests/views/FilesList/FileListFilters.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ vi.mock('../../../composables/useFileListWidth.js', () => ({
2626

2727
vi.mock('@nextcloud/l10n', () => ({
2828
t: vi.fn((_app: string, text: string) => text),
29+
isRTL: vi.fn(() => false),
2930
}))
3031

3132
vi.mock('@nextcloud/logger', () => ({

src/tests/views/FilesList/FilesList.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useUserConfigStore } from '../../../store/userconfig.js'
1313

1414
vi.mock('@nextcloud/l10n', () => ({
1515
t: vi.fn((_app: string, text: string) => text),
16+
isRTL: vi.fn(() => false),
1617
}))
1718

1819
vi.mock('@nextcloud/logger', () => ({

0 commit comments

Comments
 (0)