feat: support get datasource status (#3645)

This commit is contained in:
Alex Yang
2023-08-10 01:05:34 -04:00
committed by GitHub
parent 05144abd6a
commit dafd5619e6
34 changed files with 836 additions and 46 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
import { test } from '@affine-test/kit/playwright';
import { openHomePage, webUrl } from '@affine-test/kit/utils/load-page';
import { coreUrl, openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test';
@@ -17,7 +17,7 @@ test('goto not found workspace', async ({ page }) => {
await waitEditorLoad(page);
// if doesn't wait for timeout, data won't be saved into indexedDB
await page.waitForTimeout(1000);
await page.goto(new URL('/workspace/invalid/all', webUrl).toString());
await page.goto(new URL('/workspace/invalid/all', coreUrl).toString());
await page.waitForTimeout(1000);
expect(page.url()).toBe(new URL('/404', webUrl).toString());
expect(page.url()).toBe(new URL('/404', coreUrl).toString());
});
+12
View File
@@ -0,0 +1,12 @@
import { test } from '@affine-test/kit/playwright';
import { openPrototypeProviderStatusPage } from '@affine-test/kit/utils/load-page';
import { expect } from '@playwright/test';
test('syncing and synced status should works', async ({ page }) => {
await openPrototypeProviderStatusPage(page);
await expect(page.getByTestId('status')).toHaveText('synced');
await page.getByTestId('start-button').click();
await expect(page.getByTestId('status')).toHaveText('syncing');
await page.getByTestId('stop-button').click();
await expect(page.getByTestId('status')).toHaveText('synced');
});
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@affine-test/affine-prototype",
"private": true,
"scripts": {
"e2e": "yarn playwright test"
},
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@playwright/test": "^1.36.2"
},
"version": "0.8.0-canary.14"
}
@@ -0,0 +1,63 @@
import type {
PlaywrightTestConfig,
PlaywrightWorkerOptions,
} from '@playwright/test';
// import { devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: './e2e',
fullyParallel: true,
timeout: process.env.CI ? 50_000 : 30_000,
use: {
baseURL: 'http://localhost:8080/',
browserName:
(process.env.BROWSER as PlaywrightWorkerOptions['browserName']) ??
'chromium',
permissions: ['clipboard-read', 'clipboard-write'],
viewport: { width: 1440, height: 800 },
actionTimeout: 5 * 1000,
locale: 'en-US',
// Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer
// You can open traces locally(`npx playwright show-trace trace.zip`)
// or in your browser on [Playwright Trace Viewer](https://trace.playwright.dev/).
trace: 'on-first-retry',
// Record video only when retrying a test for the first time.
video: 'on-first-retry',
},
forbidOnly: !!process.env.CI,
workers: 4,
retries: 1,
// 'github' for GitHub Actions CI to generate annotations, plus a concise 'dot'
// default 'list' when running locally
// See https://playwright.dev/docs/test-reporters#github-actions-annotations
reporter: process.env.CI ? 'github' : 'list',
webServer: [
// Intentionally not building the web, reminds you to run it by yourself.
{
command: 'yarn workspace @affine/prototype preview',
port: 3003,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
},
},
],
};
if (process.env.CI) {
config.retries = 3;
config.workers = '50%';
}
export default config;
+16
View File
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"esModuleInterop": true,
"outDir": "lib"
},
"include": ["e2e"],
"references": [
{
"path": "../kit"
},
{
"path": "../fixtures"
}
]
}
+8 -3
View File
@@ -1,11 +1,16 @@
import type { Page } from '@playwright/test';
export const webUrl = 'http://localhost:8080';
export const coreUrl = 'http://localhost:8080';
export const prototypeUrl = 'http://localhost:3003';
export async function openHomePage(page: Page) {
await page.goto(webUrl);
await page.goto(coreUrl);
}
export async function openPluginPage(page: Page) {
await page.goto(`${webUrl}/_plugin/index.html`);
await page.goto(`${coreUrl}/_plugin/index.html`);
}
export async function openPrototypeProviderStatusPage(page: Page) {
await page.goto(`${prototypeUrl}/suite/provider-status.html`);
}