Skip to content

Commit

Permalink
chore: fix visual tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hikerpig committed Jun 16, 2024
1 parent dcf2936 commit 26adaa2
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 30 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Currently we need two shells to develop the live-editor demo.
./scripts/watch-for-browser.sh
```

2. Start the demo. When the CLI stops rolling, open `http://localhost:3001/demo/live-editor/` in
2. Start the demo. When the CLI stops rolling, open `https://localhost:3001/demo/live-editor/` in
your browser and you will see the editor page. It will reload once `demo/src` or its dependency packages change.

```sh
Expand All @@ -72,5 +72,5 @@ pnpm run compile
Build demo and docs site.

```sh
pnpm run build-site
pnpm run build-site
```
2 changes: 1 addition & 1 deletion demo/cypress/e2e/test-utils/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { encodeForUrl } from '@pintora/core'

export function startRender(opts: { code: string }) {
const { code } = opts
const DEMO_HOST = 'http://localhost:3001'
const DEMO_HOST = 'https://localhost:3001'
const encodedCode = encodeForUrl(code)
const demoUrl = `${DEMO_HOST}/demo/preview/?code=${encodedCode}&e2e=true`
return cy.visit(demoUrl)
Expand Down
4 changes: 2 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"cypress:open": "cypress open",
"local-test:visual": "percy exec -- cypress run",
"test:visual": "percy exec -- cypress run --record",
"ci:visual": "start-server-and-test serve http://localhost:3001/demo/preview/ test:visual"
"ci:visual": "start-server-and-test serve http://localhost:3001/demo/preview/ local-test:visual"
},
"dependencies": {
"@codemirror/basic-setup": "^0.20.0",
Expand Down Expand Up @@ -54,7 +54,7 @@
"cypress": "^13.3.2",
"less": "^4.1.3",
"postcss": "^8.4.16",
"start-server-and-test": "^2.0.0",
"start-server-and-test": "^2.0.4",
"tailwindcss": "^3.1.8",
"typescript": "^5.0.0",
"vite": "^5.0.10",
Expand Down
22 changes: 15 additions & 7 deletions demo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development

const serverAllow = process.env.SERVER_ALLOW || '..'

const enableHttps = process.env.ENABLE_HTTPS === 'true'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
Expand All @@ -37,9 +39,11 @@ export default defineConfig({
strategies: 'injectManifest',
workbox: {},
}),
ViteMkcert({
savePath: './certs', // save the generated certificate into certs directory
}),
enableHttps
? ViteMkcert({
savePath: './certs', // save the generated certificate into certs directory
})
: null,
],
base: BASE,
mode,
Expand All @@ -48,10 +52,14 @@ export default defineConfig({
// Allow serving files from one level up to the project root
allow: [serverAllow],
},
https: {
cert: './certs/cert.pem',
key: './certs/dev.pem'
}
...(enableHttps
? {
https: {
cert: './certs/cert.pem',
key: './certs/dev.pem',
},
}
: null),
},
build: {
rollupOptions: {
Expand Down
60 changes: 42 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 26adaa2

Please sign in to comment.