Merge pull request 'tests(e2e): Refactor branch protection test' (#5294) from fnetx/e2e-flakyness into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5294
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
Otto 2024-10-11 14:53:14 +00:00
commit 33ddb24379

View file

@ -34,7 +34,8 @@ test('repo webhook settings', async ({browser}, workerInfo) => {
await expect(page.locator('.hide-unless-checked')).toBeHidden(); await expect(page.locator('.hide-unless-checked')).toBeHidden();
}); });
test('repo branch protection settings', async ({browser}, workerInfo) => { test.describe('repo branch protection settings', () => {
test('form', async ({browser}, workerInfo) => {
test.skip(workerInfo.project.name === 'Mobile Safari', 'Cannot get it to work - as usual'); test.skip(workerInfo.project.name === 'Mobile Safari', 'Cannot get it to work - as usual');
const page = await login({browser}, workerInfo); const page = await login({browser}, workerInfo);
const response = await page.goto('/user2/repo1/settings/branches/edit'); const response = await page.goto('/user2/repo1/settings/branches/edit');
@ -47,11 +48,19 @@ test('repo branch protection settings', async ({browser}, workerInfo) => {
await page.locator('input[name="rule_name"]').fill('testrule'); await page.locator('input[name="rule_name"]').fill('testrule');
await page.getByText('Save rule').click(); await page.getByText('Save rule').click();
// verify header is in edit mode // verify header is in edit mode
await page.waitForLoadState('networkidle'); await page.waitForLoadState('domcontentloaded');
await page.getByText('Edit').click(); await page.getByText('Edit').click();
await expect(page.locator('h4')).toContainText('Protection rules for branch'); await expect(page.locator('h4')).toContainText('Protection rules for branch');
});
test.afterEach(async ({browser}, workerInfo) => {
const page = await login({browser}, workerInfo);
// delete the rule for the next test // delete the rule for the next test
await page.goBack(); await page.goto('/user2/repo1/settings/branches/');
await page.waitForLoadState('domcontentloaded');
test.skip(await page.getByText('Delete rule').isHidden(), 'Nothing to delete at this time');
await page.getByText('Delete rule').click(); await page.getByText('Delete rule').click();
await page.getByText('Yes').click(); await page.getByText('Yes').click();
await page.waitForLoadState('load');
});
}); });