mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix(e2e): Flaky tests on Toggle WIP + Dependency dropdown (#12473)
There are two test groups in `issue-sidebar.test.e2e.ts` which behaves
flaky on CI:
- Toggle WIP
- Dependency dropdown
1. **Toggle WIP**:
There is a race-condition happening with this test execution, when we
toggle the WIP status "Still in progress?" / "Ready for review?", there
is a page reload that happens once we select either of the option and
when we use window.WaitForLoadState('domcontentloaded')` it just check
the state of the current dom and not the reloading of the page.
To mitigate this, we need to use a promise call with
`page.WaitForEvent('load')` wherever necessary. This change has been
applied in the `setTitle` and `toggle_wip_to` helper functions.
Also there is a refactor logic where we remove the repetitive call for
click and save events on `manual edit` and `maximum_title_length` and
consistently use the setTitle.
2. **Dependency dropdown**
There is flakiness with this code:
```
await input.fill('1');
await expect(items.first()).toContainText(first);
```
We register the issues via `postIssue` in the `declare_repo_test.go`
file. And the catch is about this issue popping up for the above logic:
```
postIssue(repo, user, 500, "first issue here", "an issue created earlier")
postIssue(repo, user, 400, "second issue here (not 1)", "not the right issue, but in the right repo")
```
On each issue creation, the frontend shows the index as `#1`, `#2`,
respectively.
The issue is when we search for 1, the indexer implementation finds the
highest scoring with relevant sorting order. These are the two issues
that pops up in the first two results.
```
#1 first issue here
#2 second issue here (not 1)
```
In the above results, sometimes the #2 issue will be shown as the first
item in the dropdown results because it contains the exact match `1` in
(not 1). Hence the solution is to remove the `(not 1)` from the second
issue to fix this flakiness behaviour.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12473
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
parent
3f0a8b4424
commit
6b516e2721
2 changed files with 8 additions and 14 deletions
|
|
@ -117,7 +117,7 @@ body:
|
|||
}),
|
||||
}, []FileChanges{}, func(user *user_model.User, repo *repo_model.Repository) {
|
||||
postIssue(repo, user, 500, "first issue here", "an issue created earlier")
|
||||
postIssue(repo, user, 400, "second issue here (not 1)", "not the right issue, but in the right repo")
|
||||
postIssue(repo, user, 400, "second issue here", "not the right issue, but in the right repo")
|
||||
postIssue(repo, user, 300, "third issue here", "depends on things")
|
||||
postIssue(repo, user, 200, "unrelated issue", "shrug emoji")
|
||||
postIssue(repo, user, 100, "newest issue", "very new")
|
||||
|
|
|
|||
|
|
@ -16,20 +16,18 @@ test.describe('Pull: Toggle WIP', () => {
|
|||
const prTitle = 'pull5';
|
||||
|
||||
async function toggle_wip_to({page}: {page: Page}, should: boolean) {
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
const loadPromise = page.waitForEvent('load');
|
||||
if (should) {
|
||||
await page.getByText('Still in progress?').click();
|
||||
} else {
|
||||
await page.getByText('Ready for review?').click();
|
||||
}
|
||||
await loadPromise;
|
||||
}
|
||||
|
||||
async function check_wip({page}: {page: Page}, is: boolean) {
|
||||
await page.waitForLoadState();
|
||||
|
||||
const elemTitle = 'h1';
|
||||
const stateLabel = '.issue-state-label';
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await expect(page.locator(elemTitle)).toContainText(prTitle);
|
||||
await expect(page.locator(elemTitle)).toContainText('#5');
|
||||
const wipRegex = /(wip|\[WIP\])/i;
|
||||
|
|
@ -45,16 +43,16 @@ test.describe('Pull: Toggle WIP', () => {
|
|||
async function setTitle({page}: {page: Page}, title: string) {
|
||||
await page.locator('#issue-title-edit-show').click();
|
||||
await page.locator('#issue-title-editor input').fill(title);
|
||||
const loadPromise = page.waitForEvent('load');
|
||||
await page.getByText('Save').click();
|
||||
await loadPromise;
|
||||
}
|
||||
|
||||
test.beforeEach(async ({page}) => {
|
||||
const response = await page.goto('/user2/repo1/pulls/5');
|
||||
expect(response?.status()).toBe(200); // Status OK
|
||||
// ensure original title
|
||||
await page.locator('#issue-title-edit-show').click();
|
||||
await page.locator('#issue-title-editor input').fill(prTitle);
|
||||
await page.getByText('Save').click();
|
||||
await setTitle({page}, prTitle);
|
||||
await check_wip({page}, false);
|
||||
});
|
||||
|
||||
|
|
@ -69,9 +67,7 @@ test.describe('Pull: Toggle WIP', () => {
|
|||
|
||||
test('manual edit', async ({page}) => {
|
||||
// manually edit title to another prefix
|
||||
await page.locator('#issue-title-edit-show').click();
|
||||
await page.locator('#issue-title-editor input').fill(`[WIP] ${prTitle}`);
|
||||
await page.getByText('Save').click();
|
||||
await setTitle({page}, `[WIP] ${prTitle}`);
|
||||
await check_wip({page}, true);
|
||||
// remove again
|
||||
await toggle_wip_to({page}, false);
|
||||
|
|
@ -81,9 +77,7 @@ test.describe('Pull: Toggle WIP', () => {
|
|||
test('maximum title length', async ({page}) => {
|
||||
// check maximum title length is handled gracefully
|
||||
const maxLenStr = prTitle + 'a'.repeat(240);
|
||||
await page.locator('#issue-title-edit-show').click();
|
||||
await page.locator('#issue-title-editor input').fill(maxLenStr);
|
||||
await page.getByText('Save').click();
|
||||
await setTitle({page}, maxLenStr);
|
||||
await expect(page.locator('h1')).toContainText(maxLenStr);
|
||||
await check_wip({page}, false);
|
||||
await toggle_wip_to({page}, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue