mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
test: fix flaky (#1953)
This commit is contained in:
4
.github/workflows/build-master.yml
vendored
4
.github/workflows/build-master.yml
vendored
@@ -231,6 +231,10 @@ jobs:
|
|||||||
name: storybook
|
name: storybook
|
||||||
path: ./packages/component/storybook-static
|
path: ./packages/component/storybook-static
|
||||||
|
|
||||||
|
- name: Wait for Octobase Ready
|
||||||
|
run: |
|
||||||
|
node ./scripts/wait-3000-healthz.mjs
|
||||||
|
|
||||||
- name: Run playwright tests
|
- name: Run playwright tests
|
||||||
run: yarn test --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
run: yarn test --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
||||||
env:
|
env:
|
||||||
|
|||||||
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -150,6 +150,10 @@ jobs:
|
|||||||
name: storybook
|
name: storybook
|
||||||
path: ./packages/component/storybook-static
|
path: ./packages/component/storybook-static
|
||||||
|
|
||||||
|
- name: Wait for Octobase Ready
|
||||||
|
run: |
|
||||||
|
node ./scripts/wait-3000-healthz.mjs
|
||||||
|
|
||||||
- name: Run playwright tests
|
- name: Run playwright tests
|
||||||
run: yarn test --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
run: yarn test --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
||||||
env:
|
env:
|
||||||
|
|||||||
37
scripts/wait-3000-healthz.mjs
Normal file
37
scripts/wait-3000-healthz.mjs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import http from 'node:http';
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
hostname: 'localhost',
|
||||||
|
port: 3000,
|
||||||
|
path: '/api/healthz',
|
||||||
|
method: 'GET',
|
||||||
|
};
|
||||||
|
|
||||||
|
const maxAttempts = 5;
|
||||||
|
const timeout = 1000;
|
||||||
|
let attempts = 0;
|
||||||
|
|
||||||
|
while (attempts < maxAttempts) {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, timeout * (1 << attempts)));
|
||||||
|
await new Promise(resolve => {
|
||||||
|
const req = http.request(options, res => {
|
||||||
|
if (res.statusCode === 204) {
|
||||||
|
console.log('Server is ready');
|
||||||
|
process.exit(0);
|
||||||
|
} else {
|
||||||
|
console.log(`Unexpected response: ${res.statusCode}`);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', error => {
|
||||||
|
console.error(error);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
req.end();
|
||||||
|
attempts++;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(1);
|
||||||
@@ -20,7 +20,7 @@ test.describe('Open AFFiNE', () => {
|
|||||||
const workspaceCards = await page.$$('data-testid=workspace-card');
|
const workspaceCards = await page.$$('data-testid=workspace-card');
|
||||||
expect(workspaceCards.length).toBe(2);
|
expect(workspaceCards.length).toBe(2);
|
||||||
await workspaceCards[1].click();
|
await workspaceCards[1].click();
|
||||||
await page.goto('http://localhost:8080');
|
await openHomePage(page);
|
||||||
|
|
||||||
const workspaceNameDom = await page.getByTestId('workspace-name');
|
const workspaceNameDom = await page.getByTestId('workspace-name');
|
||||||
const currentWorkspaceName = await workspaceNameDom.evaluate(
|
const currentWorkspaceName = await workspaceNameDom.evaluate(
|
||||||
|
|||||||
Reference in New Issue
Block a user