diff --git a/.gitattributes b/.gitattributes index 2a17c50d9d1..7c94819e94f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,4 +5,3 @@ cmd/repo-updater/repos/testdata/** linguist-generated=true **/*.pb.go linguist-generated=true CHANGELOG.md merge=union **/mock_*_test.go linguist-generated=true -*.har filter=lfs diff=lfs merge=lfs -text diff --git a/client/browser/.gitignore b/client/browser/.gitignore index ca88b72f0e8..92a68b53761 100644 --- a/client/browser/.gitignore +++ b/client/browser/.gitignore @@ -21,3 +21,5 @@ npm-debug.log.* /.gtm/ code-intel-extensions + +*.har diff --git a/client/browser/README.md b/client/browser/README.md index 33752220709..f44c59d8f66 100644 --- a/client/browser/README.md +++ b/client/browser/README.md @@ -141,16 +141,13 @@ Click reload for Sourcegraph at `about:debugging` - Unit tests: `sg test bext` - Integration tests - - install [git lfs](https://git-lfs.github.com) if it's not installed - run - - fetch snapshots with `git lfs fetch` - build browser extension with `sg test bext-build` - run tests with `sg test bext-integration` - develop - add/edit test case or at least its part with navigation to a certain page - if there's no page snapshot for created test or page URL referenced in the existing test has been changed, test will fail with 'Page not found' error - to generate or update page snapshots for tests run `yarn record-integration` - - after pushing the updated snapshots to remote they will be stored on GitHub LFS and snapshot files will contain references to that storage - E2E tests: `sg test bext-build` & `sg test bext-e2e` ### E2E tests diff --git a/client/browser/package.json b/client/browser/package.json index dd67c301587..9624ef4c115 100644 --- a/client/browser/package.json +++ b/client/browser/package.json @@ -28,7 +28,8 @@ "clean": "rm -rf build/ dist/ *.zip *.xpi .checksum", "test": "jest --testPathIgnorePatterns end-to-end integration", "test-e2e": "mocha './src/end-to-end/**/*.test.ts'", - "test-integration": "TS_NODE_PROJECT=src/integration/tsconfig.json SOURCEGRAPH_BASE_URL=https://sourcegraph.com mocha --parallel=$CI --retries=2 ./src/integration/**/*.test.ts", + "run-integration": "TS_NODE_PROJECT=src/integration/tsconfig.json SOURCEGRAPH_BASE_URL=https://sourcegraph.com mocha --parallel=$CI --retries=2 ./src/integration/**/*.test.ts", + "test-integration": "node scripts/test-integration", "record-integration": "node scripts/record-integration", "create-source-zip": "node scripts/create-source-zip" }, diff --git a/client/browser/scripts/record-integration.js b/client/browser/scripts/record-integration.js index 270e7d75155..82acec06bf8 100644 --- a/client/browser/scripts/record-integration.js +++ b/client/browser/scripts/record-integration.js @@ -1,30 +1,36 @@ +const { Console } = require('console') + const { readdir, readFile } = require('mz/fs') const shelljs = require('shelljs') -const recordSnapshot = grepValue => - shelljs.exec( - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - `POLLYJS_MODE=record SOURCEGRAPH_BASE_URL=https://sourcegraph.com yarn test-integration --grep='${grepValue}'`, - (error, stdout, stderr) => { - if (error) { - console.error(error) - return - } - console.log(`stdout: ${stdout}`) - console.error(`stderr: ${stderr}`) - } - ) +const { compressRecordings, deleteRecordings } = require('./utils') -;(async () => { +const recordSnapshot = grepValue => + new Promise((resolve, reject) => { + shelljs.exec( + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `POLLYJS_MODE=record SOURCEGRAPH_BASE_URL=https://sourcegraph.com yarn run-integration --grep='${grepValue}'`, + (code, stdout, stderr) => { + console.log(`stdout: ${stdout}`) + console.log(`stderr: ${stderr}`) + + if (code === 0) { + resolve() + } + + const error = new Error() + error.code = code + reject(error) + } + ) + }) + +const recordTests = async () => { // 1. Record by --grep args const args = process.argv.slice(2) for (let index = 0; index < args.length; ++index) { if (args[index] === '--grep' && !!args[index + 1]) { - recordSnapshot(args[index + 1]) - return - } - if (args[index].startsWith('--grep=')) { - recordSnapshot(args.replace('--grep=', '')) + await recordSnapshot(args[index + 1]) return } } @@ -43,9 +49,17 @@ const recordSnapshot = grepValue => .filter(Boolean) .map(matchArray => matchArray[2]) - for (const testName of testNames) { - recordSnapshot(testName) + await Promise.all(testNames.map(testName => recordSnapshot(testName))) +} + +// eslint-disable-next-line no-void +void (async () => { + try { + await recordTests() + await compressRecordings() + process.exit(0) + } catch (error) { + await deleteRecordings() + process.exit(error.code ?? 1) } -})().catch(error => { - console.log(error) -}) +})() diff --git a/client/browser/scripts/test-integration.js b/client/browser/scripts/test-integration.js new file mode 100644 index 00000000000..ab835766782 --- /dev/null +++ b/client/browser/scripts/test-integration.js @@ -0,0 +1,12 @@ +const shelljs = require('shelljs') + +const { decompressRecordings, deleteRecordings } = require('./utils') + +// eslint-disable-next-line no-void +void (async () => { + await decompressRecordings() + shelljs.exec('POLLYJS_MODE=replay yarn run-integration', async code => { + await deleteRecordings() + process.exit(code) + }) +})() diff --git a/client/browser/scripts/utils.js b/client/browser/scripts/utils.js new file mode 100644 index 00000000000..6a90ab0afc5 --- /dev/null +++ b/client/browser/scripts/utils.js @@ -0,0 +1,107 @@ +const { pipeline } = require('stream') +const { promisify } = require('util') +const { createGzip, unzip } = require('zlib') + +const { readdir, writeFile, readFile, unlink, createReadStream, createWriteStream } = require('mz/fs') + +const fixturesPath = './src/integration/__fixtures__' +const recordingFileName = 'recording.har' + +// eslint-disable-next-line @typescript-eslint/restrict-template-expressions +const buildCompressedFilePath = filePath => `${filePath}.gz` +const buildDecompressedFilePath = compressedFilePath => compressedFilePath.replace(/\.gz$/, '') + +const findRecordingPath = async (path, isCompressed) => { + const content = await readdir(path, { withFileTypes: true }) + + if (content.length === 0) { + return + } + + if (content[0].isDirectory()) { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + return findRecordingPath(`${path}/${content[0].name}`, isCompressed) + } + + const recording = content.find( + element => + element.isFile() && + element.name === (isCompressed ? buildCompressedFilePath(recordingFileName) : recordingFileName) + ) + + if (recording) { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + return `${path}/${recording.name}` + } +} + +const pipe = promisify(pipeline) +const compress = async (input, output) => { + const gzip = createGzip() + const source = createReadStream(input) + const destination = createWriteStream(output) + await pipe(source, gzip, destination) +} + +const compressRecordings = async () => { + const folders = await readdir(fixturesPath) + + await Promise.all( + folders.map(async folder => { + const filePath = await findRecordingPath(`${fixturesPath}/${folder}`, false) + + if (filePath) { + try { + await compress(filePath, buildCompressedFilePath(filePath)) + await unlink(filePath) // delete original recording + } catch (error) { + console.error('An error occurred:', error) + process.exitCode = 1 + } + } + }) + ) +} + +const unzipAsPromise = promisify(unzip) +const decompressRecordings = async () => { + const folders = await readdir(fixturesPath) + + await Promise.all( + folders.map(async folder => { + const filePath = await findRecordingPath(`${fixturesPath}/${folder}`, true) + + if (filePath) { + try { + const content = await readFile(filePath, 'base64') + const result = await unzipAsPromise(Buffer.from(content, 'base64')) + await writeFile(buildDecompressedFilePath(filePath), result) + } catch (error) { + console.error('An error occurred:', error) + process.exitCode = 1 + } + } + }) + ) +} + +const deleteRecordings = async () => { + const folders = await readdir(fixturesPath) + + await Promise.all( + folders.map(async folder => { + const filePath = await findRecordingPath(`${fixturesPath}/${folder}`, false) + + if (filePath) { + try { + await unlink(filePath) // delete original recording + } catch (error) { + console.error('An error occurred:', error) + process.exitCode = 1 + } + } + }) + ) +} + +module.exports = { compressRecordings, decompressRecordings, deleteRecordings } diff --git a/client/browser/src/integration/__fixtures__/git_hub_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har b/client/browser/src/integration/__fixtures__/git_hub_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har deleted file mode 100644 index 070e4aa6fdd..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1b02a1fbaa176e4c1fe5e94c7f17e7251a731966c605f7c1ec13b996f39032a7 -size 3965367 diff --git a/client/browser/src/integration/__fixtures__/git_hub_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har.gz new file mode 100644 index 00000000000..882eee3ba00 Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode_773639707/recording.har b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode_773639707/recording.har deleted file mode 100644 index 82c71e730a3..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode_773639707/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:680180fe613ebe023e3056e0f0115ba7174044fdae8881045d6deb4df37ee8fb -size 4131287 diff --git a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode_773639707/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode_773639707/recording.har.gz new file mode 100644 index 00000000000..6a42b847a21 Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_split_mode_773639707/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode_618850985/recording.har b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode_618850985/recording.har deleted file mode 100644 index 39228d4e750..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode_618850985/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fd37bd88edd1df6e937fafe69ca216a12d26ef42b04975f421aaca2c9738c097 -size 4122447 diff --git a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode_618850985/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode_618850985/recording.har.gz new file mode 100644 index 00000000000..6821b8d48af Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_commit_view_has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode/has_sourcegraph_icon_button_and_provides_hover_tooltips_for_pull_requests_in_unified_mode_618850985/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_split_mode/provides_hover_tooltips_for_pull_requests_in_split_mode_2968075303/recording.har b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_split_mode/provides_hover_tooltips_for_pull_requests_in_split_mode_2968075303/recording.har deleted file mode 100644 index 83662eb19d1..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_split_mode/provides_hover_tooltips_for_pull_requests_in_split_mode_2968075303/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8cc95274dd025a4fdecfeb63102c57ef8303f77706517a1bae36133966dbbb9f -size 4066535 diff --git a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_split_mode/provides_hover_tooltips_for_pull_requests_in_split_mode_2968075303/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_split_mode/provides_hover_tooltips_for_pull_requests_in_split_mode_2968075303/recording.har.gz new file mode 100644 index 00000000000..2463a66288e Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_split_mode/provides_hover_tooltips_for_pull_requests_in_split_mode_2968075303/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_unified_mode/provides_hover_tooltips_for_pull_requests_in_unified_mode_4227635693/recording.har b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_unified_mode/provides_hover_tooltips_for_pull_requests_in_unified_mode_4227635693/recording.har deleted file mode 100644 index c68fb24fccf..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_unified_mode/provides_hover_tooltips_for_pull_requests_in_unified_mode_4227635693/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:034a9eb1dd7162034b61a734ee6c50e93142b2aa2810e6cb58694b7a31b7ac52 -size 4008413 diff --git a/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_unified_mode/provides_hover_tooltips_for_pull_requests_in_unified_mode_4227635693/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_unified_mode/provides_hover_tooltips_for_pull_requests_in_unified_mode_4227635693/recording.har.gz new file mode 100644 index 00000000000..0136c37098e Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_pull_request_pages_files_changed_view_provides_hover_tooltips_for_pull_requests_in_unified_mode/provides_hover_tooltips_for_pull_requests_in_unified_mode_4227635693/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_advanced_search_page_if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_search_query/if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_552820258/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_search_pages_advanced_search_page_if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_search_query/if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_552820258/recording.har.gz new file mode 100644 index 00000000000..6fab86b0cf9 Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_search_pages_advanced_search_page_if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_search_query/if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_552820258/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_global_search_page_viewport_l_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_global_search_page_viewport_l_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz new file mode 100644 index 00000000000..ebcfd4f51f7 Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_global_search_page_viewport_l_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_global_search_page_viewport_m_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_global_search_page_viewport_m_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz new file mode 100644 index 00000000000..bb16b91ffc7 Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_global_search_page_viewport_m_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_renders_search_on_sourcegraph_button/renders_search_on_sourcegraph_button_1406237094/recording.har b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_renders_search_on_sourcegraph_button/renders_search_on_sourcegraph_button_1406237094/recording.har deleted file mode 100644 index 43688b25bd4..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_renders_search_on_sourcegraph_button/renders_search_on_sourcegraph_button_1406237094/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c8ad10704ec10c5139255a476a8bc91e05c79a832219b3439108da36f0a7a872 -size 5094260 diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_repo_search_page_viewport_l_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_repo_search_page_viewport_l_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz new file mode 100644 index 00000000000..4366541d02e Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_repo_search_page_viewport_l_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_repo_search_page_viewport_m_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_repo_search_page_viewport_m_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz new file mode 100644 index 00000000000..2373b4c8af5 Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_repo_search_page_viewport_m_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_language_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type__1878682397/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_and_language/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_a_708823018/recording.har b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_and_language/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_a_708823018/recording.har deleted file mode 100644 index 9e53194196e..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_and_language/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_result_type_a_708823018/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0cf7baf17162acef5c20b21efd21bf0f2b4479e5677e3008318a9b6291dfa505 -size 8201635 diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_query/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_que_1166304504/recording.har b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_query/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_que_1166304504/recording.har deleted file mode 100644 index 96b774b7209..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_query/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_que_1166304504/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1fef47c5587ed9ebc0ab7dde1b4995346ffc3138bb3b1c75db569d0a6225fbf8 -size 13870835 diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_sea_2172073946/recording.har b/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_sea_2172073946/recording.har deleted file mode 100644 index 1c5cda769d1..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_search_pages_search_results_page_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_search_query_from_search_input/search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_proper_type_and_sea_2172073946/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5c76bfb8597e61ebcfe412850632587b7ea351dba11fb06c1e383d1e3947d7b9 -size 14059886 diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_and_advanced_search_pages_if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_search_query/if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_552820258/recording.har b/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_and_advanced_search_pages_if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_search_query/if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_552820258/recording.har deleted file mode 100644 index de1caef4e0f..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_and_advanced_search_pages_if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_search_query/if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_552820258/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:dc3776c52971b9f79bef7116c5fcead03a369c73c0728c758556154e877845b6 -size 3597076 diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_and_advanced_search_pages_if_search_input_is_empty_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_empty_search_query/if_search_input_is_empty_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_1634084962/recording.har b/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_and_advanced_search_pages_if_search_input_is_empty_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_empty_search_query/if_search_input_is_empty_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_1634084962/recording.har deleted file mode 100644 index b88602ccc0b..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_and_advanced_search_pages_if_search_input_is_empty_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_empty_search_query/if_search_input_is_empty_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_1634084962/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ff760a6d933108a2c79bc43fb95d4340dd9d994b8dc0d1b4742c99befcf5c977 -size 3596387 diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_and_advanced_search_pages_render_search_on_sourcegraph_button/render_search_on_sourcegraph_button_2658884963/recording.har b/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_and_advanced_search_pages_render_search_on_sourcegraph_button/render_search_on_sourcegraph_button_2658884963/recording.har deleted file mode 100644 index 15ba2d25d2e..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_and_advanced_search_pages_render_search_on_sourcegraph_button/render_search_on_sourcegraph_button_2658884963/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:14aad19c1be3a8b9aac6d0052b448263faa15185b141fc15b1fa356baaa6d6da -size 3596869 diff --git a/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_search_page_if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_search_query/if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_552820258/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_search_page_if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_search_query/if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_552820258/recording.har.gz new file mode 100644 index 00000000000..93d64f78b51 Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_search_pages_simple_search_page_if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_with_type_repo_and_search_query/if_search_input_has_value_search_on_sourcegraph_click_navigates_to_sourcegraph_search_page_552820258/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_hub_shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_definition_setting/shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_defi_4078478237/recording.har b/client/browser/src/integration/__fixtures__/git_hub_shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_definition_setting/shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_defi_4078478237/recording.har deleted file mode 100644 index 061e843f51a..00000000000 --- a/client/browser/src/integration/__fixtures__/git_hub_shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_definition_setting/shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_defi_4078478237/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5f3e8fa573777c7317c134b3f2549b45e81f98b999542472edb5af45ea6ec615 -size 7942071 diff --git a/client/browser/src/integration/__fixtures__/git_hub_shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_definition_setting/shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_defi_4078478237/recording.har.gz b/client/browser/src/integration/__fixtures__/git_hub_shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_definition_setting/shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_defi_4078478237/recording.har.gz new file mode 100644 index 00000000000..1b653b20600 Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_hub_shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_definition_setting/shows_hover_tooltips_when_hovering_a_token_and_respects_enable_single_click_to_go_to_defi_4078478237/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_lab_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har b/client/browser/src/integration/__fixtures__/git_lab_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har deleted file mode 100644 index d913222954f..00000000000 --- a/client/browser/src/integration/__fixtures__/git_lab_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:acadffb600dd1e46ffaba1ea14ecf3e787ce171a37b05bc0829f47a4a7241d91 -size 11336381 diff --git a/client/browser/src/integration/__fixtures__/git_lab_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har.gz b/client/browser/src/integration/__fixtures__/git_lab_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har.gz new file mode 100644 index 00000000000..9d70e0de185 Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_lab_adds_view_on_sourcegraph_buttons_to_files/adds_view_on_sourcegraph_buttons_to_files_2768809061/recording.har.gz differ diff --git a/client/browser/src/integration/__fixtures__/git_lab_shows_hover_tooltips_when_hovering_a_token/shows_hover_tooltips_when_hovering_a_token_1368546183/recording.har b/client/browser/src/integration/__fixtures__/git_lab_shows_hover_tooltips_when_hovering_a_token/shows_hover_tooltips_when_hovering_a_token_1368546183/recording.har deleted file mode 100644 index db810bd9b8d..00000000000 --- a/client/browser/src/integration/__fixtures__/git_lab_shows_hover_tooltips_when_hovering_a_token/shows_hover_tooltips_when_hovering_a_token_1368546183/recording.har +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1d7997563b2397afded2489e67fd060556ae2ef63f60a28fb2dc8bd4539a5ad3 -size 11336406 diff --git a/client/browser/src/integration/__fixtures__/git_lab_shows_hover_tooltips_when_hovering_a_token/shows_hover_tooltips_when_hovering_a_token_1368546183/recording.har.gz b/client/browser/src/integration/__fixtures__/git_lab_shows_hover_tooltips_when_hovering_a_token/shows_hover_tooltips_when_hovering_a_token_1368546183/recording.har.gz new file mode 100644 index 00000000000..763ac8917cc Binary files /dev/null and b/client/browser/src/integration/__fixtures__/git_lab_shows_hover_tooltips_when_hovering_a_token/shows_hover_tooltips_when_hovering_a_token_1368546183/recording.har.gz differ diff --git a/client/browser/src/integration/after-install-page.test.ts b/client/browser/src/integration/after-install-page.test.ts deleted file mode 100644 index d881ba16c76..00000000000 --- a/client/browser/src/integration/after-install-page.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { createDriverForTest, Driver } from '@sourcegraph/shared/src/testing/driver' - -import { BrowserIntegrationTestContext, createBrowserIntegrationTestContext } from './context' -import { closeInstallPageTab } from './shared' - -describe('After install page', () => { - let driver: Driver - before(async () => { - driver = await createDriverForTest({ loadExtension: true }) - await closeInstallPageTab(driver.browser) - if (driver.sourcegraphBaseUrl !== 'https://sourcegraph.com') { - await driver.setExtensionSourcegraphUrl() - } - }) - after(() => driver?.close()) - - let testContext: BrowserIntegrationTestContext - beforeEach(async function () { - testContext = await createBrowserIntegrationTestContext({ - driver, - currentTest: this.currentTest!, - directory: __dirname, - }) - - // Requests to other origins that we need to ignore to prevent breaking tests. - testContext.server - .get('https://storage.googleapis.com/sourcegraph-assets/code-host-integration/*path') - .intercept((request, response) => { - response.sendStatus(200) - }) - - // Ensure that the same assets are requested in all environments. - await driver.page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: 'light' }]) - }) - - afterEach(() => testContext?.dispose()) - - it('renders after install page content', async () => { - await driver.openBrowserExtensionPage('after_install') - await driver.page.$("[data-testid='after-install-page-content']") - }) -}) diff --git a/client/browser/src/integration/github.test.ts b/client/browser/src/integration/github.test.ts index f451f0a0930..d43969bd6e9 100644 --- a/client/browser/src/integration/github.test.ts +++ b/client/browser/src/integration/github.test.ts @@ -37,7 +37,12 @@ describe('GitHub', () => { directory: __dirname, }) - mockUrls(['https://api.github.com/_private/browser/*', 'https://collector.github.com/*path']) + mockUrls([ + 'https://api.github.com/_private/browser/*', + 'https://collector.github.com/*path', + 'https://github.com/favicon.ico', + 'https://github.githubassets.com/favicons/*path', + ]) testContext.server.any('https://api.github.com/repos/*').intercept((request, response) => { response @@ -244,10 +249,6 @@ describe('GitHub', () => { hasRedirectedToDefinition = true }) - testContext.server.get('https://github.com/favicon.ico').intercept((request, response) => { - response.sendStatus(200) - }) - const openPageAndGetToken = async () => { await driver.page.goto( 'https://github.com/sourcegraph/jsonrpc2/blob/4fb7cd90793ee6ab445f466b900e6bffb9b63d78/call_opt.go' @@ -757,57 +758,16 @@ describe('GitHub', () => { describe('Search pages', () => { const sourcegraphSearchPage = 'https://sourcegraph.com/search' - describe('Simple and advanced search pages', () => { - beforeEach(() => { - mockUrls(['https://github.githubassets.com/favicons/*path']) - }) + const pages = [ + { name: 'Simple search page', url: 'https://github.com/search' }, + { name: 'Advanced search page', url: 'https://github.com/search/advanced' }, + ] - const pages = ['https://github.com/search', 'https://github.com/search/advanced'] - - it('render "Search on Sourcegraph" button', async () => { - for (const page of pages) { + for (const page of pages) { + describe(page.name, () => { + it('if search input has value "Search on Sourcegraph" click navigates to Sourcegraph search page with type "repo" and search query', async () => { await driver.newPage() - await driver.page.goto(page) - - const linkToSourcegraph = await driver.page.waitForSelector( - '[data-testid="search-on-sourcegraph"]', - { timeout: 3000 } - ) - - assert(linkToSourcegraph, 'Expected link to Sourcegraph search page exists') - } - }) - - it('if search input is empty "Search on Sourcegraph" click navigates to Sourcegraph search page with type "repo" and empty search query', async () => { - for (const page of pages) { - await driver.newPage() - await driver.page.goto(page) - - const linkToSourcegraph = await driver.page.waitForSelector( - '[data-testid="search-on-sourcegraph"]', - { timeout: 3000 } - ) - let hasRedirectedToSourcegraphSearch = false - testContext.server.get(sourcegraphSearchPage).intercept(request => { - if (request.query.q === 'type:repo') { - hasRedirectedToSourcegraphSearch = true - } - }) - - await linkToSourcegraph?.click() - await driver.page.waitForTimeout(3000) - - assert( - hasRedirectedToSourcegraphSearch, - 'Expected to be redirected to Sourcegraph search page with type "repo" and empty query' - ) - } - }) - - it('if search input has value "Search on Sourcegraph" click navigates to Sourcegraph search page with type "repo" and search query', async () => { - for (const page of pages) { - await driver.newPage() - await driver.page.goto(page) + await driver.page.goto(page.url) const query = 'Hello world!' const searchInput = await driver.page.waitForSelector('#search_form input[type="text"]') @@ -815,6 +775,9 @@ describe('GitHub', () => { '[data-testid="search-on-sourcegraph"]', { timeout: 3000 } ) + + assert(linkToSourcegraph, 'Expected link to Sourcegraph search page exists') + let hasRedirectedToSourcegraphSearch = false testContext.server.get(sourcegraphSearchPage).intercept(request => { if (['type:repo', query].every(value => request.query.q?.includes(value))) { @@ -830,15 +793,14 @@ describe('GitHub', () => { hasRedirectedToSourcegraphSearch, 'Expected to be redirected to Sourcegraph search page with type "repo" and search query' ) - } + }) }) - }) + } // global and repository search pages describe('Search results page', () => { beforeEach(() => { mockUrls([ - 'https://github.githubassets.com/favicons/*path', 'https://github.com/_graphql/GetSuggestedNavigationDestinations', 'https://github.com/**/commits/checks-statuses-rollups', 'https://github.com/commits/badges', @@ -856,16 +818,8 @@ describe('GitHub', () => { const repoSearchPage = `https://github.com/${repo}/search` const pages = [ - { - url: globalSearchPage, - htmlResultLangSelector: 'ul.filter-list li:nth-child(1) a.filter-item', - commitResultTypeSelector: 'nav.menu .menu-item:nth-child(3)', - }, - { - url: repoSearchPage, - htmlResultLangSelector: 'ul.filter-list li:nth-child(2) a.filter-item', - commitResultTypeSelector: 'nav.menu .menu-item:nth-child(2)', - }, + { name: 'Global search page', url: globalSearchPage }, + { name: 'Repo search page', url: repoSearchPage }, ] const viewportM = { width: 768, height: 1024 } @@ -873,11 +827,13 @@ describe('GitHub', () => { const viewportConfigs = [ { + name: 'M', viewport: viewportM, sourcegraphButtonSelector: '#pageSearchFormSourcegraphButton [data-testid="search-on-sourcegraph"]', searchInputSelector: ".application-main form.js-site-search-form input.form-control[name='q']", }, { + name: 'L', viewport: viewportL, searchInputSelector: "header form.js-site-search-form input.form-control[name='q']", sourcegraphButtonSelector: @@ -885,152 +841,89 @@ describe('GitHub', () => { }, ] - it('renders "Search on Sourcegraph" button', async () => { - for (const page of pages) { - const url = buildGitHubSearchResultsURL(page.url, 'hello') + for (const page of pages) { + describe(page.name, () => { + for (const viewportConfig of viewportConfigs) { + describe(`Viewport: ${viewportConfig.name}`, () => { + it('"Search on Sourcegraph" click navigates to Sourcegraph search page with proper result type, language and search query from search input', async () => { + const initialQuery = 'fix' - for (const { sourcegraphButtonSelector } of viewportConfigs) { - await driver.page.goto(url) + const url = buildGitHubSearchResultsURL(page.url, initialQuery) + const query = 'issue' - const linkToSourcegraph = await driver.page.waitForSelector(sourcegraphButtonSelector, { - timeout: 3000, + await driver.newPage() + await driver.page.goto(url) + await driver.page.setViewport(viewportConfig.viewport) + + let hasRedirectedToSourcegraphSearch = false + let lang = '' + testContext.server.get(sourcegraphSearchPage).intercept(request => { + const resultQuery = `${initialQuery} ${query}` + const parameters = ['type:commit', `lang:${lang}`, resultQuery] + + if (page.url === repoSearchPage) { + parameters.push(`repo:${repo}`) + } + + hasRedirectedToSourcegraphSearch = parameters.every(value => + request.query.q?.includes(value) + ) + }) + + // filter results by language (handled by client-side routing) + const langLinkHandle = await driver.page.$( + 'ul.filter-list li:first-child a.filter-item' + ) + assert(langLinkHandle, 'Expected language result type link to exist') + lang = await langLinkHandle.evaluate(node => { + if (!(node instanceof HTMLAnchorElement) || !node.href) { + return '' + } + + return new URL(node.href).searchParams.get('l') || '' + }) + await langLinkHandle.click() + await driver.page.waitForTimeout(3000) + + // filter results by type (handled by client-side routing) + const commitsLinkHandle = await driver.page.$( + "nav.menu a.menu-item[href*='type=commits']" + ) + assert(commitsLinkHandle, 'Expected commits result type link to exist') + await commitsLinkHandle.click() + await driver.page.waitForTimeout(3000) + + const searchInput = await driver.page.waitForSelector( + viewportConfig.searchInputSelector + ) + // For some reason puppeteer when typing into input field prepends the exising value. + // To replicate the natural behavior we navigate to the end of exisiting value and then start typing. + await searchInput?.focus() + for (const _char of initialQuery) { + await driver.page.keyboard.press('ArrowRight') + } + await searchInput?.type(` ${query}`, { delay: 100 }) + await driver.page.keyboard.press('Escape') // if input focus opened dropdown, ensure the latter is closed + + const linkToSourcegraph = await driver.page.waitForSelector( + viewportConfig.sourcegraphButtonSelector, + { + timeout: 3000, + } + ) + assert(linkToSourcegraph, 'Expected link to Sourcegraph search page exists') + await linkToSourcegraph?.click() + await driver.page.waitForTimeout(3000) + + assert( + hasRedirectedToSourcegraphSearch, + 'Expected to be redirected to Sourcegraph search page with type "commit", language "HTML" and search query' + ) + }) }) - - assert(linkToSourcegraph, 'Expected link to Sourcegraph search page exists') } - } - }) - - it('"Search on Sourcegraph" click navigates to Sourcegraph search page with proper type and query', async () => { - const searchTerm = 'hello' - - for (const page of pages) { - const url = buildGitHubSearchResultsURL(page.url, searchTerm) - - for (const { viewport, sourcegraphButtonSelector } of viewportConfigs) { - await driver.newPage() - await driver.page.goto(url) - await driver.page.setViewport(viewport) - - const linkToSourcegraph = await driver.page.waitForSelector(sourcegraphButtonSelector, { - timeout: 3000, - }) - - let hasRedirectedToSourcegraphSearch = false - testContext.server.get(sourcegraphSearchPage).intercept(request => { - if (page.url === globalSearchPage) { - hasRedirectedToSourcegraphSearch = ['type:repo', searchTerm].every(value => - request.query.q?.includes(value) - ) - } else if (page.url === repoSearchPage) { - hasRedirectedToSourcegraphSearch = [`repo:${repo}`, searchTerm].every(value => - request.query.q?.includes(value) - ) - } - }) - - await linkToSourcegraph?.click() - await driver.page.waitForTimeout(3000) - - assert( - hasRedirectedToSourcegraphSearch, - 'Expected to be redirected to Sourcegraph search page with proper result type and query' - ) - } - } - }) - - it('"Search on Sourcegraph" click navigates to Sourcegraph search page with proper type and search query from search input', async () => { - const initialQuery = 'hello' - - for (const page of pages) { - const url = buildGitHubSearchResultsURL(page.url, initialQuery) - const query = 'world' - - for (const { viewport, sourcegraphButtonSelector, searchInputSelector } of viewportConfigs) { - await driver.newPage() - await driver.page.goto(url.toString()) - await driver.page.setViewport(viewport) - - const searchInput = await driver.page.waitForSelector(searchInputSelector) - const linkToSourcegraph = await driver.page.waitForSelector(sourcegraphButtonSelector, { - timeout: 3000, - }) - let hasRedirectedToSourcegraphSearch = false - testContext.server.get(sourcegraphSearchPage).intercept(request => { - const resultQuery = `${initialQuery} ${query}` - - if (page.url === globalSearchPage) { - hasRedirectedToSourcegraphSearch = ['type:repo', resultQuery].every(value => - request.query.q?.includes(value) - ) - } else if (page.url === repoSearchPage) { - hasRedirectedToSourcegraphSearch = [`repo:${repo}`, resultQuery].every(value => - request.query.q?.includes(value) - ) - } - }) - - // For some reason puppeteer when typing into input field prepends the exising value. - // To replicate the natural behavior we navigate to the end of exisiting value and then start typing. - await searchInput?.focus() - for (const _char of initialQuery) { - await driver.page.keyboard.press('ArrowRight') - } - await searchInput?.type(` ${query}`, { delay: 100 }) - await driver.page.keyboard.press('Escape') // if input focus opened dropdown, ensure the latter is closed - - await linkToSourcegraph?.click() - await driver.page.waitForTimeout(1000) - - assert( - hasRedirectedToSourcegraphSearch, - 'Expected to be redirected to Sourcegraph search page with type "repo" and input search query' - ) - } - } - }) - - it('"Search on Sourcegraph" click navigates to Sourcegraph search page with proper result type and language', async () => { - const searchTerm = 'hello' - - for (const page of pages) { - const url = buildGitHubSearchResultsURL(page.url, searchTerm) - - await driver.newPage() - await driver.page.goto(url) - await driver.page.setViewport(viewportL) - - let hasRedirectedToSourcegraphSearch = false - testContext.server.get(sourcegraphSearchPage).intercept(request => { - if (['type:commit', 'lang:HTML', searchTerm].every(value => request.query.q?.includes(value))) { - hasRedirectedToSourcegraphSearch = true - } - }) - - // filter results by language (handled by client-side routing) - const htmlButton = await driver.page.waitForSelector(page.htmlResultLangSelector) - await htmlButton?.click() - await driver.page.waitForTimeout(3000) - - // filter results by type (handled by client-side routing) - const commitsButton = await driver.page.waitForSelector(page.commitResultTypeSelector) - commitsButton?.click() - await driver.page.waitForTimeout(3000) - - const linkToSourcegraph = await driver.page.waitForSelector( - '#headerSearchInputSourcegraphButton [data-testid="search-on-sourcegraph"]', - { timeout: 3000 } - ) - await linkToSourcegraph?.click() - await driver.page.waitForTimeout(3000) - - assert( - hasRedirectedToSourcegraphSearch, - 'Expected to be redirected to Sourcegraph search page with type "commit", language "HTML" and search query' - ) - } - }) + }) + } }) }) }) diff --git a/client/browser/src/integration/gitlab.test.ts b/client/browser/src/integration/gitlab.test.ts index 3bd1e3391f7..55cad699b0e 100644 --- a/client/browser/src/integration/gitlab.test.ts +++ b/client/browser/src/integration/gitlab.test.ts @@ -41,6 +41,38 @@ describe('GitLab', () => { response.sendStatus(200).send(JSON.stringify({ visibility: 'public' })) }) + testContext.server + .get( + 'https://gitlab.com/sourcegraph/jsonrpc2/-/blob/4fb7cd90793ee6ab445f466b900e6bffb9b63d78/call_opt.go?format=json&viewer=simple' + ) + .intercept((request, response) => { + response.sendStatus(200).send( + JSON.stringify({ + id: 'b554baca875b70e4b2c2fc03225e6b3de4fd0a70', + last_commit_sha: '4fb7cd90793ee6ab445f466b900e6bffb9b63d78', + path: 'call_opt.go', + name: 'call_opt.go', + extension: 'go', + size: 883, + mime_type: 'text/plain', + binary: false, + simple_viewer: 'text', + rich_viewer: null, + show_viewer_switcher: false, + render_error: null, + raw_path: '/sourcegraph/jsonrpc2/-/raw/4fb7cd90793ee6ab445f466b900e6bffb9b63d78/call_opt.go', + blame_path: + '/sourcegraph/jsonrpc2/-/blame/4fb7cd90793ee6ab445f466b900e6bffb9b63d78/call_opt.go', + commits_path: + '/sourcegraph/jsonrpc2/-/commits/4fb7cd90793ee6ab445f466b900e6bffb9b63d78/call_opt.go', + tree_path: '/sourcegraph/jsonrpc2/-/tree/4fb7cd90793ee6ab445f466b900e6bffb9b63d78/', + permalink: '/sourcegraph/jsonrpc2/-/blob/4fb7cd90793ee6ab445f466b900e6bffb9b63d78/call_opt.go', + html: + '\u003Cdiv class="blob-viewer" data-path="call_opt.go" data-type="simple"\u003E\n\u003Cdiv class="file-content code js-syntax-highlight" id="blob-content"\u003E\n\u003Cdiv class="line-numbers"\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="1" href="#L1" id="L1"\u003E\n1\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="2" href="#L2" id="L2"\u003E\n2\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="3" href="#L3" id="L3"\u003E\n3\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="4" href="#L4" id="L4"\u003E\n4\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="5" href="#L5" id="L5"\u003E\n5\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="6" href="#L6" id="L6"\u003E\n6\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="7" href="#L7" id="L7"\u003E\n7\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="8" href="#L8" id="L8"\u003E\n8\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="9" href="#L9" id="L9"\u003E\n9\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="10" href="#L10" id="L10"\u003E\n10\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="11" href="#L11" id="L11"\u003E\n11\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="12" href="#L12" id="L12"\u003E\n12\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="13" href="#L13" id="L13"\u003E\n13\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="14" href="#L14" id="L14"\u003E\n14\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="15" href="#L15" id="L15"\u003E\n15\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="16" href="#L16" id="L16"\u003E\n16\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="17" href="#L17" id="L17"\u003E\n17\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="18" href="#L18" id="L18"\u003E\n18\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="19" href="#L19" id="L19"\u003E\n19\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="20" href="#L20" id="L20"\u003E\n20\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="21" href="#L21" id="L21"\u003E\n21\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="22" href="#L22" id="L22"\u003E\n22\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="23" href="#L23" id="L23"\u003E\n23\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="24" href="#L24" id="L24"\u003E\n24\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="25" href="#L25" id="L25"\u003E\n25\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="26" href="#L26" id="L26"\u003E\n26\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="27" href="#L27" id="L27"\u003E\n27\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="28" href="#L28" id="L28"\u003E\n28\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="29" href="#L29" id="L29"\u003E\n29\n\u003C/a\u003E\n\u003Ca class="file-line-num diff-line-num" data-line-number="30" href="#L30" id="L30"\u003E\n30\n\u003C/a\u003E\n\u003C/div\u003E\n\u003Cdiv class="blob-content" data-blob-id="b554baca875b70e4b2c2fc03225e6b3de4fd0a70" data-path="call_opt.go" data-qa-selector="file_content"\u003E\n\u003Cpre class="code highlight"\u003E\u003Ccode\u003E\u003Cspan id="LC1" class="line" lang="go"\u003E\u003Cspan class="k"\u003Epackage\u003C/span\u003E \u003Cspan class="n"\u003Ejsonrpc2\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC2" class="line" lang="go"\u003E\u003C/span\u003E\n\u003Cspan id="LC3" class="line" lang="go"\u003E\u003Cspan class="c"\u003E// CallOption is an option that can be provided to (*Conn).Call to\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC4" class="line" lang="go"\u003E\u003Cspan class="c"\u003E// configure custom behavior. See Meta.\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC5" class="line" lang="go"\u003E\u003Cspan class="k"\u003Etype\u003C/span\u003E \u003Cspan class="n"\u003ECallOption\u003C/span\u003E \u003Cspan class="k"\u003Einterface\u003C/span\u003E \u003Cspan class="p"\u003E{\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC6" class="line" lang="go"\u003E\t\u003Cspan class="n"\u003Eapply\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Er\u003C/span\u003E \u003Cspan class="o"\u003E*\u003C/span\u003E\u003Cspan class="n"\u003ERequest\u003C/span\u003E\u003Cspan class="p"\u003E)\u003C/span\u003E \u003Cspan class="kt"\u003Eerror\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC7" class="line" lang="go"\u003E\u003Cspan class="p"\u003E}\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC8" class="line" lang="go"\u003E\u003C/span\u003E\n\u003Cspan id="LC9" class="line" lang="go"\u003E\u003Cspan class="k"\u003Etype\u003C/span\u003E \u003Cspan class="n"\u003EcallOptionFunc\u003C/span\u003E \u003Cspan class="k"\u003Efunc\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Er\u003C/span\u003E \u003Cspan class="o"\u003E*\u003C/span\u003E\u003Cspan class="n"\u003ERequest\u003C/span\u003E\u003Cspan class="p"\u003E)\u003C/span\u003E \u003Cspan class="kt"\u003Eerror\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC10" class="line" lang="go"\u003E\u003C/span\u003E\n\u003Cspan id="LC11" class="line" lang="go"\u003E\u003Cspan class="k"\u003Efunc\u003C/span\u003E \u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Ec\u003C/span\u003E \u003Cspan class="n"\u003EcallOptionFunc\u003C/span\u003E\u003Cspan class="p"\u003E)\u003C/span\u003E \u003Cspan class="n"\u003Eapply\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Er\u003C/span\u003E \u003Cspan class="o"\u003E*\u003C/span\u003E\u003Cspan class="n"\u003ERequest\u003C/span\u003E\u003Cspan class="p"\u003E)\u003C/span\u003E \u003Cspan class="kt"\u003Eerror\u003C/span\u003E \u003Cspan class="p"\u003E{\u003C/span\u003E \u003Cspan class="k"\u003Ereturn\u003C/span\u003E \u003Cspan class="n"\u003Ec\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Er\u003C/span\u003E\u003Cspan class="p"\u003E)\u003C/span\u003E \u003Cspan class="p"\u003E}\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC12" class="line" lang="go"\u003E\u003C/span\u003E\n\u003Cspan id="LC13" class="line" lang="go"\u003E\u003Cspan class="c"\u003E// Meta returns a call option which attaches the given meta object to\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC14" class="line" lang="go"\u003E\u003Cspan class="c"\u003E// the JSON-RPC 2.0 request (this is a Sourcegraph extension to JSON\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC15" class="line" lang="go"\u003E\u003Cspan class="c"\u003E// RPC 2.0 for carrying metadata).\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC16" class="line" lang="go"\u003E\u003Cspan class="k"\u003Efunc\u003C/span\u003E \u003Cspan class="n"\u003EMeta\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Emeta\u003C/span\u003E \u003Cspan class="k"\u003Einterface\u003C/span\u003E\u003Cspan class="p"\u003E{})\u003C/span\u003E \u003Cspan class="n"\u003ECallOption\u003C/span\u003E \u003Cspan class="p"\u003E{\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC17" class="line" lang="go"\u003E\t\u003Cspan class="k"\u003Ereturn\u003C/span\u003E \u003Cspan class="n"\u003EcallOptionFunc\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="k"\u003Efunc\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Er\u003C/span\u003E \u003Cspan class="o"\u003E*\u003C/span\u003E\u003Cspan class="n"\u003ERequest\u003C/span\u003E\u003Cspan class="p"\u003E)\u003C/span\u003E \u003Cspan class="kt"\u003Eerror\u003C/span\u003E \u003Cspan class="p"\u003E{\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC18" class="line" lang="go"\u003E\t\t\u003Cspan class="k"\u003Ereturn\u003C/span\u003E \u003Cspan class="n"\u003Er\u003C/span\u003E\u003Cspan class="o"\u003E.\u003C/span\u003E\u003Cspan class="n"\u003ESetMeta\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Emeta\u003C/span\u003E\u003Cspan class="p"\u003E)\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC19" class="line" lang="go"\u003E\t\u003Cspan class="p"\u003E})\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC20" class="line" lang="go"\u003E\u003Cspan class="p"\u003E}\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC21" class="line" lang="go"\u003E\u003C/span\u003E\n\u003Cspan id="LC22" class="line" lang="go"\u003E\u003Cspan class="c"\u003E// PickID returns a call option which sets the ID on a request. Care must be\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC23" class="line" lang="go"\u003E\u003Cspan class="c"\u003E// taken to ensure there are no conflicts with any previously picked ID, nor\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC24" class="line" lang="go"\u003E\u003Cspan class="c"\u003E// with the default sequence ID.\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC25" class="line" lang="go"\u003E\u003Cspan class="k"\u003Efunc\u003C/span\u003E \u003Cspan class="n"\u003EPickID\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Eid\u003C/span\u003E \u003Cspan class="n"\u003EID\u003C/span\u003E\u003Cspan class="p"\u003E)\u003C/span\u003E \u003Cspan class="n"\u003ECallOption\u003C/span\u003E \u003Cspan class="p"\u003E{\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC26" class="line" lang="go"\u003E\t\u003Cspan class="k"\u003Ereturn\u003C/span\u003E \u003Cspan class="n"\u003EcallOptionFunc\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="k"\u003Efunc\u003C/span\u003E\u003Cspan class="p"\u003E(\u003C/span\u003E\u003Cspan class="n"\u003Er\u003C/span\u003E \u003Cspan class="o"\u003E*\u003C/span\u003E\u003Cspan class="n"\u003ERequest\u003C/span\u003E\u003Cspan class="p"\u003E)\u003C/span\u003E \u003Cspan class="kt"\u003Eerror\u003C/span\u003E \u003Cspan class="p"\u003E{\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC27" class="line" lang="go"\u003E\t\t\u003Cspan class="n"\u003Er\u003C/span\u003E\u003Cspan class="o"\u003E.\u003C/span\u003E\u003Cspan class="n"\u003EID\u003C/span\u003E \u003Cspan class="o"\u003E=\u003C/span\u003E \u003Cspan class="n"\u003Eid\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC28" class="line" lang="go"\u003E\t\t\u003Cspan class="k"\u003Ereturn\u003C/span\u003E \u003Cspan class="no"\u003Enil\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC29" class="line" lang="go"\u003E\t\u003Cspan class="p"\u003E})\u003C/span\u003E\u003C/span\u003E\n\u003Cspan id="LC30" class="line" lang="go"\u003E\u003Cspan class="p"\u003E}\u003C/span\u003E\u003C/span\u003E\u003C/code\u003E\u003C/pre\u003E\n\u003C/div\u003E\n\u003C/div\u003E\n\n\n\u003C/div\u003E\n', + }) + ) + }) + testContext.overrideGraphQL({ ViewerConfiguration: () => ({ viewerConfiguration: { diff --git a/doc/dev/background-information/ci/reference.md b/doc/dev/background-information/ci/reference.md index 0ac523a55db..3a268caeed4 100644 --- a/doc/dev/background-information/ci/reference.md +++ b/doc/dev/background-information/ci/reference.md @@ -23,12 +23,12 @@ The default run type. - **Pipeline setup**: Trigger async - Client PR preview - **Linters and static analysis**: Prettier, Misc linters, Yarn deduplicate lint - - **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), ESLint, Build TS, Stylelint + - **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Puppeteer tests for chrome extension, Test (client/browser), ESLint, Build TS, Stylelint - Upload build trace - Pipeline for `GraphQL` changes: - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint - - **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), ESLint, Build TS, Stylelint + - **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Puppeteer tests for chrome extension, Test (client/browser), ESLint, Build TS, Stylelint - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - Upload build trace @@ -81,6 +81,7 @@ Base pipeline (more steps might be included based on branch changes): - ESLint - Build TS - Stylelint +- Puppeteer tests for chrome extension - Test (client/browser) - Test (all) - E2E for chrome extension @@ -96,7 +97,7 @@ Base pipeline (more steps might be included based on branch changes): - **Image builds**: Build alpine-3.12, Build alpine-3.14, Build cadvisor, Build codeinsights-db, Build codeintel-db, Build frontend, Build github-proxy, Build gitserver, Build grafana, Build indexed-searcher, Build jaeger-agent, Build jaeger-all-in-one, Build minio, Build postgres-12-alpine, Build postgres_exporter, Build precise-code-intel-worker, Build prometheus, Build redis-cache, Build redis-store, Build redis_exporter, Build repo-updater, Build search-indexer, Build searcher, Build symbols, Build syntax-highlighter, Build worker, Build migrator, Build server, Build sg - **Image security scans**: Scan alpine-3.12, Scan alpine-3.14, Scan cadvisor, Scan codeinsights-db, Scan codeintel-db, Scan frontend, Scan github-proxy, Scan gitserver, Scan grafana, Scan indexed-searcher, Scan jaeger-agent, Scan jaeger-all-in-one, Scan minio, Scan postgres-12-alpine, Scan postgres_exporter, Scan precise-code-intel-worker, Scan prometheus, Scan redis-cache, Scan redis-store, Scan redis_exporter, Scan repo-updater, Scan search-indexer, Scan searcher, Scan symbols, Scan syntax-highlighter, Scan worker, Scan migrator, Scan server, Scan sg - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint, SVG lint, Yarn deduplicate lint, Docker linters, Check and build docsite -- **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), ESLint, Build TS, Stylelint +- **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Puppeteer tests for chrome extension, Test (client/browser), ESLint, Build TS, Stylelint - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - **DB backcompat tests**: Backcompat test (all), Backcompat test (enterprise/internal/codeintel/stores/dbstore), Backcompat test (enterprise/internal/codeintel/stores/lsifstore), Backcompat test (enterprise/internal/insights), Backcompat test (internal/database), Backcompat test (internal/repos), Backcompat test (enterprise/internal/batches), Backcompat test (cmd/frontend), Backcompat test (enterprise/internal/database), Backcompat test (enterprise/cmd/frontend/internal/batches/resolvers) - **CI script tests**: test-trace-command.sh @@ -115,7 +116,7 @@ Base pipeline (more steps might be included based on branch changes): - **Image builds**: Build alpine-3.12, Build alpine-3.14, Build cadvisor, Build codeinsights-db, Build codeintel-db, Build frontend, Build github-proxy, Build gitserver, Build grafana, Build indexed-searcher, Build jaeger-agent, Build jaeger-all-in-one, Build minio, Build postgres-12-alpine, Build postgres_exporter, Build precise-code-intel-worker, Build prometheus, Build redis-cache, Build redis-store, Build redis_exporter, Build repo-updater, Build search-indexer, Build searcher, Build symbols, Build syntax-highlighter, Build worker, Build migrator, Build server, Build sg, Build executor image, Build docker registry mirror image - **Image security scans**: Scan alpine-3.12, Scan alpine-3.14, Scan cadvisor, Scan codeinsights-db, Scan codeintel-db, Scan frontend, Scan github-proxy, Scan gitserver, Scan grafana, Scan indexed-searcher, Scan jaeger-agent, Scan jaeger-all-in-one, Scan minio, Scan postgres-12-alpine, Scan postgres_exporter, Scan precise-code-intel-worker, Scan prometheus, Scan redis-cache, Scan redis-store, Scan redis_exporter, Scan repo-updater, Scan search-indexer, Scan searcher, Scan symbols, Scan syntax-highlighter, Scan worker, Scan migrator, Scan server, Scan sg - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint, SVG lint, Yarn deduplicate lint, Docker linters, Check and build docsite -- **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), ESLint, Build TS, Stylelint +- **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Puppeteer tests for chrome extension, Test (client/browser), ESLint, Build TS, Stylelint - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - **DB backcompat tests**: Backcompat test (all), Backcompat test (enterprise/internal/codeintel/stores/dbstore), Backcompat test (enterprise/internal/codeintel/stores/lsifstore), Backcompat test (enterprise/internal/insights), Backcompat test (internal/database), Backcompat test (internal/repos), Backcompat test (enterprise/internal/batches), Backcompat test (cmd/frontend), Backcompat test (enterprise/internal/database), Backcompat test (enterprise/cmd/frontend/internal/batches/resolvers) - **CI script tests**: test-trace-command.sh @@ -133,6 +134,7 @@ Base pipeline (more steps might be included based on branch changes): - ESLint - Build TS - Stylelint +- Puppeteer tests for chrome extension - Test (client/browser) - Test (all) - E2E for chrome extension @@ -151,7 +153,7 @@ Base pipeline (more steps might be included based on branch changes): - **Image builds**: Build alpine-3.12, Build alpine-3.14, Build cadvisor, Build codeinsights-db, Build codeintel-db, Build frontend, Build github-proxy, Build gitserver, Build grafana, Build indexed-searcher, Build jaeger-agent, Build jaeger-all-in-one, Build minio, Build postgres-12-alpine, Build postgres_exporter, Build precise-code-intel-worker, Build prometheus, Build redis-cache, Build redis-store, Build redis_exporter, Build repo-updater, Build search-indexer, Build searcher, Build symbols, Build syntax-highlighter, Build worker, Build migrator, Build server, Build sg, Build executor image - **Image security scans**: Scan alpine-3.12, Scan alpine-3.14, Scan cadvisor, Scan codeinsights-db, Scan codeintel-db, Scan frontend, Scan github-proxy, Scan gitserver, Scan grafana, Scan indexed-searcher, Scan jaeger-agent, Scan jaeger-all-in-one, Scan minio, Scan postgres-12-alpine, Scan postgres_exporter, Scan precise-code-intel-worker, Scan prometheus, Scan redis-cache, Scan redis-store, Scan redis_exporter, Scan repo-updater, Scan search-indexer, Scan searcher, Scan symbols, Scan syntax-highlighter, Scan worker, Scan migrator, Scan server, Scan sg - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint, SVG lint, Yarn deduplicate lint, Docker linters, Check and build docsite -- **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), ESLint, Build TS, Stylelint +- **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Puppeteer tests for chrome extension, Test (client/browser), ESLint, Build TS, Stylelint - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - **DB backcompat tests**: Backcompat test (all), Backcompat test (enterprise/internal/codeintel/stores/dbstore), Backcompat test (enterprise/internal/codeintel/stores/lsifstore), Backcompat test (enterprise/internal/insights), Backcompat test (internal/database), Backcompat test (internal/repos), Backcompat test (enterprise/internal/batches), Backcompat test (cmd/frontend), Backcompat test (enterprise/internal/database), Backcompat test (enterprise/cmd/frontend/internal/batches/resolvers) - **CI script tests**: test-trace-command.sh @@ -175,7 +177,7 @@ Base pipeline (more steps might be included based on branch changes): - **Image builds**: Build alpine-3.12, Build alpine-3.14, Build cadvisor, Build codeinsights-db, Build codeintel-db, Build frontend, Build github-proxy, Build gitserver, Build grafana, Build indexed-searcher, Build jaeger-agent, Build jaeger-all-in-one, Build minio, Build postgres-12-alpine, Build postgres_exporter, Build precise-code-intel-worker, Build prometheus, Build redis-cache, Build redis-store, Build redis_exporter, Build repo-updater, Build search-indexer, Build searcher, Build symbols, Build syntax-highlighter, Build worker, Build migrator, Build server, Build sg, Build executor image - **Image security scans**: Scan alpine-3.12, Scan alpine-3.14, Scan cadvisor, Scan codeinsights-db, Scan codeintel-db, Scan frontend, Scan github-proxy, Scan gitserver, Scan grafana, Scan indexed-searcher, Scan jaeger-agent, Scan jaeger-all-in-one, Scan minio, Scan postgres-12-alpine, Scan postgres_exporter, Scan precise-code-intel-worker, Scan prometheus, Scan redis-cache, Scan redis-store, Scan redis_exporter, Scan repo-updater, Scan search-indexer, Scan searcher, Scan symbols, Scan syntax-highlighter, Scan worker, Scan migrator, Scan server, Scan sg - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint, SVG lint, Yarn deduplicate lint, Docker linters, Check and build docsite -- **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), ESLint, Build TS, Stylelint +- **Client checks**: Puppeteer tests prep, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Puppeteer tests for chrome extension, Test (client/browser), ESLint, Build TS, Stylelint - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - **DB backcompat tests**: Backcompat test (all), Backcompat test (enterprise/internal/codeintel/stores/dbstore), Backcompat test (enterprise/internal/codeintel/stores/lsifstore), Backcompat test (enterprise/internal/insights), Backcompat test (internal/database), Backcompat test (internal/repos), Backcompat test (enterprise/internal/batches), Backcompat test (cmd/frontend), Backcompat test (enterprise/internal/database), Backcompat test (enterprise/cmd/frontend/internal/batches/resolvers) - **CI script tests**: test-trace-command.sh diff --git a/enterprise/dev/ci/internal/ci/operations.go b/enterprise/dev/ci/internal/ci/operations.go index 5099f38690f..f93ec736f02 100644 --- a/enterprise/dev/ci/internal/ci/operations.go +++ b/enterprise/dev/ci/internal/ci/operations.go @@ -212,26 +212,24 @@ func addWebApp(pipeline *bk.Pipeline) { // Builds and tests the browser extension. func addBrowserExt(pipeline *bk.Pipeline) { - // Broken: https://github.com/sourcegraph/sourcegraph/issues/33484 // Browser extension integration tests - // for _, browser := range []string{"chrome"} { - // pipeline.AddStep( - // fmt.Sprintf(":%s: Puppeteer tests for %s extension", browser, browser), - // withYarnCache(), - // bk.Env("EXTENSION_PERMISSIONS_ALL_URLS", "true"), - // bk.Env("BROWSER", browser), - // bk.Env("LOG_BROWSER_CONSOLE", "true"), - // bk.Env("SOURCEGRAPH_BASE_URL", "https://sourcegraph.com"), - // bk.Env("POLLYJS_MODE", "replay"), // ensure that we use existing recordings - // bk.Cmd("git-lfs fetch"), - // bk.Cmd("yarn --frozen-lockfile --network-timeout 60000"), - // bk.Cmd("yarn workspace @sourcegraph/browser -s run build"), - // bk.Cmd("yarn run cover-browser-integration"), - // bk.Cmd("yarn nyc report -r json"), - // bk.Cmd("dev/ci/codecov.sh -c -F typescript -F integration"), - // bk.ArtifactPaths("./puppeteer/*.png"), - // ) - // } + for _, browser := range []string{"chrome"} { + pipeline.AddStep( + fmt.Sprintf(":%s: Puppeteer tests for %s extension", browser, browser), + withYarnCache(), + bk.Env("EXTENSION_PERMISSIONS_ALL_URLS", "true"), + bk.Env("BROWSER", browser), + bk.Env("LOG_BROWSER_CONSOLE", "true"), + bk.Env("SOURCEGRAPH_BASE_URL", "https://sourcegraph.com"), + bk.Env("POLLYJS_MODE", "replay"), // ensure that we use existing recordings + bk.Cmd("yarn --frozen-lockfile --network-timeout 60000"), + bk.Cmd("yarn workspace @sourcegraph/browser -s run build"), + bk.Cmd("yarn run cover-browser-integration"), + bk.Cmd("yarn nyc report -r json"), + bk.Cmd("dev/ci/codecov.sh -c -F typescript -F integration"), + bk.ArtifactPaths("./puppeteer/*.png"), + ) + } // Browser extension unit tests pipeline.AddStep(":jest::chrome: Test (client/browser)", diff --git a/sg.config.yaml b/sg.config.yaml index 0d98c547c52..40643677f09 100644 --- a/sg.config.yaml +++ b/sg.config.yaml @@ -950,7 +950,7 @@ tests: cmd: EXTENSION_PERMISSIONS_ALL_URLS=true yarn workspace @sourcegraph/browser build bext-integration: - cmd: POLLYJS_MODE=replay yarn workspace @sourcegraph/browser test-integration + cmd: yarn workspace @sourcegraph/browser test-integration bext-e2e: cmd: yarn workspace @sourcegraph/browser mocha ./src/end-to-end/github.test.ts ./src/end-to-end/gitlab.test.ts