forgejo/tests/e2e/repo-migrate.test.e2e.ts
Gusted 0737196842 chore: remove webkit and mobile safari from playwright (#10103)
Webkit and Mobile safari are comically unreliable, will fail for unexplainable reasons and are very hard to run locally in comparison with the other supported platforms. I do not remember the last time where these two platforms were able to catch a regression where the other platforms did not.

I would like to stress, for the historical record, that many hours has been devoted into adjusting the tests and following best practices to make these two platforms more stable but despite those, IMO wasted, efforts these two platforms are causing many hours of wasted CPU time simply because they are flaky and make (new) contributors nervous if their change contains a regression or not.

To my knowledge, the tests are not broken for these two platforms. If you go to the issue tracker you will not find issues by users that use these two platforms and report that Forgejo is broken. It does not reflect reality.

This is the sunk cost fallacy, bite the bullet and agree that these platforms will not contribute positively to Forgejo's excellent test suite.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10103
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
2025-11-13 17:23:08 +01:00

85 lines
3.9 KiB
TypeScript

// @watch start
// web_src/js/features/repo-migrate.js
// @watch end
import {expect} from '@playwright/test';
import {test, test_context, dynamic_id} from './utils_e2e.ts';
import {screenshot} from './shared/screenshots.ts';
test.use({user: 'user2'});
test('Migration type seleciton screen', async ({page}) => {
await page.goto('/repo/migrate');
// For branding purposes, it is desired that `gitea-` prefixes in SVGs are
// replaced with something like `productlogo-`.
await expect(page.locator('svg.gitea-git')).toBeVisible();
await expect(page.locator('svg.octicon-mark-github')).toBeVisible();
await expect(page.locator('svg.gitea-gitlab')).toBeVisible();
await expect(page.locator('svg.gitea-forgejo')).toBeVisible();
await expect(page.locator('svg.gitea-gitea')).toBeVisible();
await expect(page.locator('svg.gitea-gogs')).toBeVisible();
await expect(page.locator('svg.gitea-onedev')).toBeVisible();
await expect(page.locator('svg.gitea-gitbucket')).toBeVisible();
await expect(page.locator('svg.gitea-codebase')).toBeVisible();
await screenshot(page);
});
test('Migration Repo Name detection', async ({page}) => {
await page.goto('/repo/migrate?service_type=2');
const form = page.locator('form');
// Test trailing slashes are stripped
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).fill('https://github.com/example/test/');
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).blur();
await expect(form.getByRole('textbox', {name: 'Repository Name'})).toHaveValue('test');
// Test trailing .git is stripped
await page.reload();
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).fill('https://github.com/example/test.git');
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).blur();
await expect(form.getByRole('textbox', {name: 'Repository Name'})).toHaveValue('test');
// Test trailing .git and trailing / together is stripped
await page.reload();
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).fill('https://github.com/example/test.git/');
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).blur();
await expect(form.getByRole('textbox', {name: 'Repository Name'})).toHaveValue('test');
// Save screenshot only once
await screenshot(page);
});
test('Migration Progress Page', async ({page, browser}) => {
const repoName = dynamic_id();
expect((await page.goto(`/user2/${repoName}`))?.status(), 'repo should not exist yet').toBe(404);
await page.goto('/repo/migrate?service_type=1');
const form = page.locator('form');
await form.getByRole('textbox', {name: 'Repository Name'}).fill(repoName);
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).fill(`https://codeberg.org/forgejo/${repoName}`);
await screenshot(page);
await form.locator('button.primary').click({timeout: 5000});
await expect(page).toHaveURL(`user2/${repoName}`);
await screenshot(page);
const ctx = await test_context(browser, {storageState: {cookies: [], origins: []}});
const unauthenticatedPage = await ctx.newPage();
expect((await unauthenticatedPage.goto(`/user2/${repoName}`))?.status(), 'public migration page should be accessible').toBe(200);
await expect(unauthenticatedPage.locator('#repo_migrating_progress')).toBeVisible();
await page.reload();
await expect(page.locator('#repo_migrating_failed')).toBeVisible();
await screenshot(page);
await page.getByRole('button', {name: 'Delete this repository'}).click();
const deleteModal = page.locator('#delete-repo-modal');
await deleteModal.getByRole('textbox', {name: 'Confirmation string'}).fill(`user2/${repoName}`);
await screenshot(page);
await deleteModal.getByRole('button', {name: 'Delete repository'}).click();
await expect(page).toHaveURL('/');
// checked last to preserve the order of screenshots from first run
await screenshot(unauthenticatedPage);
});