test: add e2e test for validation of editor version
This commit is contained in:
@@ -6,7 +6,7 @@ import './temporary.css';
|
|||||||
import { Logger } from '@toeverything/pathfinder-logger';
|
import { Logger } from '@toeverything/pathfinder-logger';
|
||||||
import '@fontsource/space-mono';
|
import '@fontsource/space-mono';
|
||||||
import '@fontsource/poppins';
|
import '@fontsource/poppins';
|
||||||
import '../utils/print-build-info';
|
import { printBuildInfo } from '../utils/print-build-info';
|
||||||
import ProviderComposer from '@/components/provider-composer';
|
import ProviderComposer from '@/components/provider-composer';
|
||||||
import type { PropsWithChildren, ReactElement, ReactNode } from 'react';
|
import type { PropsWithChildren, ReactElement, ReactNode } from 'react';
|
||||||
import type { NextPage } from 'next';
|
import type { NextPage } from 'next';
|
||||||
@@ -34,7 +34,9 @@ type AppPropsWithLayout = AppProps & {
|
|||||||
|
|
||||||
const App = ({ Component, pageProps }: AppPropsWithLayout) => {
|
const App = ({ Component, pageProps }: AppPropsWithLayout) => {
|
||||||
const getLayout = Component.getLayout || (page => page);
|
const getLayout = Component.getLayout || (page => page);
|
||||||
|
useEffect(() => {
|
||||||
|
printBuildInfo();
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Logger />
|
<Logger />
|
||||||
|
|||||||
@@ -12,11 +12,19 @@ type Config = {
|
|||||||
|
|
||||||
const nextConfig = getConfig();
|
const nextConfig = getConfig();
|
||||||
const publicRuntimeConfig: Config = nextConfig.publicRuntimeConfig;
|
const publicRuntimeConfig: Config = nextConfig.publicRuntimeConfig;
|
||||||
|
const setAffineAppProperties = () => {
|
||||||
|
const input = document.createElement('input');
|
||||||
|
const id = 'editor-version';
|
||||||
|
if (document.getElementById(id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
input.value = publicRuntimeConfig.EDITOR_VERSION;
|
||||||
|
input.type = 'hidden';
|
||||||
|
input.id = id;
|
||||||
|
input.setAttribute('data-testid', 'editor-version');
|
||||||
|
document.body.appendChild(input);
|
||||||
|
};
|
||||||
const printBuildInfo = () => {
|
const printBuildInfo = () => {
|
||||||
// if (isDev) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
console.group('Build info');
|
console.group('Build info');
|
||||||
console.log('Project:', publicRuntimeConfig.PROJECT_NAME);
|
console.log('Project:', publicRuntimeConfig.PROJECT_NAME);
|
||||||
console.log(
|
console.log(
|
||||||
@@ -30,6 +38,7 @@ const printBuildInfo = () => {
|
|||||||
`${publicRuntimeConfig.NODE_ENV}${publicRuntimeConfig.CI ? '(ci)' : ''}`
|
`${publicRuntimeConfig.NODE_ENV}${publicRuntimeConfig.CI ? '(ci)' : ''}`
|
||||||
);
|
);
|
||||||
console.log('Editor Version:', publicRuntimeConfig.EDITOR_VERSION);
|
console.log('Editor Version:', publicRuntimeConfig.EDITOR_VERSION);
|
||||||
|
|
||||||
console.log('Version:', publicRuntimeConfig.VERSION);
|
console.log('Version:', publicRuntimeConfig.VERSION);
|
||||||
console.log(
|
console.log(
|
||||||
'AFFiNE is an open source project, you can view its source code on GitHub!'
|
'AFFiNE is an open source project, you can view its source code on GitHub!'
|
||||||
@@ -38,8 +47,8 @@ const printBuildInfo = () => {
|
|||||||
`https://github.com/toeverything/AFFiNE/tree/${publicRuntimeConfig.COMMIT_HASH}`
|
`https://github.com/toeverything/AFFiNE/tree/${publicRuntimeConfig.COMMIT_HASH}`
|
||||||
);
|
);
|
||||||
console.groupEnd();
|
console.groupEnd();
|
||||||
|
|
||||||
|
setAffineAppProperties();
|
||||||
};
|
};
|
||||||
|
|
||||||
printBuildInfo();
|
export { printBuildInfo };
|
||||||
|
|
||||||
export {};
|
|
||||||
|
|||||||
24
tests/console.spec.ts
Normal file
24
tests/console.spec.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
import { loadPage } from './libs/load-page';
|
||||||
|
import pkg from './../packages/app/package.json';
|
||||||
|
|
||||||
|
loadPage();
|
||||||
|
|
||||||
|
test.describe('web console', () => {
|
||||||
|
test('editor version', async ({ page }) => {
|
||||||
|
// https://playwright.dev/docs/evaluating
|
||||||
|
// https://github.com/microsoft/playwright/issues/13059
|
||||||
|
// Get the handle to a specific function.
|
||||||
|
// const getEditoVersionHandle = await page.evaluate(
|
||||||
|
// 'window.__getEditoVersion'
|
||||||
|
// );
|
||||||
|
//Later on, call this function with some arguments.
|
||||||
|
// const msg = await getEditoVersionHandle.evaluate((post, args) => post);
|
||||||
|
// console.log(getEditoVersionHandle);
|
||||||
|
const documentEditorVersion = await page.inputValue('input#editor-version');
|
||||||
|
const pkgEditorVersion = pkg.dependencies['@blocksuite/editor'];
|
||||||
|
|
||||||
|
expect(documentEditorVersion).toBe(pkgEditorVersion);
|
||||||
|
console.log('pkgEditorVersion', pkgEditorVersion);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user