web: extract testing package (#45812)

This commit is contained in:
Valery Bugakov 2022-12-23 10:04:50 +08:00 committed by GitHub
parent d5fbcbe7f9
commit 9db57c1df8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 87 additions and 18 deletions

View File

@ -17,6 +17,7 @@ client/search-ui/node_modules
client/shared/node_modules
client/storybook/node_modules
client/template-parser/node_modules
client/testing/node_modules
client/web/node_modules
client/wildcard/node_modules
client/vscode/node_modules

View File

@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event'
import { act } from 'react-dom/test-utils'
import { spy, assert, useFakeTimers } from 'sinon'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/shared/dev/aria-asserts'
import { NOOP_TELEMETRY_SERVICE } from '@sourcegraph/shared/src/telemetry/telemetryService'
import { MockIntersectionObserver } from '@sourcegraph/shared/src/testing/MockIntersectionObserver'
import {
@ -11,6 +10,7 @@ import {
mockGetUserSearchContextNamespaces,
} from '@sourcegraph/shared/src/testing/searchContexts/testHelpers'
import { NOOP_PLATFORM_CONTEXT } from '@sourcegraph/shared/src/testing/searchTestHelpers'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/testing'
import { SearchContextDropdown, SearchContextDropdownProps } from './SearchContextDropdown'

View File

@ -2,8 +2,8 @@ import { screen, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import sinon from 'sinon'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/shared/dev/aria-asserts'
import { Progress } from '@sourcegraph/shared/src/search/stream'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/testing'
import { renderWithBrandedContext } from '@sourcegraph/wildcard/src/testing'
import { StreamingProgressSkippedPopover } from './StreamingProgressSkippedPopover'

View File

@ -3,9 +3,9 @@ import userEvent from '@testing-library/user-event'
import * as H from 'history'
import { NEVER } from 'rxjs'
import { assertAriaEnabled } from '@sourcegraph/testing'
import { renderWithBrandedContext } from '@sourcegraph/wildcard/src/testing'
import { assertAriaEnabled } from '../../dev/aria-asserts'
import { createBarrier } from '../api/integration-test/testHelpers'
import { NOOP_TELEMETRY_SERVICE } from '../telemetry/telemetryService'

View File

@ -0,0 +1 @@
out/

View File

@ -0,0 +1,12 @@
// @ts-check
const baseConfig = require('../../.eslintrc.js')
module.exports = {
extends: '../../.eslintrc.js',
parserOptions: {
...baseConfig.parserOptions,
project: [__dirname + '/tsconfig.json'],
},
overrides: baseConfig.overrides,
}

4
client/testing/README.md Normal file
View File

@ -0,0 +1,4 @@
# Tools for writing tests
Package-agnostic utilities for unit and integration tests.
App or package-specific utilities should live in `client/{packageName}/src/testing`.

View File

@ -0,0 +1,5 @@
// @ts-check
module.exports = {
extends: '../../babel.config.js',
}

View File

@ -0,0 +1,13 @@
// @ts-check
const config = require('../../jest.config.base')
const exportedConfig = {
...config,
displayName: 'testing',
rootDir: __dirname,
roots: ['<rootDir>'],
verbose: true,
}
module.exports = exportedConfig

View File

@ -0,0 +1,13 @@
{
"private": true,
"name": "@sourcegraph/testing",
"version": "0.0.1",
"description": "Sourcegraph testing API",
"main": "./src/index.ts",
"sideEffects": false,
"license": "Apache-2.0",
"scripts": {
"lint:js": "yarn run -T eslint --cache 'src/**/*.[jt]s?(x)'",
"test": "yarn run -T jest"
}
}

View File

@ -0,0 +1 @@
export * from './aria-asserts'

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"references": [{ "path": "../common" }],
"compilerOptions": {
"jsx": "react-jsx",
"module": "commonjs",
"sourceRoot": "src",
"rootDir": ".",
"outDir": "./out",
"baseUrl": "./src",
},
"include": ["./src/**/*", "./*.ts"],
}

View File

@ -4,8 +4,8 @@ import * as H from 'history'
import { NEVER, of } from 'rxjs'
import sinon from 'sinon'
import { assertAriaDisabled } from '@sourcegraph/shared/dev/aria-asserts'
import { MockedTestProvider } from '@sourcegraph/shared/src/testing/apollo'
import { assertAriaDisabled } from '@sourcegraph/testing'
import { renderWithBrandedContext } from '@sourcegraph/wildcard/src/testing'
import { AuthenticatedUser } from '../../auth'

View File

@ -4,8 +4,8 @@ import * as H from 'history'
import { NEVER, of } from 'rxjs'
import sinon from 'sinon'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/shared/dev/aria-asserts'
import { MockedTestProvider } from '@sourcegraph/shared/src/testing/apollo'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/testing'
import { renderWithBrandedContext } from '@sourcegraph/wildcard/src/testing'
import {

View File

@ -2,8 +2,8 @@ import { fireEvent, getByRole, screen } from '@testing-library/react'
import { createMemoryHistory, createLocation } from 'history'
import { NEVER } from 'rxjs'
import { assertAriaDisabled } from '@sourcegraph/shared/dev/aria-asserts'
import { MockedTestProvider } from '@sourcegraph/shared/src/testing/apollo'
import { assertAriaDisabled } from '@sourcegraph/testing'
import { renderWithBrandedContext } from '@sourcegraph/wildcard/src/testing'
import { mockAuthenticatedUser, mockCodeMonitorFields } from '../testing/util'

View File

@ -2,7 +2,7 @@ import { render } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import sinon from 'sinon'
import { assertAriaDisabled } from '@sourcegraph/shared/dev/aria-asserts'
import { assertAriaDisabled } from '@sourcegraph/testing'
import { ActionEditor, ActionEditorProps } from './ActionEditor'

View File

@ -3,8 +3,8 @@ import { render } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import sinon from 'sinon'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/shared/dev/aria-asserts'
import { MockedTestProvider, waitForNextApolloResponse } from '@sourcegraph/shared/src/testing/apollo'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/testing'
import { MonitorEmailPriority, SendTestEmailResult, SendTestEmailVariables } from '../../../../graphql-operations'
import { mockAuthenticatedUser } from '../../testing/util'

View File

@ -3,8 +3,8 @@ import { render } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import sinon from 'sinon'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/shared/dev/aria-asserts'
import { MockedTestProvider, waitForNextApolloResponse } from '@sourcegraph/shared/src/testing/apollo'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/testing'
import { SendTestSlackWebhookResult, SendTestSlackWebhookVariables } from '../../../../graphql-operations'
import { mockAuthenticatedUser } from '../../testing/util'

View File

@ -3,8 +3,8 @@ import { render } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import sinon from 'sinon'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/shared/dev/aria-asserts'
import { MockedTestProvider, waitForNextApolloResponse } from '@sourcegraph/shared/src/testing/apollo'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/testing'
import { SendTestWebhookResult, SendTestWebhookVariables } from '../../../../graphql-operations'
import { mockAuthenticatedUser } from '../../testing/util'

View File

@ -2,7 +2,7 @@ import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import sinon from 'sinon'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/shared/dev/aria-asserts'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/testing'
import { Button } from '../../Button'
import { PopoverTrigger } from '../../Popover'

View File

@ -1,7 +1,7 @@
import { render, RenderResult, cleanup, fireEvent } from '@testing-library/react'
import sinon from 'sinon'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/shared/dev/aria-asserts'
import { assertAriaDisabled, assertAriaEnabled } from '@sourcegraph/testing'
import { PageSwitcher, PageSwitcherProps } from './PageSwitcher'

View File

@ -8,12 +8,7 @@
"baseUrl": "./src",
"jsx": "react-jsx",
},
"references": [
{ "path": "../shared" },
{ "path": "../branded" },
{ "path": "../../schema" },
{ "path": "../common" },
],
"references": [{ "path": "../branded" }, { "path": "../common" }, { "path": "../testing" }],
"include": ["**/*", ".*"],
"exclude": ["../../node_modules", "./node_modules", "./out"],
}

View File

@ -29,6 +29,7 @@ DIRS=(
client/shared
client/storybook
client/template-parser
client/testing
client/vscode
client/web
client/wildcard

View File

@ -848,6 +848,9 @@ importers:
client/template-parser:
specifiers: {}
client/testing:
specifiers: {}
client/vscode:
specifiers:
vsce: ^2.7.0

View File

@ -20,6 +20,7 @@
{ "path": "client/storybook" },
{ "path": "client/search" },
{ "path": "client/search-ui" },
{ "path": "client/testing" },
{ "path": "dev/release" },
{ "path": "schema" },
{ "path": "client/codeintellify" },

View File

@ -5519,6 +5519,12 @@ __metadata:
languageName: unknown
linkType: soft
"@sourcegraph/testing@workspace:client/testing":
version: 0.0.0-use.local
resolution: "@sourcegraph/testing@workspace:client/testing"
languageName: unknown
linkType: soft
"@sourcegraph/tsconfig@npm:^4.0.1":
version: 4.0.1
resolution: "@sourcegraph/tsconfig@npm:4.0.1"