Skip to content

Commit 545d96c

Browse files
Merge pull request #6491 from nextcloud/backport/6486/stable28
[stable28] Check link protocol
2 parents a821e0c + 88f47c5 commit 545d96c

13 files changed

Lines changed: 607 additions & 666 deletions

File tree

.github/workflows/cypress.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818

1919
jobs:
2020
init:
21-
runs-on: ubuntu-22.04
21+
runs-on: ubuntu-latest
2222
outputs:
2323
nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
2424
npmVersion: ${{ steps.versions.outputs.npmVersion }}
@@ -184,17 +184,17 @@ jobs:
184184

185185

186186
- name: Upload test failure screenshots
187-
uses: actions/upload-artifact@v3
187+
uses: actions/upload-artifact@v4
188188
if: failure()
189189
with:
190-
name: Upload screenshots
190+
name: snapshots_${{ matrix.containers }}
191191
path: |
192192
apps/${{ env.APP_NAME }}/cypress/screenshots/
193193
apps/${{ env.APP_NAME }}/cypress/snapshots/
194194
retention-days: 5
195195

196196
- name: Upload nextcloud logs
197-
uses: actions/upload-artifact@v3
197+
uses: actions/upload-artifact@v4
198198
if: failure()
199199
with:
200200
name: cypress-${{ matrix.containers }}.log

composer/composer/InstalledVersions.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class InstalledVersions
3232
*/
3333
private static $installed;
3434

35+
/**
36+
* @var bool
37+
*/
38+
private static $installedIsLocalDir;
39+
3540
/**
3641
* @var bool|null
3742
*/
@@ -309,6 +314,12 @@ public static function reload($data)
309314
{
310315
self::$installed = $data;
311316
self::$installedByVendor = array();
317+
318+
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
319+
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
320+
// so we have to assume it does not, and that may result in duplicate data being returned when listing
321+
// all installed packages for example
322+
self::$installedIsLocalDir = false;
312323
}
313324

