Add utilities to check platform to determine if a test should run (#5983)
* Add tests for utility to bypass unreliable tests * Limit skip to just Windows * Ignore unit tests from Playwright * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -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 })
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 143 KiB |
96
e2e/playwright/test-utils.test.ts
Normal file
96
e2e/playwright/test-utils.test.ts
Normal file
@ -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)
|
||||
})
|
||||
})
|
||||
@ -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'
|
||||
|
||||
Reference in New Issue
Block a user