loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'test: fix e2e tests' (#5968) from viceice/test/e2e-fixes into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5968

+35 -43
+1 -4
tests/e2e/actions.test.e2e.ts
··· 20 20 21 21 test('workflow dispatch present', async ({browser}, workerInfo) => { 22 22 const context = await load_logged_in_context(browser, workerInfo, 'user2'); 23 - /** @type {import('@playwright/test').Page} */ 24 23 const page = await context.newPage(); 25 24 26 25 await page.goto('/user2/test_workflows/actions?workflow=test-dispatch.yml&actor=0&status=0'); ··· 40 39 test.skip(workerInfo.project.name === 'Mobile Safari', 'Flaky behaviour on mobile safari; see https://codeberg.org/forgejo/forgejo/pulls/3334#issuecomment-2033383'); 41 40 42 41 const context = await load_logged_in_context(browser, workerInfo, 'user2'); 43 - /** @type {import('@playwright/test').Page} */ 44 42 const page = await context.newPage(); 45 43 46 44 await page.goto('/user2/test_workflows/actions?workflow=test-dispatch.yml&actor=0&status=0'); ··· 62 60 test.skip(workerInfo.project.name === 'Mobile Safari', 'Flaky behaviour on mobile safari; see https://codeberg.org/forgejo/forgejo/pulls/3334#issuecomment-2033383'); 63 61 64 62 const context = await load_logged_in_context(browser, workerInfo, 'user2'); 65 - /** @type {import('@playwright/test').Page} */ 66 63 const page = await context.newPage(); 67 64 68 65 await page.goto('/user2/test_workflows/actions?workflow=test-dispatch.yml&actor=0&status=0'); 69 66 70 67 await page.locator('#workflow_dispatch_dropdown>button').click(); 71 68 72 - await page.type('input[name="inputs[string2]"]', 'abc'); 69 + await page.fill('input[name="inputs[string2]"]', 'abc'); 73 70 await page.locator('#workflow-dispatch-submit').click(); 74 71 75 72 await expect(page.getByText('Workflow run was successfully requested.')).toBeVisible();
+4 -4
tests/e2e/example.test.e2e.ts
··· 21 21 test('Register Form', async ({page}, workerInfo) => { 22 22 const response = await page.goto('/user/sign_up'); 23 23 expect(response?.status()).toBe(200); // Status OK 24 - await page.type('input[name=user_name]', `e2e-test-${workerInfo.workerIndex}`); 25 - await page.type('input[name=email]', `e2e-test-${workerInfo.workerIndex}@test.com`); 26 - await page.type('input[name=password]', 'test123test123'); 27 - await page.type('input[name=retype]', 'test123test123'); 24 + await page.fill('input[name=user_name]', `e2e-test-${workerInfo.workerIndex}`); 25 + await page.fill('input[name=email]', `e2e-test-${workerInfo.workerIndex}@test.com`); 26 + await page.fill('input[name=password]', 'test123test123'); 27 + await page.fill('input[name=retype]', 'test123test123'); 28 28 await page.click('form button.ui.primary.button:visible'); 29 29 // Make sure we routed to the home page. Else login failed. 30 30 expect(page.url()).toBe(`${workerInfo.project.use.baseURL}/`);
+7 -9
tests/e2e/issue-sidebar.test.e2e.ts
··· 4 4 // web_src/js/features/repo-issue** 5 5 // @watch end 6 6 7 - import {expect} from '@playwright/test'; 7 + /* eslint playwright/expect-expect: ["error", { "assertFunctionNames": ["check_wip"] }] */ 8 + 9 + import {expect, type Page} from '@playwright/test'; 8 10 import {test, login_user, login} from './utils_e2e.ts'; 9 11 10 12 test.beforeAll(async ({browser}, workerInfo) => { 11 13 await login_user(browser, workerInfo, 'user2'); 12 14 }); 13 15 14 - /* eslint-disable playwright/expect-expect */ 15 - // some tests are reported to have no assertions, 16 - // which is not correct, because they use the global helper function 17 16 test.describe('Pull: Toggle WIP', () => { 18 17 const prTitle = 'pull5'; 19 - async function toggle_wip_to({page}, should) { 18 + async function toggle_wip_to({page}, should: boolean) { 20 19 await page.waitForLoadState('domcontentloaded'); 21 20 if (should) { 22 21 await page.getByText('Still in progress?').click(); ··· 25 24 } 26 25 } 27 26 28 - async function check_wip({page}, is) { 27 + async function check_wip({page}, is: boolean) { 29 28 const elemTitle = 'h1'; 30 29 const stateLabel = '.issue-state-label'; 31 30 await page.waitForLoadState('domcontentloaded'); ··· 96 95 await expect(page.locator('h1')).toContainText(maxLenStr); 97 96 }); 98 97 }); 99 - /* eslint-enable playwright/expect-expect */ 100 98 101 99 test('Issue: Labels', async ({browser}, workerInfo) => { 102 100 test.skip(workerInfo.project.name === 'Mobile Safari', 'Unable to get tests working on Safari Mobile, see https://codeberg.org/forgejo/forgejo/pulls/3445#issuecomment-1789636'); 103 101 104 - async function submitLabels({page}) { 102 + async function submitLabels({page}: {page: Page}) { 105 103 const submitted = page.waitForResponse('/user2/repo1/issues/labels'); 106 104 await page.locator('textarea').first().click(); // close via unrelated element 107 105 await submitted; ··· 199 197 200 198 // Assign other user (with searchbox) 201 199 await page.locator('.select-assignees.dropdown').click(); 202 - await page.type('.select-assignees .menu .search input', 'user4'); 200 + await page.fill('.select-assignees .menu .search input', 'user4'); 203 201 await expect(page.locator('.select-assignees .menu .item').filter({hasText: 'user2'})).toBeHidden(); 204 202 await expect(page.locator('.select-assignees .menu .item').filter({hasText: 'user4'})).toBeVisible(); 205 203 await page.locator('.select-assignees .menu .item').filter({hasText: 'user4'}).click();
+13 -13
tests/e2e/markdown-editor.test.e2e.ts
··· 29 29 30 30 // Indent, then unindent first line 31 31 await textarea.focus(); 32 - await textarea.evaluate((it) => it.setSelectionRange(0, 0)); 32 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(0, 0)); 33 33 await indent.click(); 34 34 await expect(textarea).toHaveValue(`${tab}* first\n* second\n* third\n* last`); 35 35 await unindent.click(); ··· 45 45 46 46 // Subsequently, select a chunk of 2nd and 3rd line and indent both, preserving the cursor position in relation to text 47 47 await textarea.focus(); 48 - await textarea.evaluate((it) => it.setSelectionRange(it.value.indexOf('cond'), it.value.indexOf('hird'))); 48 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.indexOf('cond'), it.value.indexOf('hird'))); 49 49 await indent.click(); 50 50 const lines23 = `* first\n${tab}${tab}* second\n${tab}* third\n* last`; 51 51 await expect(textarea).toHaveValue(lines23); ··· 60 60 61 61 // Indent and unindent with cursor at the end of the line 62 62 await textarea.focus(); 63 - await textarea.evaluate((it) => it.setSelectionRange(it.value.indexOf('cond'), it.value.indexOf('cond'))); 63 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.indexOf('cond'), it.value.indexOf('cond'))); 64 64 await textarea.press('End'); 65 65 await indent.click(); 66 66 await expect(textarea).toHaveValue(`* first\n${tab}* second\n* third\n* last`); ··· 69 69 70 70 // Check that Tab does work after input 71 71 await textarea.focus(); 72 - await textarea.evaluate((it) => it.setSelectionRange(it.value.length, it.value.length)); 72 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.length, it.value.length)); 73 73 await textarea.press('Shift+Enter'); // Avoid triggering the prefix continuation feature 74 74 await textarea.pressSequentially('* least'); 75 75 await indent.click(); ··· 78 78 // Check that partial indents are cleared 79 79 await textarea.focus(); 80 80 await textarea.fill(initText); 81 - await textarea.evaluate((it) => it.setSelectionRange(it.value.indexOf('* second'), it.value.indexOf('* second'))); 81 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.indexOf('* second'), it.value.indexOf('* second'))); 82 82 await textarea.pressSequentially(' '); 83 83 await unindent.click(); 84 84 await expect(textarea).toHaveValue(initText); ··· 99 99 await textarea.fill(initText); 100 100 101 101 // Test continuation of '* ' prefix 102 - await textarea.evaluate((it) => it.setSelectionRange(it.value.indexOf('cond'), it.value.indexOf('cond'))); 102 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.indexOf('cond'), it.value.indexOf('cond'))); 103 103 await textarea.press('End'); 104 104 await textarea.press('Enter'); 105 105 await textarea.pressSequentially('middle'); ··· 112 112 await expect(textarea).toHaveValue(`* first\n* second\n${tab}* middle\n${tab}* muddle\n* third\n* last`); 113 113 114 114 // Test breaking in the middle of a line 115 - await textarea.evaluate((it) => it.setSelectionRange(it.value.lastIndexOf('ddle'), it.value.lastIndexOf('ddle'))); 115 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.lastIndexOf('ddle'), it.value.lastIndexOf('ddle'))); 116 116 await textarea.pressSequentially('tate'); 117 117 await textarea.press('Enter'); 118 118 await textarea.pressSequentially('me'); ··· 120 120 121 121 // Test not triggering when Shift held 122 122 await textarea.fill(initText); 123 - await textarea.evaluate((it) => it.setSelectionRange(it.value.length, it.value.length)); 123 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.length, it.value.length)); 124 124 await textarea.press('Shift+Enter'); 125 125 await textarea.press('Enter'); 126 126 await textarea.pressSequentially('...but not least'); ··· 128 128 129 129 // Test continuation of ordered list 130 130 await textarea.fill(`1. one\n2. two`); 131 - await textarea.evaluate((it) => it.setSelectionRange(it.value.length, it.value.length)); 131 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.length, it.value.length)); 132 132 await textarea.press('Enter'); 133 133 await textarea.pressSequentially('three'); 134 134 await expect(textarea).toHaveValue(`1. one\n2. two\n3. three`); 135 135 136 136 // Test continuation of alternative ordered list syntax 137 137 await textarea.fill(`1) one\n2) two`); 138 - await textarea.evaluate((it) => it.setSelectionRange(it.value.length, it.value.length)); 138 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.length, it.value.length)); 139 139 await textarea.press('Enter'); 140 140 await textarea.pressSequentially('three'); 141 141 await expect(textarea).toHaveValue(`1) one\n2) two\n3) three`); 142 142 143 143 // Test continuation of blockquote 144 144 await textarea.fill(`> knowledge is power`); 145 - await textarea.evaluate((it) => it.setSelectionRange(it.value.length, it.value.length)); 145 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.length, it.value.length)); 146 146 await textarea.press('Enter'); 147 147 await textarea.pressSequentially('france is bacon'); 148 148 await expect(textarea).toHaveValue(`> knowledge is power\n> france is bacon`); 149 149 150 150 // Test continuation of checklists 151 151 await textarea.fill(`- [ ] have a problem\n- [x] create a solution`); 152 - await textarea.evaluate((it) => it.setSelectionRange(it.value.length, it.value.length)); 152 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.length, it.value.length)); 153 153 await textarea.press('Enter'); 154 154 await textarea.pressSequentially('write a test'); 155 155 await expect(textarea).toHaveValue(`- [ ] have a problem\n- [x] create a solution\n- [ ] write a test`); ··· 174 174 ]; 175 175 for (const prefix of prefixes) { 176 176 await textarea.fill(`${prefix}one`); 177 - await textarea.evaluate((it) => it.setSelectionRange(it.value.length, it.value.length)); 177 + await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.length, it.value.length)); 178 178 await textarea.press('Enter'); 179 179 await textarea.pressSequentially('two'); 180 180 await expect(textarea).toHaveValue(`${prefix}one\n${prefix}two`);
+3 -3
tests/e2e/reaction-selectors.test.e2e.ts
··· 3 3 // routers/web/repo/issue.go 4 4 // @watch end 5 5 6 - import {expect} from '@playwright/test'; 6 + import {expect, type Locator} from '@playwright/test'; 7 7 import {test, login_user, load_logged_in_context} from './utils_e2e.ts'; 8 8 9 9 test.beforeAll(async ({browser}, workerInfo) => { 10 10 await login_user(browser, workerInfo, 'user2'); 11 11 }); 12 12 13 - const assertReactionCounts = (comment, counts) => 13 + const assertReactionCounts = (comment: Locator, counts: unknown) => 14 14 expect(async () => { 15 15 await expect(comment.locator('.reactions')).toBeVisible(); 16 16 ··· 29 29 return expect(reactions).toStrictEqual(counts); 30 30 }).toPass(); 31 31 32 - async function toggleReaction(menu, reaction) { 32 + async function toggleReaction(menu: Locator, reaction: string) { 33 33 await menu.evaluateAll((menus) => menus[0].focus()); 34 34 await menu.locator('.add-reaction').click(); 35 35 await menu.locator(`[role=menuitem][data-reaction-content="${reaction}"]`).click();
+2 -2
tests/e2e/repo-code.test.e2e.ts
··· 4 4 // services/gitdiff/** 5 5 // @watch end 6 6 7 - import {expect} from '@playwright/test'; 7 + import {expect, type Page} from '@playwright/test'; 8 8 import {test, login_user, login} from './utils_e2e.ts'; 9 9 import {accessibilityCheck} from './shared/accessibility.ts'; 10 10 ··· 12 12 await login_user(browser, workerInfo, 'user2'); 13 13 }); 14 14 15 - async function assertSelectedLines(page, nums) { 15 + async function assertSelectedLines(page: Page, nums: string[]) { 16 16 const pageAssertions = async () => { 17 17 expect( 18 18 await Promise.all((await page.locator('tr.active [data-line-number]').all()).map((line) => line.getAttribute('data-line-number'))),
+2 -2
tests/e2e/shared/accessibility.ts
··· 3 3 4 4 export async function accessibilityCheck({page}: {page: Page}, includes: string[], excludes: string[], disabledRules: string[]) { 5 5 // contrast of inline links is still a global issue in Forgejo 6 - disabledRules += 'link-in-text-block'; 6 + disabledRules.push('link-in-text-block'); 7 7 8 - let accessibilityScanner = await new AxeBuilder({page}) 8 + let accessibilityScanner = new AxeBuilder({page}) 9 9 .disableRules(disabledRules); 10 10 // passing the whole array seems to be not supported, 11 11 // iterating has the nice side-effectof skipping this if the array is empty
+3 -5
tests/e2e/utils_e2e.ts
··· 33 33 expect(response?.status()).toBe(200); // Status OK 34 34 35 35 // Fill out form 36 - await page.type('input[name=user_name]', user); 37 - await page.type('input[name=password]', LOGIN_PASSWORD); 36 + await page.fill('input[name=user_name]', user); 37 + await page.fill('input[name=password]', LOGIN_PASSWORD); 38 38 await page.click('form button.ui.primary.button:visible'); 39 39 40 40 await page.waitForLoadState(); ··· 48 48 } 49 49 50 50 export async function load_logged_in_context(browser: Browser, workerInfo: TestInfo, user: string) { 51 - let context; 52 51 try { 53 - context = await test_context(browser, {storageState: `${ARTIFACTS_PATH}/state-${user}-${workerInfo.workerIndex}.json`}); 52 + return await test_context(browser, {storageState: `${ARTIFACTS_PATH}/state-${user}-${workerInfo.workerIndex}.json`}); 54 53 } catch (err) { 55 54 if (err.code === 'ENOENT') { 56 55 throw new Error(`Could not find state for '${user}'. Did you call login_user(browser, workerInfo, '${user}') in test.beforeAll()?`); 57 56 } 58 57 } 59 - return context; 60 58 } 61 59 62 60 export async function login({browser}: {browser: Browser}, workerInfo: TestInfo) {
-1
tests/e2e/webauthn.test.e2e.ts
··· 30 30 transport: 'usb', 31 31 automaticPresenceSimulation: true, 32 32 isUserVerified: true, 33 - backupEligibility: true, // TODO: this doesn't seem to be available?! 34 33 }, 35 34 }); 36 35