mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 06:18:45 +08:00
feat: first test for data center
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/playwright/.cache/
|
||||
@@ -10,7 +10,8 @@
|
||||
".": "./dist/src/index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --project ./tsconfig.json"
|
||||
"build": "tsc --project ./tsconfig.json",
|
||||
"test": "playwright test"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
@@ -19,15 +20,15 @@
|
||||
"url": "git+https://github.com/toeverything/AFFiNE.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.29.1",
|
||||
"typescript": "^4.8.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.2.0",
|
||||
"encoding": "^0.1.13",
|
||||
"firebase": "^9.13.0",
|
||||
"ky": "^0.33.0",
|
||||
"swr": "^2.0.0",
|
||||
"lib0": "^0.2.58",
|
||||
"swr": "^2.0.0",
|
||||
"y-protocols": "^1.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { PlaywrightTestConfig } from '@playwright/test';
|
||||
|
||||
const config: PlaywrightTestConfig = {
|
||||
testDir: './tests',
|
||||
timeout: 30 * 1000,
|
||||
expect: {
|
||||
/**
|
||||
* Maximum time expect() should wait for the condition to be met.
|
||||
* For example in `await expect(locator).toHaveText();`
|
||||
*/
|
||||
timeout: 5000,
|
||||
},
|
||||
fullyParallel: true,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
use: {
|
||||
actionTimeout: 0,
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'on-first-retry',
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -0,0 +1,19 @@
|
||||
class DataCenter {
|
||||
static async init() {
|
||||
return new DataCenter();
|
||||
}
|
||||
|
||||
private constructor() {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
let _dataCenterInstance: Promise<DataCenter>;
|
||||
|
||||
export const getDataCenter = () => {
|
||||
if (!_dataCenterInstance) {
|
||||
_dataCenterInstance = DataCenter.init();
|
||||
}
|
||||
|
||||
return _dataCenterInstance;
|
||||
};
|
||||
@@ -2,3 +2,5 @@ export { signInWithGoogle, onAuthStateChanged } from './auth';
|
||||
export * from './request';
|
||||
export * from './sdks';
|
||||
export * from './websocket';
|
||||
|
||||
export { getDataCenter } from './data-center';
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { getDataCenter } from './utils.js';
|
||||
|
||||
test('can init data center', async () => {
|
||||
const dataCenter = await getDataCenter();
|
||||
|
||||
expect(dataCenter).toBeTruthy();
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
export const getDataCenter = () =>
|
||||
import('../src/data-center.js').then(async dataCenter =>
|
||||
dataCenter.getDataCenter()
|
||||
);
|
||||
Reference in New Issue
Block a user