diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index c4c1ec7d0..894a9fff3 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -141,13 +141,13 @@ jobs: if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} run: yarn playwright install chromium --with-deps - - name: run unit tests + - name: Run unit tests if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} run: xvfb-run -a yarn test:unit env: VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} - - name: check for changes + - name: Check for changes if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} id: git-check run: | diff --git a/e2e/playwright/file-tree.spec.ts b/e2e/playwright/file-tree.spec.ts index 3921a0b30..88ed2d403 100644 --- a/e2e/playwright/file-tree.spec.ts +++ b/e2e/playwright/file-tree.spec.ts @@ -6,6 +6,7 @@ import { executorInputPath, getUtils, orRunWhenFullSuiteEnabled, + runningOnWindows, } from './test-utils' import { join } from 'path' import { FILE_EXT } from 'lib/constants' @@ -15,7 +16,9 @@ test.describe('integrations tests', () => { 'Creating a new file or switching file while in sketchMode should exit sketchMode', { tag: '@electron' }, async ({ page, context, homePage, scene, editor, toolbar, cmdBar }) => { - test.fixme(orRunWhenFullSuiteEnabled()) + if (runningOnWindows()) { + test.fixme(orRunWhenFullSuiteEnabled()) + } await context.folderSetupFn(async (dir) => { const bracketDir = join(dir, 'test-sample') await fsp.mkdir(bracketDir, { recursive: true }) diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png index 9ee9c7574..ebf1b7d07 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/test-utils.test.ts b/e2e/playwright/test-utils.test.ts new file mode 100644 index 000000000..0d0521084 --- /dev/null +++ b/e2e/playwright/test-utils.test.ts @@ -0,0 +1,96 @@ +import { + runningOnLinux, + runningOnMac, + runningOnWindows, + orRunWhenFullSuiteEnabled, +} from './test-utils' + +describe('platform detection utilities', () => { + const originalPlatform = process.platform + + afterAll(() => { + Object.defineProperty(process, 'platform', { + value: originalPlatform, + }) + }) + + describe('runningOnLinux', () => { + it('returns true on Linux', () => { + Object.defineProperty(process, 'platform', { + value: 'linux', + }) + expect(runningOnLinux()).toBe(true) + }) + + it('returns false on other platforms', () => { + Object.defineProperty(process, 'platform', { + value: 'darwin', + }) + expect(runningOnLinux()).toBe(false) + }) + }) + + describe('runningOnMac', () => { + it('returns true on Mac', () => { + Object.defineProperty(process, 'platform', { + value: 'darwin', + }) + expect(runningOnMac()).toBe(true) + }) + + it('returns false on other platforms', () => { + Object.defineProperty(process, 'platform', { + value: 'linux', + }) + expect(runningOnMac()).toBe(false) + }) + }) + + describe('runningOnWindows', () => { + it('returns true on Windows', () => { + Object.defineProperty(process, 'platform', { + value: 'win32', + }) + expect(runningOnWindows()).toBe(true) + }) + + it('returns false on other platforms', () => { + Object.defineProperty(process, 'platform', { + value: 'linux', + }) + expect(runningOnWindows()).toBe(false) + }) + }) +}) + +describe('utility to bypass unreliable tests', () => { + const originalEnv = { ...process.env } + + afterAll(() => { + process.env = { ...originalEnv } + }) + it('always runs them on dedicated branch', () => { + process.env.GITHUB_EVENT_NAME = 'push' + process.env.GITHUB_REF = 'refs/heads/all-e2e' + process.env.GITHUB_HEAD_REF = '' + process.env.GITHUB_BASE_REF = '' + const condition = orRunWhenFullSuiteEnabled() + expect(condition).toBe(false) + }) + it('skips them on the main branch', () => { + process.env.GITHUB_EVENT_NAME = 'push' + process.env.GITHUB_REF = 'refs/heads/main' + process.env.GITHUB_HEAD_REF = '' + process.env.GITHUB_BASE_REF = '' + const condition = orRunWhenFullSuiteEnabled() + expect(condition).toBe(true) + }) + it('skips them on pull requests', () => { + process.env.GITHUB_EVENT_NAME = 'pull_request' + process.env.GITHUB_REF = 'refs/pull/5883/merge' + process.env.GITHUB_HEAD_REF = 'my-branch' + process.env.GITHUB_BASE_REF = 'main' + const condition = orRunWhenFullSuiteEnabled() + expect(condition).toBe(true) + }) +}) diff --git a/e2e/playwright/test-utils.ts b/e2e/playwright/test-utils.ts index fddfc89fd..226dc887d 100644 --- a/e2e/playwright/test-utils.ts +++ b/e2e/playwright/test-utils.ts @@ -55,6 +55,18 @@ export const commonPoints = { export const editorSelector = '[role="textbox"][data-language="kcl"]' type PaneId = 'variables' | 'code' | 'files' | 'logs' +export function runningOnLinux() { + return process.platform === 'linux' +} + +export function runningOnMac() { + return process.platform === 'darwin' +} + +export function runningOnWindows() { + return process.platform === 'win32' +} + export function orRunWhenFullSuiteEnabled() { const branch = process.env.GITHUB_REF?.replace('refs/heads/', '') return branch !== 'all-e2e' diff --git a/playwright.config.ts b/playwright.config.ts index 56f61628a..48ef63bf7 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -12,6 +12,7 @@ import { defineConfig, devices } from '@playwright/test' export default defineConfig({ timeout: 120_000, // override the default 30s timeout testDir: './e2e/playwright', + testIgnore: '*.test.ts', // ignore unit tests /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ diff --git a/vite.config.ts b/vite.config.ts index 038bd0191..d4f918055 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -35,7 +35,7 @@ const config = defineConfig({ coverage: { provider: 'istanbul', // or 'v8' }, - exclude: [...configDefaults.exclude, '**/e2e/**/*', 'rust'], + exclude: [...configDefaults.exclude, '**/e2e/**/*.spec.*', 'rust'], deps: { optimizer: { web: {