Upgrade the e2e test setup
This commit is contained in:
parent
041627f7e4
commit
cd6f44d9dd
7 changed files with 110 additions and 2056 deletions
|
@ -1,6 +1,9 @@
|
||||||
import type {PlaywrightTestConfig} from '@playwright/test'
|
import type {PlaywrightTestConfig} from '@playwright/test'
|
||||||
import {devices} from '@playwright/test'
|
import {devices} from '@playwright/test'
|
||||||
|
|
||||||
|
const port = 8082
|
||||||
|
const url = `http://localhost:${port}`
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read environment variables from file.
|
* Read environment variables from file.
|
||||||
* https://github.com/motdotla/dotenv
|
* https://github.com/motdotla/dotenv
|
||||||
|
@ -14,13 +17,13 @@ const config: PlaywrightTestConfig = {
|
||||||
testDir: '../src',
|
testDir: '../src',
|
||||||
testMatch: /.*\.e2e\.ts/,
|
testMatch: /.*\.e2e\.ts/,
|
||||||
/* Maximum time one test can run for. */
|
/* Maximum time one test can run for. */
|
||||||
timeout: 100000,
|
timeout: 4000,
|
||||||
expect: {
|
expect: {
|
||||||
/**
|
/**
|
||||||
* Maximum time expect() should wait for the condition to be met.
|
* Maximum time expect() should wait for the condition to be met.
|
||||||
* For example in `await expect(locator).toHaveText();`
|
* For example in `await expect(locator).toHaveText();`
|
||||||
*/
|
*/
|
||||||
timeout: 10000,
|
timeout: 1000,
|
||||||
},
|
},
|
||||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||||
forbidOnly: !!process.env.CI,
|
forbidOnly: !!process.env.CI,
|
||||||
|
@ -39,6 +42,7 @@ const config: PlaywrightTestConfig = {
|
||||||
|
|
||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
trace: 'on-first-retry',
|
trace: 'on-first-retry',
|
||||||
|
baseURL: url,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Configure projects for major browsers */
|
/* Configure projects for major browsers */
|
||||||
|
@ -50,12 +54,12 @@ const config: PlaywrightTestConfig = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
// {
|
||||||
name: 'firefox',
|
// name: 'firefox',
|
||||||
use: {
|
// use: {
|
||||||
...devices['Desktop Firefox'],
|
// ...devices['Desktop Firefox'],
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
],
|
],
|
||||||
|
|
||||||
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
|
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
|
||||||
|
@ -68,9 +72,9 @@ const config: PlaywrightTestConfig = {
|
||||||
TODO 👆
|
TODO 👆
|
||||||
*/
|
*/
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'yarn run serve:ci --port 8080',
|
command: `yarn run serve:ci --port ${port}`,
|
||||||
port: 8080,
|
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
|
url: url,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@percy/cli": "^1.16.0",
|
"@percy/cli": "^1.16.0",
|
||||||
"@percy/playwright": "^1.0.4",
|
"@percy/playwright": "^1.0.4",
|
||||||
"@playwright/test": "^1.29.1",
|
"@playwright/test": "^1.36.2",
|
||||||
"@react-three/drei": "^7.2.2",
|
"@react-three/drei": "^7.2.2",
|
||||||
"@react-three/fiber": "^7.0.6",
|
"@react-three/fiber": "^7.0.6",
|
||||||
"@rollup/plugin-virtual": "^3.0.1",
|
"@rollup/plugin-virtual": "^3.0.1",
|
||||||
|
@ -32,17 +32,8 @@
|
||||||
"@types/react": "^17.0.9",
|
"@types/react": "^17.0.9",
|
||||||
"@vitejs/plugin-react": "^4.0.0",
|
"@vitejs/plugin-react": "^4.0.0",
|
||||||
"@vitejs/plugin-react-swc": "^3.3.2",
|
"@vitejs/plugin-react-swc": "^3.3.2",
|
||||||
"esbuild": "^0.17.6",
|
|
||||||
"esbuild-register": "^3.4.2",
|
|
||||||
"parcel": "^2.9.3",
|
|
||||||
"three": "^0.130.1",
|
"three": "^0.130.1",
|
||||||
"typescript": "^4.4.2",
|
"typescript": "^4.4.2",
|
||||||
"vite": "^4.3.9",
|
"vite": "^4.3.9"
|
||||||
"vite-plugin-commonjs": "^0.8.0",
|
|
||||||
"vite-plugin-html-template": "^1.2.0",
|
|
||||||
"vite-plugin-mpa": "^1.2.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@originjs/vite-plugin-commonjs": "^1.0.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,34 +4,49 @@ import styled from 'styled-components'
|
||||||
export const ItemSectionWithPreviews = (props: {
|
export const ItemSectionWithPreviews = (props: {
|
||||||
groupName: string
|
groupName: string
|
||||||
modules: string[]
|
modules: string[]
|
||||||
|
collapsedByDefault: boolean
|
||||||
|
collapsible: boolean
|
||||||
}) => {
|
}) => {
|
||||||
let {groupName, modules} = props
|
const {groupName, modules, collapsedByDefault, collapsible} = props
|
||||||
|
console.log(groupName)
|
||||||
|
|
||||||
|
const [collapsed, setCollapsed] = React.useState(
|
||||||
|
collapsible && collapsedByDefault,
|
||||||
|
)
|
||||||
|
|
||||||
|
const toggleCollapse = () => {
|
||||||
|
if (!collapsible) return
|
||||||
|
setCollapsed(!collapsed)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<SectionHeader>{groupName}</SectionHeader>
|
<SectionHeader collapsible={collapsible} onClick={toggleCollapse}>
|
||||||
<ItemListContainer>
|
{groupName}
|
||||||
{modules.map((moduleName) => {
|
</SectionHeader>
|
||||||
const href = `/${groupName}/${moduleName}/`
|
|
||||||
return (
|
{!collapsed && (
|
||||||
<ItemContainer key={`li-${moduleName}`}>
|
<ItemListContainer>
|
||||||
<ItemLink href={href}>
|
{modules.map((moduleName) => {
|
||||||
{/* <PreviewContainer>
|
const href = `/${groupName}/${moduleName}/`
|
||||||
<iframe src={href} frameBorder="0" tabIndex={-1} />
|
return (
|
||||||
</PreviewContainer> */}
|
<ItemContainer key={`li-${moduleName}`}>
|
||||||
<ItemDesc>
|
<ItemLink href={href}>
|
||||||
<h3>{moduleName}</h3>
|
<ItemDesc>
|
||||||
<p>{href}</p>
|
<h3>{moduleName}</h3>
|
||||||
</ItemDesc>
|
<p>{href}</p>
|
||||||
</ItemLink>
|
</ItemDesc>
|
||||||
</ItemContainer>
|
</ItemLink>
|
||||||
)
|
</ItemContainer>
|
||||||
})}
|
)
|
||||||
</ItemListContainer>
|
})}
|
||||||
|
</ItemListContainer>
|
||||||
|
)}
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const SectionHeader = styled.h3`
|
const SectionHeader = styled.h3<{collapsible: boolean}>`
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Inter', sans-serif;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
@ -42,6 +57,10 @@ const SectionHeader = styled.h3`
|
||||||
|
|
||||||
/* White/White50 */
|
/* White/White50 */
|
||||||
color: rgba(255, 255, 255, 0.5);
|
color: rgba(255, 255, 255, 0.5);
|
||||||
|
|
||||||
|
text-decoration: ${({collapsible}) => (collapsible ? 'underline' : 'none')};
|
||||||
|
cursor: ${({collapsible}) => (collapsible ? 'pointer' : 'default')};
|
||||||
|
user-select: none;
|
||||||
`
|
`
|
||||||
|
|
||||||
const ItemDesc = styled.div`
|
const ItemDesc = styled.div`
|
||||||
|
|
|
@ -55,6 +55,8 @@ export const PlaygroundPage = ({
|
||||||
key={`group-${groupName}`}
|
key={`group-${groupName}`}
|
||||||
groupName={groupName}
|
groupName={groupName}
|
||||||
modules={modules}
|
modules={modules}
|
||||||
|
collapsedByDefault={groupName === 'tests'}
|
||||||
|
collapsible={groupName === 'tests'}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</ContentContainer>
|
</ContentContainer>
|
||||||
|
|
|
@ -7,25 +7,8 @@ const delay = (dur: number) =>
|
||||||
new Promise((resolve) => setTimeout(resolve, dur))
|
new Promise((resolve) => setTimeout(resolve, dur))
|
||||||
|
|
||||||
test.describe('setting-static-props', () => {
|
test.describe('setting-static-props', () => {
|
||||||
test.beforeEach(async ({page}) => {
|
|
||||||
// TODO This is a temporary hack that re-tries navigating to the url in case the server isn't ready yet.
|
|
||||||
// Ideally we should wait running the e2e tests until the server has signalled that it's ready to serve.
|
|
||||||
// For now, let's use this hack, otherwise, the e2e test may _randomly_ break on the CI with "ERRConnectionRefused"
|
|
||||||
const maxRetries = 3
|
|
||||||
for (let i = 1; i <= maxRetries; i++) {
|
|
||||||
try {
|
|
||||||
await page.goto('http://localhost:8080/tests/setting-static-props')
|
|
||||||
} catch (error) {
|
|
||||||
if (i === maxRetries) {
|
|
||||||
throw error
|
|
||||||
} else {
|
|
||||||
await delay(1000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
test('Undo/redo', async ({page}) => {
|
test('Undo/redo', async ({page}) => {
|
||||||
|
await page.goto('./tests/setting-static-props/')
|
||||||
// https://github.com/microsoft/playwright/issues/12298
|
// https://github.com/microsoft/playwright/issues/12298
|
||||||
// The div does in fact intercept pointer events, but it is meant to 🤦
|
// The div does in fact intercept pointer events, but it is meant to 🤦
|
||||||
await page
|
await page
|
||||||
|
|
|
@ -1,19 +1,11 @@
|
||||||
import {defineConfig} from 'vite'
|
import {defineConfig} from 'vite'
|
||||||
// import react from '@vitejs/plugin-react'
|
|
||||||
import react from '@vitejs/plugin-react-swc'
|
import react from '@vitejs/plugin-react-swc'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
// import {mapValues} from 'lodash-es'
|
|
||||||
// import {PlaygroundPage} from './devEnv/home/PlaygroundPage'
|
|
||||||
import fg from 'fast-glob'
|
import fg from 'fast-glob'
|
||||||
import {getAliasesFromTsConfigForRollup} from '../../devEnv/getAliasesFromTsConfig'
|
import {getAliasesFromTsConfigForRollup} from '../../devEnv/getAliasesFromTsConfig'
|
||||||
import {definedGlobals} from '../../theatre/devEnv/definedGlobals'
|
import {definedGlobals} from '../../theatre/devEnv/definedGlobals'
|
||||||
import devCommonJS from 'vite-plugin-commonjs'
|
|
||||||
// import {viteCommonjs as productionCommonJS} from '@originjs/vite-plugin-commonjs'
|
|
||||||
// import mpa from 'vite-plugin-mpa'
|
|
||||||
// import htmlTemplatePlugin from 'vite-plugin-html-template'
|
|
||||||
|
|
||||||
const fromPlaygroundDir = (folder: string) => path.resolve(__dirname, folder)
|
const fromPlaygroundDir = (folder: string) => path.resolve(__dirname, folder)
|
||||||
// const buildDir = playgroundDir('build')
|
|
||||||
const srcDir = fromPlaygroundDir('src')
|
const srcDir = fromPlaygroundDir('src')
|
||||||
const sharedDir = fromPlaygroundDir('src/shared')
|
const sharedDir = fromPlaygroundDir('src/shared')
|
||||||
const personalDir = fromPlaygroundDir('src/personal')
|
const personalDir = fromPlaygroundDir('src/personal')
|
||||||
|
@ -48,12 +40,10 @@ const config = defineConfig(async ({command}) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
root: srcDir,
|
root: srcDir,
|
||||||
plugins: [
|
plugins: [react()],
|
||||||
react(),
|
|
||||||
dev ? devCommonJS() : /*productionCommonJS()*/ undefined,
|
|
||||||
],
|
|
||||||
appType: 'mpa',
|
appType: 'mpa',
|
||||||
server: {
|
server: {
|
||||||
|
port: 8082,
|
||||||
// base: '/playground/',
|
// base: '/playground/',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue