Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: move pte e2e collaborationtests out in own workflow #5084

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/e2e-pte.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: End-to-End PTE collaboration tests
on:
# Build on pushes branches that have a PR (including drafts)
pull_request:
# Build on commits pushed to branches without a PR if it's in the allowlist
push:
branches: [next]
jobs:
playwright-test:
timeout-minutes: 30
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
strategy:
fail-fast: false
matrix:
project: [chromium]
# Add more shards here if needed
shardIndex: [1, 2]
shardTotal: [2]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18

- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-modules-${{ env.cache-name }}-
${{ runner.os }}-modules-
${{ runner.os }}-

- name: Install project dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Store Playwright's Version
run: |
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV

- name: Cache Playwright Browsers for Playwright's Version
id: cache-playwright-browsers
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}

- name: Install Playwright Browsers
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: Run end-to-end tests
run: cd packages/@sanity/portable-text-editor && yarn test:e2e --silent --shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }}
38 changes: 0 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,6 @@ jobs:
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install project dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Store Playwright's Version
run: |
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV

- name: Cache Playwright Browsers for Playwright's Version
id: cache-playwright-browsers
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}

- name: Install Playwright Browsers
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: Build CLI
run: yarn build:cli # Needed for CLI tests

Expand Down Expand Up @@ -140,23 +119,6 @@ jobs:
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Store Playwright's Version
run: |
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV

- name: Cache Playwright Browsers for Playwright's Version
id: cache-playwright-browsers
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}

- name: Install Playwright Browsers
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: Test
id: test
run: |
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,8 @@
"node-notifier": "^10.0.0"
},
"packageManager": "yarn@1.22.19",
"isSanityMonorepo": true
"isSanityMonorepo": true,
"dependencies": {
"yarn": "^1.22.19"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./test/setup/collaborative.jest.env.ts */
/** @jest-environment ./e2e-tests/setup/collaborative.jest.env.ts */
import os from 'os'
import '../setup/globals.jest'
import {noop} from 'lodash'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./test/setup/collaborative.jest.env.ts */
/** @jest-environment ./e2e-tests/setup/collaborative.jest.env.ts */

import '../setup/globals.jest'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./test/setup/collaborative.jest.env.ts */
/** @jest-environment ./e2e-tests/setup/collaborative.jest.env.ts */
import {toPlainText} from '@portabletext/toolkit'
import '../setup/globals.jest'
import type {PortableTextBlock} from '@sanity/types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./test/setup/collaborative.jest.env.ts */
/** @jest-environment ./e2e-tests/setup/collaborative.jest.env.ts */

import '../setup/globals.jest'
import type {PortableTextBlock} from '@sanity/types'
Expand Down
19 changes: 16 additions & 3 deletions packages/@sanity/portable-text-editor/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

const {createJestConfig} = require('../../../test/config.cjs')

const PTE_E2E = process.env.PTE_E2E

if (!PTE_E2E) {
module.exports = createJestConfig({
displayName: require('./package.json').name,
modulePathIgnorePatterns: ['<rootDir>/e2e-tests'],
})
return
}

// eslint-disable-next-line no-console
console.info('Running collaborate editing tests for the Portable Text Editor')

module.exports = createJestConfig({
displayName: require('./package.json').name,
globalSetup: '<rootDir>/test/setup/globalSetup.ts',
globalTeardown: '<rootDir>/test/setup/globalTeardown.ts',
setupFilesAfterEnv: ['<rootDir>/test/setup/afterEnv.ts'],
globalSetup: '<rootDir>/e2e-tests/setup/globalSetup.ts',
globalTeardown: '<rootDir>/e2e-tests/setup/globalTeardown.ts',
setupFilesAfterEnv: ['<rootDir>/e2e-tests/setup/afterEnv.ts'],
})
1 change: 1 addition & 0 deletions packages/@sanity/portable-text-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"prettier": "prettier --write './**/*.{ts,tsx,js,css,html}'",
"dev": "cd ./test/ && ts-node serve",
"test": "jest",
"test:e2e": "PTE_E2E=true jest e2e-tests/__tests__",
"test:watch": "jest --watch",
"watch": "pkg-utils watch --tsconfig tsconfig.lib.json"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const debugVerbose = debug.enabled && false

// The editor will commit changes in a throttled fashion in order
// not to overload the network and degrade performance while typing.
const FLUSH_PATCHES_THROTTLED_MS = process.env.NODE_ENV === 'test' ? 100 : 1000
const FLUSH_PATCHES_THROTTLED_MS = process.env.NODE_ENV === 'test' ? 500 : 1000

/**
* @internal
Expand Down
Loading