bazel: decouple web application bundle from integration tests modules (#51560)

Make the web application bundle independent from the
`//client/web/src/integration` and `//client/shared/src/testing`. It
significantly slows down the Percy changes I iterate on locally.

Previously they were connected via multiple mock files and the shared
`isHotReloadEnabled` variable. The variable is redundant now, and the
mock files are correctly moved to the `web_tests` target out of
`web_lib`.
This commit is contained in:
Valery Bugakov 2023-05-09 23:47:56 -07:00 committed by GitHub
parent a990dd879d
commit e5a666fb13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 42 additions and 34 deletions

View File

@ -6,3 +6,4 @@ GH2SG.bookmarklet.js
svelte.config.js
vite.config.ts
playwright.config.ts
.vscode-test

View File

@ -48,6 +48,7 @@ pnpm-lock.yaml
node_modules/
client/web-sveltekit/.svelte-kit
*.module.scss.d.ts
.vscode-test
# Errors when used with @ianvs/prettier-plugin-sort-imports due to TS language API hitting global `eval`
client/browser/src/types/webextension-polyfill/index.d.ts

2
client/BUILD.bazel generated
View File

@ -7,11 +7,13 @@
# Test files, snapshots etc:
# gazelle:js_test_files **/*.{spec,test}.{ts,tsx}
# gazelle:js_test_files **/mock*.{ts,tsx}
# gazelle:js_test_files **/*.{mock,mocks}.{ts,tsx}
# gazelle:js_test_files **/mocks/**
# gazelle:js_test_files **/testutils/**
# gazelle:js_test_files **/tests/**
# gazelle:js_test_files **/__mocks__/**/*.{ts,tsx}
# gazelle:js_test_files **/fixtures/**/*.{ts,tsx}
# gazelle:js_test_files **/WebStory.{ts,tsx}
# TODO(bazel): put fixtures + testutils + ? into own rules
# js_{fixture}_files **/*.{fixture,fixtures}.{ts,tsx}

View File

@ -256,7 +256,6 @@ ts_project(
"src/search/helpers/queryExample.ts",
"src/search/helpers/searchContext.ts",
"src/search/index.ts",
"src/search/integration/index.ts",
"src/search/integration/streaming-search-mocks.ts",
"src/search/query/analyze.ts",
"src/search/query/completion.ts",

View File

@ -1 +0,0 @@
export * from './streaming-search-mocks'

View File

@ -1,6 +1,9 @@
import { downloadAndUnzipVSCode } from '@vscode/test-electron'
import { mixedSearchStreamEvents, highlightFileResult } from '@sourcegraph/shared/src/search/integration'
import {
mixedSearchStreamEvents,
highlightFileResult,
} from '@sourcegraph/shared/src/search/integration/streaming-search-mocks'
import { Settings } from '@sourcegraph/shared/src/settings/settings'
import { createVSCodeIntegrationTestContext, VSCodeIntegrationTestContext } from './context'

34
client/web/BUILD.bazel generated
View File

@ -173,7 +173,6 @@ ts_project(
"src/code-monitoring/CodeMonitoringLogo.tsx",
"src/codeMonitoring/index.ts",
"src/codeintel/BrainDot.tsx",
"src/codeintel/ReferencesPanel.mocks.ts",
"src/codeintel/ReferencesPanel.tsx",
"src/codeintel/ReferencesPanelQueries.ts",
"src/codeintel/index.ts",
@ -279,7 +278,6 @@ ts_project(
"src/components/WebHoverOverlay/WebHoverOverlay.fixtures.ts",
"src/components/WebHoverOverlay/WebHoverOverlay.tsx",
"src/components/WebHoverOverlay/index.ts",
"src/components/WebStory.tsx",
"src/components/branding/BrandLogo.tsx",
"src/components/diff/DiffBoundary.tsx",
"src/components/diff/DiffHunk.tsx",
@ -310,7 +308,6 @@ ts_project(
"src/components/externalServices/index.ts",
"src/components/fuzzyFinder/FuzzyActions.tsx",
"src/components/fuzzyFinder/FuzzyFiles.tsx",
"src/components/fuzzyFinder/FuzzyFinder.mocks.tsx",
"src/components/fuzzyFinder/FuzzyFinder.tsx",
"src/components/fuzzyFinder/FuzzyFinderFeatureFlag.ts",
"src/components/fuzzyFinder/FuzzyFsm.ts",
@ -329,7 +326,6 @@ ts_project(
"src/components/gitHubApps/GitHubAppPage.tsx",
"src/components/gitHubApps/GitHubAppsPage.tsx",
"src/components/gitHubApps/backend.ts",
"src/components/legacyLayoutRouteContext.ts",
"src/components/shared.tsx",
"src/components/time/Duration.tsx",
"src/components/useScrollToLocationHash.ts",
@ -354,7 +350,6 @@ ts_project(
"src/enterprise/batches/backend.ts",
"src/enterprise/batches/batch-spec/BatchSpecContext.tsx",
"src/enterprise/batches/batch-spec/TabBar.tsx",
"src/enterprise/batches/batch-spec/batch-spec.mock.ts",
"src/enterprise/batches/batch-spec/edit/DownloadSpecModal.tsx",
"src/enterprise/batches/batch-spec/edit/EditBatchSpecPage.tsx",
"src/enterprise/batches/batch-spec/edit/RunBatchSpecButton.tsx",
@ -424,7 +419,6 @@ ts_project(
"src/enterprise/batches/detail/ActiveExecutionNotice.tsx",
"src/enterprise/batches/detail/BatchChangeBurndownChart.tsx",
"src/enterprise/batches/detail/BatchChangeDetailsActionSection.tsx",
"src/enterprise/batches/detail/BatchChangeDetailsPage.mock.ts",
"src/enterprise/batches/detail/BatchChangeDetailsPage.tsx",
"src/enterprise/batches/detail/BatchChangeDetailsTabs.tsx",
"src/enterprise/batches/detail/BatchChangeStatsCard.tsx",
@ -437,7 +431,6 @@ ts_project(
"src/enterprise/batches/detail/WebhookAlert.tsx",
"src/enterprise/batches/detail/backend.ts",
"src/enterprise/batches/detail/bulk-operations/BulkOperationNode.tsx",
"src/enterprise/batches/detail/changesets/BatchChangeChangesets.mock.ts",
"src/enterprise/batches/detail/changesets/BatchChangeChangesets.tsx",
"src/enterprise/batches/detail/changesets/BatchChangeChangesetsHeader.tsx",
"src/enterprise/batches/detail/changesets/ChangesetCheckStatusCell.tsx",
@ -1051,7 +1044,6 @@ ts_project(
"src/marketing/components/SurveyUseCaseForm.tsx",
"src/marketing/components/TweetFeedback.tsx",
"src/marketing/page/SurveyForm.tsx",
"src/marketing/page/SurveyPage.mocks.ts",
"src/marketing/page/SurveyPage.tsx",
"src/marketing/toast/SurveySuccessToast.tsx",
"src/marketing/toast/SurveyToastContent.tsx",
@ -1076,7 +1068,6 @@ ts_project(
"src/nav/NavBar/NavBar.tsx",
"src/nav/NavBar/NavDropdown.tsx",
"src/nav/NavBar/index.tsx",
"src/nav/StatusMessagesNavItem.mocks.ts",
"src/nav/StatusMessagesNavItem.tsx",
"src/nav/StatusMessagesNavItemQueries.ts",
"src/nav/UserNavItem.tsx",
@ -1170,13 +1161,11 @@ ts_project(
"src/repo/RepoRevisionSidebarFocusableTree.tsx",
"src/repo/RepoRevisionSidebarSymbolTree.tsx",
"src/repo/RepoRevisionSidebarSymbols.tsx",
"src/repo/RepositoriesPopover/RepositoriesPopover.mocks.ts",
"src/repo/RepositoriesPopover/RepositoriesPopover.tsx",
"src/repo/RepositoriesPopover/RepositoryNode.tsx",
"src/repo/RepositoriesPopover/index.ts",
"src/repo/RepositoryFileTreePage.tsx",
"src/repo/RepositoryNotFoundPage.tsx",
"src/repo/RevisionsPopover/RevisionsPopover.mocks.ts",
"src/repo/RevisionsPopover/RevisionsPopover.tsx",
"src/repo/RevisionsPopover/RevisionsPopoverCommits.tsx",
"src/repo/RevisionsPopover/RevisionsPopoverReferences.tsx",
@ -1346,7 +1335,6 @@ ts_project(
"src/search/results/createActions.ts",
"src/search/results/export/SearchResultsCsvExportModal.tsx",
"src/search/results/export/searchResultsExport.ts",
"src/search/results/sidebar/Revisions.mocks.ts",
"src/search/results/sidebar/Revisions.tsx",
"src/search/results/sidebar/SearchAggregations.tsx",
"src/search/results/sidebar/SearchFiltersSidebar.tsx",
@ -1546,7 +1534,6 @@ ts_project(
"src/team/area/TeamMembersPage.tsx",
"src/team/area/TeamProfilePage.tsx",
"src/team/area/backend.ts",
"src/team/area/test-utils.ts",
"src/team/backend.ts",
"src/team/index.ts",
"src/team/list/DeleteTeamModal.tsx",
@ -1713,7 +1700,7 @@ ts_project(
"//:node_modules/focus-visible",
"//:node_modules/fzf",
"//:node_modules/graphiql",
"//:node_modules/graphql",
"//:node_modules/graphql", # keep
"//:node_modules/history",
"//:node_modules/http-status-codes",
"//:node_modules/is-absolute-url",
@ -1748,10 +1735,8 @@ ts_project(
"//:node_modules/use-resize-observer",
"//:node_modules/utility-types", #keep
"//:node_modules/uuid",
"//:node_modules/wildcard-mock-link",
"//:node_modules/yaml-ast-parser",
"//:node_modules/zustand",
"//client/shared:graphql_operations",
"//schema:schema-json",
],
)
@ -1772,6 +1757,7 @@ ts_project(
"src/auth/SignInPage.test.tsx",
"src/auth/SignUpPage.test.tsx",
"src/backend/persistenceMapper.test.ts",
"src/codeintel/ReferencesPanel.mocks.ts",
"src/codeintel/ReferencesPanel.test.tsx",
"src/components/ErrorBoundary.test.tsx",
"src/components/FilteredConnection/FilteredConnection.test.tsx",
@ -1779,15 +1765,21 @@ ts_project(
"src/components/FilteredConnection/hooks/useShowMorePagination.test.tsx",
"src/components/KeyboardShortcutsHelp/KeyboardShortcutsHelp.test.tsx",
"src/components/LoaderButton.test.tsx",
"src/components/WebStory.tsx",
"src/components/branding/BrandLogo.test.tsx",
"src/components/diff/DiffHunk.test.tsx",
"src/components/diff/DiffSplitHunk.test.tsx",
"src/components/diff/DiffStat.test.tsx",
"src/components/externalServices/ExternalServiceForm.test.tsx",
"src/components/externalServices/externalServices.test.tsx",
"src/components/fuzzyFinder/FuzzyFinder.mocks.tsx",
"src/components/fuzzyFinder/FuzzyFinder.test.tsx",
"src/components/legacyLayoutRouteContext.mock.ts",
"src/enterprise/batches/MultiSelectContext.test.tsx",
"src/enterprise/batches/batch-spec/batch-spec.mock.ts",
"src/enterprise/batches/batch-spec/yaml-util.test.ts",
"src/enterprise/batches/detail/BatchChangeDetailsPage.mock.ts",
"src/enterprise/batches/detail/changesets/BatchChangeChangesets.mock.ts",
"src/enterprise/code-monitoring/CodeMonitoringPage.test.tsx",
"src/enterprise/code-monitoring/CreateCodeMonitorPage.test.tsx",
"src/enterprise/code-monitoring/ManageCodeMonitorPage.test.tsx",
@ -1824,10 +1816,12 @@ ts_project(
"src/hooks/useUrlSyncedState.test.ts",
"src/hooks/useUrlSyncedString.test.tsx",
"src/insights/utils/use-series-toggle.test.tsx",
"src/marketing/page/SurveyPage.mocks.ts",
"src/marketing/page/SurveyPage.test.tsx",
"src/marketing/toast/SurveyToast.test.tsx",
"src/monitoring/shouldErrorBeReported.test.ts",
"src/nav/GlobalNavbar.test.tsx",
"src/nav/StatusMessagesNavItem.mocks.ts",
"src/nav/StatusMessagesNavItem.test.tsx",
"src/nav/UserNavItem.test.tsx",
"src/notebooks/serialize/convertMarkdownToBlocks.test.ts",
@ -1836,7 +1830,9 @@ ts_project(
"src/open-in-editor/migrate-legacy-settings.test.ts",
"src/person/PersonLink.test.tsx",
"src/repo/RepoRevisionSidebarSymbols.test.tsx",
"src/repo/RepositoriesPopover/RepositoriesPopover.mocks.ts",
"src/repo/RepositoriesPopover/RepositoriesPopover.test.tsx",
"src/repo/RevisionsPopover/RevisionsPopover.mocks.ts",
"src/repo/RevisionsPopover/RevisionsPopover.test.tsx",
"src/repo/blob/actions/ToggleRenderedFileMode.test.tsx",
"src/repo/blob/codemirror/document-highlights.test.ts",
@ -1853,6 +1849,7 @@ ts_project(
"src/search/results/SearchResultsInfoBar.test.tsx",
"src/search/results/StreamingSearchResults.test.tsx",
"src/search/results/export/searchResultsExport.test.ts",
"src/search/results/sidebar/Revisions.mocks.ts",
"src/search/results/sidebar/Revisions.test.tsx",
"src/site-admin/SiteAdminFeatureFlagsPage.test.ts",
"src/site-admin/SiteAdminMigrationsPage.test.ts",
@ -1861,6 +1858,7 @@ ts_project(
"src/site/LicenseExpirationAlert.test.tsx",
"src/stores/navbarSearchQueryState.test.ts",
"src/stores/notepad.test.ts",
"src/team/area/testContext.mock.ts",
"src/tour/components/Tour/Tour.test.tsx",
"src/tour/components/Tour/useTour.test.tsx",
"src/tracking/util.test.ts",
@ -1902,6 +1900,7 @@ ts_project(
"//:node_modules/ajv-formats",
"//:node_modules/date-fns",
"//:node_modules/delay",
"//:node_modules/graphql",
"//:node_modules/history",
"//:node_modules/lodash",
"//:node_modules/react",
@ -1912,6 +1911,7 @@ ts_project(
"//:node_modules/sinon",
"//:node_modules/wildcard-mock-link",
"//:node_modules/zustand",
"//client/shared:graphql_operations",
],
)
@ -1964,7 +1964,6 @@ WEBPACK_CONFIG_DEPS = [
"//:node_modules/webpack",
"//:node_modules/react-refresh",
"//client/web/dev",
"//client/web/src/integration",
"//:node_modules/react-visibility-sensor", # required for https://github.com/joshwnj/react-visibility-sensor/issues/148 workaround
# HACKS: bundle-time css import
@ -1993,6 +1992,7 @@ ENTERPRISE_BUNDLE_DATA_DEPS = BUNDLE_DATA_DEPS + [
"//:babel_config",
"//:browserslist",
"//:package_json",
":web_lib",
],
entry_points = {
"src/main.js": "app",

View File

@ -13,7 +13,7 @@ import { SourcegraphContext } from '../jscontext'
import { LegacyLayoutRouteContext, LegacyRouteContext } from '../LegacyRouteContext'
import { BreadcrumbSetters, BreadcrumbsProps, useBreadcrumbs } from './Breadcrumbs'
import { legacyLayoutRouteContextMock } from './legacyLayoutRouteContext'
import { legacyLayoutRouteContextMock } from './legacyLayoutRouteContext.mock'
import webStyles from '../SourcegraphWebApp.scss'

View File

@ -20,7 +20,6 @@ ts_project(
name = "integration",
srcs = [
"context.ts",
"environment.ts",
"graphQlResponseHelpers.ts",
"graphQlResults.ts",
"insights/utils/override-insights-graphql-api.ts",

View File

@ -2,7 +2,7 @@ import assert from 'assert'
import expect from 'expect'
import { mixedSearchStreamEvents } from '@sourcegraph/shared/src/search/integration'
import { mixedSearchStreamEvents } from '@sourcegraph/shared/src/search/integration/streaming-search-mocks'
import { accessibilityAudit } from '@sourcegraph/shared/src/testing/accessibility'
import { Driver, createDriverForTest } from '@sourcegraph/shared/src/testing/driver'
import { afterEachSaveScreenshotIfFailed } from '@sourcegraph/shared/src/testing/screenshotReporter'

View File

@ -1,2 +0,0 @@
// A shared variable to keep webpack.config and integration tests context configuration in sync.
export const isHotReloadEnabled = process.env.NODE_ENV !== 'production' && process.env.CI !== 'true'

View File

@ -4,7 +4,7 @@ import { test } from 'mocha'
import { encodeURIPathComponent } from '@sourcegraph/common'
import { SharedGraphQlOperations } from '@sourcegraph/shared/src/graphql-operations'
import { mixedSearchStreamEvents } from '@sourcegraph/shared/src/search/integration'
import { mixedSearchStreamEvents } from '@sourcegraph/shared/src/search/integration/streaming-search-mocks'
import { Driver, createDriverForTest } from '@sourcegraph/shared/src/testing/driver'
import { afterEachSaveScreenshotIfFailed } from '@sourcegraph/shared/src/testing/screenshotReporter'

View File

@ -5,7 +5,10 @@ import { subDays } from 'date-fns'
import expect from 'expect'
import { SharedGraphQlOperations } from '@sourcegraph/shared/src/graphql-operations'
import { highlightFileResult, mixedSearchStreamEvents } from '@sourcegraph/shared/src/search/integration'
import {
highlightFileResult,
mixedSearchStreamEvents,
} from '@sourcegraph/shared/src/search/integration/streaming-search-mocks'
import { SearchEvent } from '@sourcegraph/shared/src/search/stream'
import { accessibilityAudit } from '@sourcegraph/shared/src/testing/accessibility'
import { Driver, createDriverForTest } from '@sourcegraph/shared/src/testing/driver'

View File

@ -4,7 +4,10 @@ import { range } from 'lodash'
import { test } from 'mocha'
import { SharedGraphQlOperations, SearchContextMinimalFields } from '@sourcegraph/shared/src/graphql-operations'
import { highlightFileResult, mixedSearchStreamEvents } from '@sourcegraph/shared/src/search/integration'
import {
highlightFileResult,
mixedSearchStreamEvents,
} from '@sourcegraph/shared/src/search/integration/streaming-search-mocks'
import { accessibilityAudit } from '@sourcegraph/shared/src/testing/accessibility'
import { Driver, createDriverForTest } from '@sourcegraph/shared/src/testing/driver'
import { afterEachSaveScreenshotIfFailed } from '@sourcegraph/shared/src/testing/screenshotReporter'

View File

@ -12,7 +12,7 @@ import {
highlightFileResult,
symbolSearchStreamEvents,
ownerSearchStreamEvents,
} from '@sourcegraph/shared/src/search/integration'
} from '@sourcegraph/shared/src/search/integration/streaming-search-mocks'
import { SearchEvent } from '@sourcegraph/shared/src/search/stream'
import { accessibilityAudit } from '@sourcegraph/shared/src/testing/accessibility'
import { Driver, createDriverForTest } from '@sourcegraph/shared/src/testing/driver'

View File

@ -8,7 +8,7 @@ import { ListTeamsOfParentResult } from '../../graphql-operations'
import { LIST_TEAMS_OF_PARENT } from '../list/backend'
import { TeamChildTeamsPage } from './TeamChildTeamsPage'
import { testContext } from './test-utils'
import { testContext } from './testContext.mock'
const config: Meta = {
title: 'web/teams/TeamChildTeamsPage',

View File

@ -8,7 +8,7 @@ import { ListTeamMembersResult } from '../../graphql-operations'
import { LIST_TEAM_MEMBERS } from '../members/backend'
import { TeamMembersPage } from './TeamMembersPage'
import { testContext } from './test-utils'
import { testContext } from './testContext.mock'
const config: Meta = {
title: 'web/teams/TeamMembersPage',

View File

@ -3,7 +3,7 @@ import { Meta, Story } from '@storybook/react'
import { WebStory } from '../../components/WebStory'
import { TeamProfilePage } from './TeamProfilePage'
import { testContext } from './test-utils'
import { testContext } from './testContext.mock'
const config: Meta = {
title: 'web/teams/TeamProfilePage',

View File

@ -27,7 +27,6 @@ const {
} = require('@sourcegraph/build-config')
const { IS_PRODUCTION, IS_DEVELOPMENT, ENVIRONMENT_CONFIG, writeIndexHTMLPlugin } = require('./dev/utils')
const { isHotReloadEnabled } = require('./src/integration/environment')
const {
NODE_ENV,
@ -52,6 +51,7 @@ const {
SENTRY_PROJECT,
} = ENVIRONMENT_CONFIG
const isHotReloadEnabled = NODE_ENV !== 'production' && !IS_CI
const IS_PERSISTENT_CACHE_ENABLED = false // Disabled in Bazel
const IS_EMBED_ENTRY_POINT_ENABLED = ENTERPRISE && (IS_PRODUCTION || (IS_DEVELOPMENT && EMBED_DEVELOPMENT))

View File

@ -29,7 +29,6 @@ const {
} = require('@sourcegraph/build-config')
const { IS_PRODUCTION, IS_DEVELOPMENT, ENVIRONMENT_CONFIG, writeIndexHTMLPlugin } = require('./dev/utils')
const { isHotReloadEnabled } = require('./src/integration/environment')
const {
NODE_ENV,
@ -55,6 +54,7 @@ const {
SOURCEGRAPH_APP,
} = ENVIRONMENT_CONFIG
const isHotReloadEnabled = NODE_ENV !== 'production' && !IS_CI
const IS_PERSISTENT_CACHE_ENABLED = IS_DEVELOPMENT && !IS_CI
const IS_EMBED_ENTRY_POINT_ENABLED = ENTERPRISE && (IS_PRODUCTION || (IS_DEVELOPMENT && EMBED_DEVELOPMENT))