diff options
author | Daniel Baumann <daniel@debian.org> | 2024-10-18 20:33:49 +0200 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2024-12-12 23:57:56 +0100 |
commit | e68b9d00a6e05b3a941f63ffb696f91e554ac5ec (patch) | |
tree | 97775d6c13b0f416af55314eb6a89ef792474615 /tests/e2e/issue-comment.test.e2e.js | |
parent | Initial commit. (diff) | |
download | forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.tar.xz forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.zip |
Adding upstream version 9.0.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to '')
-rw-r--r-- | tests/e2e/issue-comment.test.e2e.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/e2e/issue-comment.test.e2e.js b/tests/e2e/issue-comment.test.e2e.js new file mode 100644 index 0000000..ee2e3a4 --- /dev/null +++ b/tests/e2e/issue-comment.test.e2e.js @@ -0,0 +1,63 @@ +// @ts-check +import {expect} from '@playwright/test'; +import {test, login_user, login} from './utils_e2e.js'; + +test.beforeAll(async ({browser}, workerInfo) => { + await login_user(browser, workerInfo, 'user2'); +}); + +test('Hyperlink paste behaviour', async ({browser}, workerInfo) => { + test.skip(['Mobile Safari', 'Mobile Chrome', 'webkit'].includes(workerInfo.project.name), 'Mobile clients seem to have very weird behaviour with this test, which I cannot confirm with real usage'); + const page = await login({browser}, workerInfo); + await page.goto('/user2/repo1/issues/new'); + await page.locator('textarea').click(); + // same URL + await page.locator('textarea').fill('https://codeberg.org/forgejo/forgejo#some-anchor'); + await page.locator('textarea').press('Shift+Home'); + await page.locator('textarea').press('ControlOrMeta+c'); + await page.locator('textarea').press('ControlOrMeta+v'); + await expect(page.locator('textarea')).toHaveValue('https://codeberg.org/forgejo/forgejo#some-anchor'); + // other text + await page.locator('textarea').fill('Some other text'); + await page.locator('textarea').press('ControlOrMeta+a'); + await page.locator('textarea').press('ControlOrMeta+v'); + await expect(page.locator('textarea')).toHaveValue('[Some other text](https://codeberg.org/forgejo/forgejo#some-anchor)'); + // subset of URL + await page.locator('textarea').fill('https://codeberg.org/forgejo/forgejo#some'); + await page.locator('textarea').press('ControlOrMeta+a'); + await page.locator('textarea').press('ControlOrMeta+v'); + await expect(page.locator('textarea')).toHaveValue('https://codeberg.org/forgejo/forgejo#some-anchor'); + // superset of URL + await page.locator('textarea').fill('https://codeberg.org/forgejo/forgejo#some-anchor-on-the-page'); + await page.locator('textarea').press('ControlOrMeta+a'); + await page.locator('textarea').press('ControlOrMeta+v'); + await expect(page.locator('textarea')).toHaveValue('https://codeberg.org/forgejo/forgejo#some-anchor'); + // completely separate URL + await page.locator('textarea').fill('http://example.com'); + await page.locator('textarea').press('ControlOrMeta+a'); + await page.locator('textarea').press('ControlOrMeta+v'); + await expect(page.locator('textarea')).toHaveValue('https://codeberg.org/forgejo/forgejo#some-anchor'); +}); + +test('Always focus edit tab first on edit', async ({browser}, workerInfo) => { + const page = await login({browser}, workerInfo); + const response = await page.goto('/user2/repo1/issues/1'); + await expect(response?.status()).toBe(200); + + // Switch to preview tab and save + await page.click('#issue-1 .comment-container .context-menu'); + await page.click('#issue-1 .comment-container .menu>.edit-content'); + await page.locator('#issue-1 .comment-container a[data-tab-for=markdown-previewer]').click(); + await page.click('#issue-1 .comment-container .save'); + + await page.waitForLoadState('networkidle'); + + // Edit again and assert that edit tab should be active (and not preview tab) + await page.click('#issue-1 .comment-container .context-menu'); + await page.click('#issue-1 .comment-container .menu>.edit-content'); + const editTab = page.locator('#issue-1 .comment-container a[data-tab-for=markdown-writer]'); + const previewTab = page.locator('#issue-1 .comment-container a[data-tab-for=markdown-previewer]'); + + await expect(editTab).toHaveClass(/active/); + await expect(previewTab).not.toHaveClass(/active/); +}); |