314325
/**
@@ -325,19 +336,24 @@ private static function getInstalled()
325336
$copiedLocalDir = false;
326337

327338
if (self::$canGetVendors) {
339+
$selfDir = strtr(__DIR__, '\\', '/');
328340
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
341+
$vendorDir = strtr($vendorDir, '\\', '/');
329342
if (isset(self::$installedByVendor[$vendorDir])) {
330343
$installed[] = self::$installedByVendor[$vendorDir];
331344
} elseif (is_file($vendorDir.'/composer/installed.php')) {
332345
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
333346
$required = require $vendorDir.'/composer/installed.php';
334347
self::$installedByVendor[$vendorDir] = $required;
335348
$installed[] = $required;
336-
if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
349+
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
337350
self::$installed = $required;
338-
$copiedLocalDir = true;
351+
self::$installedIsLocalDir = true;
339352
}
340353
}
354+
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
355+
$copiedLocalDir = true;
356+
}
341357
}
342358
}
343359

composer/composer/installed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => '__root__',
44
'pretty_version' => 'dev-main',
55
'version' => 'dev-main',
6-
'reference' => 'ee3d8b90a4886b0ca38bbc3f89b4808426726066',
6+
'reference' => 'a821e0c7b4d02e65c64b7b95c4a4303ef0d14ed0',
77
'type' => 'library',
88
'install_path' => __DIR__ . '/../',
99
'aliases' => array(),
@@ -13,7 +13,7 @@
1313
'__root__' => array(
1414
'pretty_version' => 'dev-main',
1515
'version' => 'dev-main',
16-
'reference' => 'ee3d8b90a4886b0ca38bbc3f89b4808426726066',
16+
'reference' => 'a821e0c7b4d02e65c64b7b95c4a4303ef0d14ed0',
1717
'type' => 'library',
1818
'install_path' => __DIR__ . '/../',
1919
'aliases' => array(),

cypress/e2e/directediting.spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ function enterContentAndClose() {
66
cy.intercept({ method: 'POST', url: '**/session/*/close' }).as('closeRequest')
77
cy.intercept({ method: 'POST', url: '**/session/*/push' }).as('push')
88
cy.intercept({ method: 'POST', url: '**/session/*/sync' }).as('sync')
9-
cy.getContent().type('# This is a headline')
10-
cy.getContent().type('{enter}')
11-
cy.getContent().type('Some text')
12-
cy.getContent().type('{enter}')
9+
cy.insertLine('# This is a headline')
10+
cy.insertLine('Some text')
1311
cy.getContent().type('{ctrl+s}')
1412
cy.wait('@push')
1513
cy.wait('@sync')

cypress/e2e/nodes/CodeBlock.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('Front matter support', function() {
104104
cy.isolateTest({ sourceFile: 'codeblock.md' })
105105
cy.openFile('codeblock.md').then(() => {
106106
cy.clearContent()
107-
cy.getContent().type('{enter}```javascript{enter}')
107+
cy.insertLine('```javascript')
108108
cy.getContent().type('const foo = "bar"{enter}{enter}{enter}')
109109
cy.getContent().find('.hljs-keyword').first().contains('const')
110110
})
@@ -123,7 +123,7 @@ describe('Front matter support', function() {
123123
it('Add an invalid mermaid block', function() {
124124
cy.isolateTest()
125125
cy.openFile('empty.md').then(() => {
126-
cy.getContent().type('```mermaid{enter}')
126+
cy.insertLine('```mermaid')
127127
cy.getContent().find('code').should('exist')
128128
cy.getContent().get('.split-view__preview').should('be.visible')
129129
// eslint-disable-next-line cypress/no-unnecessary-waiting
@@ -138,7 +138,7 @@ describe('Front matter support', function() {
138138
it('Add a valid mermaid block', function() {
139139
cy.isolateTest()
140140
cy.openFile('empty.md').then(() => {
141-
cy.getContent().type('```mermaid{enter}')
141+
cy.insertLine('```mermaid')
142142
cy.getContent().find('code').should('exist')
143143
cy.getContent().get('.split-view__preview').should('be.visible')
144144
// eslint-disable-next-line cypress/no-unnecessary-waiting

cypress/e2e/nodes/Links.spec.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { initUserAndFiles, randUser } from '../../utils/index.js'
1+
import { randUser } from '../../utils/index.js'
22

33
const user = randUser()
44
const fileName = 'empty.md'
55

66
describe('test link marks', function() {
77
before(function() {
8-
initUserAndFiles(user)
8+
cy.createUser(user)
99
})
1010

1111
beforeEach(function() {
@@ -22,8 +22,8 @@ describe('test link marks', function() {
2222

2323
describe('link preview', function() {
2424
it('shows a link preview', () => {
25-
cy.getContent().type('https://nextcloud.com')
26-
cy.getContent().type('{enter}')
25+
const link = 'https://nextcloud.com/'
26+
cy.insertLine(link)
2727

2828
cy.getContent()
2929
.find('.widgets--list', { timeout: 10000 })
@@ -32,8 +32,7 @@ describe('test link marks', function() {
3232
})
3333

3434
it('does not show a link preview for links within a paragraph', () => {
35-
cy.getContent().type('Please visit https://nextcloud.com')
36-
cy.getContent().type('{enter}')
35+
cy.insertLine('Please visit https://nextcloud.com')
3736

3837
cy.getContent()
3938
.find('.widgets--list', { timeout: 10000 })
@@ -49,8 +48,7 @@ describe('test link marks', function() {
4948

5049
const link = `${Cypress.env('baseUrl')}/apps/files/file-name?fileId=${id}`
5150
cy.clearContent()
52-
cy.getContent()
53-
.type(`${link}{enter}`)
51+
cy.insertLine(link)
5452

5553
cy.getContent()
5654
.find(`a[href*="${Cypress.env('baseUrl')}"]`)
@@ -69,8 +67,7 @@ describe('test link marks', function() {
6967

7068
const link = `${Cypress.env('baseUrl')}/file-name?fileId=${id}`
7169
cy.clearContent()
72-
cy.getContent()
73-
.type(`${link}{enter}`)
70+
cy.insertLine(link)
7471

7572
cy.getContent()
7673
.find(`a[href*="${Cypress.env('baseUrl')}"]`)
@@ -84,16 +81,14 @@ describe('test link marks', function() {
8481

8582
it('without protocol', () => {
8683
cy.clearContent()
87-
cy.getContent()
88-
.type('google.com{enter}')
84+
cy.insertLine('google.com')
8985
cy.getContent()
9086
.find('a[href*="google.com"]')
9187
.should('not.exist')
9288
})
9389

9490
it('with protocol but without space', () => {
95-
cy.getContent()
96-
.type('https://nextcloud.com')
91+
cy.getContent().type('https://nextcloud.com')
9792

9893
cy.getContent()
9994
.find('a[href*="nextcloud.com"]')

cypress/e2e/sections.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('Content Sections', () => {
4444
it('Anchor ID is updated', () => {
4545
cy.visitTestFolder()
4646
cy.openFile(fileName, { force: true })
47-
cy.getContent().type('# Heading 1{enter}')
47+
cy.insertLine('# Heading 1')
4848
cy.getContent()
4949
.find('h1 > a')
5050
.should('have.attr', 'id')
@@ -83,8 +83,7 @@ describe('Content Sections', () => {
8383
cy.visitTestFolder()
8484
cy.openFile(fileName, { force: true })
8585
// Issue #2868
86-
cy.getContent()
87-
.type('# Heading 1{enter}')
86+
cy.insertLine('# Heading 1')
8887
cy.getContent()
8988
.find('h1 > a')
9089
.should('have.attr', 'id')

cypress/e2e/sync.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Sync', () => {
3838
cy.openTestFile()
3939
cy.wait('@sync', { timeout: 10000 })
4040
cy.getContent().find('h2').should('contain', 'Hello world')
41-
cy.getContent().type('{moveToEnd}* Saving the doc saves the doc state{enter}')
41+
cy.insertLine('{moveToEnd}* Saving the doc saves the doc state')
4242
cy.wait('@sync', { timeout: 10000 })
4343
})
4444

@@ -77,7 +77,7 @@ describe('Sync', () => {
7777
.should('not.contain', 'Document could not be loaded.')
7878
// FIXME: There seems to be a bug where typed words maybe lost if not waiting for the new session
7979
cy.wait('@syncAfterRecovery', { timeout: 10000 })
80-
cy.getContent().type('* more content added after the lost connection{enter}')
80+
cy.insertLine('* more content added after the lost connection')
8181
cy.wait('@syncAfterRecovery', { timeout: 10000 })
8282
cy.closeFile()
8383
cy.testName()
@@ -137,7 +137,7 @@ describe('Sync', () => {
137137
.should('not.contain', 'Document could not be loaded.')
138138
// FIXME: There seems to be a bug where typed words maybe lost if not waiting for the new session
139139
cy.wait('@syncAfterRecovery', { timeout: 10000 })
140-
cy.getContent().type('* more content added after the lost connection{enter}')
140+
cy.insertLine('* more content added after the lost connection')
141141
cy.wait('@syncAfterRecovery', { timeout: 10000 })
142142
cy.closeFile()
143143
cy.testName()

cypress/e2e/viewer.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ describe('Open test.md in viewer', function() {
9595
// This used to break with the focus trap that the viewer modal has
9696
cy.openFile('empty.md')
9797

98-
cy.getContent()
99-
.type('- test{enter}')
98+
cy.insertLine('- test')
10099

101100
// Cypress does not have native tab key support, though this seems to work
102101
// for triggering the key handler of tiptap

cypress/support/commands.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ Cypress.Commands.add('clearContent', () => {
385385
cy.getContent()
386386
})
387387

388+
Cypress.Commands.add('insertLine', (line = '') => {
389+
cy.getContent()
390+
.type(`${line}{enter}`)
391+
})
392+
388393
Cypress.Commands.add('openWorkspace', () => {
389394
cy.createDescription()
390395
cy.get('#rich-workspace .editor__content').click({ force: true })

0 commit comments

Comments
 (0)