Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion content/copilot/concepts/about-copilot-coding-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ Users can include hidden messages in issues assigned to {% data variables.produc
* **{% data variables.product.prodname_copilot_short %} doesn't account for content exclusions**. Content exclusions allow administrators to configure {% data variables.product.prodname_copilot_short %} to ignore certain files. When using {% data variables.copilot.copilot_coding_agent %}, {% data variables.product.prodname_copilot_short %} will not ignore these files, and will be able to see and update them. See [AUTOTITLE](/copilot/managing-copilot/configuring-and-auditing-content-exclusion/excluding-content-from-github-copilot).
* **{% data variables.copilot.copilot_coding_agent %} is not available in {% data variables.enterprise.data_residency %}**. The agent is only available in {% data variables.product.prodname_dotcom_the_website %}.

## Hands-on practice

Try the [Expand your team with {% data variables.copilot.copilot_coding_agent %}](https://github.com/skills/expand-your-team-with-copilot/) Skills exercise for practical experience with {% data variables.copilot.copilot_coding_agent %}.

## Further reading

* **Hands-on practice**: Try the [Expand your team with {% data variables.copilot.copilot_coding_agent %}](https://github.com/skills/expand-your-team-with-copilot/) Skills course for practical experience with {% data variables.copilot.copilot_coding_agent %}.
* [AUTOTITLE](/copilot/using-github-copilot/coding-agent) how-to articles
* [AUTOTITLE](/copilot/responsible-use-of-github-copilot-features/responsible-use-of-copilot-coding-agent-on-githubcom)
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ In this example, we looked at an account management system written in COBOL and
* **Review the code before using it**: Make sure you understand the code that {% data variables.product.prodname_copilot_short %} provides before using it in your application. This will help you catch any potential issues and ensure that the code meets your requirements.
* **Validate your changes**: After making changes to the code, it's important to validate that the application still works as expected. You can use the test plan generated by {% data variables.product.prodname_copilot_short %} to create unit and integration tests for the application.

## Hands-on practice

Try the [Modernizing your legacy code with {% data variables.product.prodname_copilot %}](https://github.com/skills/modernize-your-legacy-code-with-github-copilot) Skills exercise for practical experience updating a legacy codebase with {% data variables.product.prodname_copilot %}.

## Further reading

* [AUTOTITLE](/copilot/copilot-chat-cookbook/documenting-code/documenting-legacy-code)
Expand Down
2 changes: 1 addition & 1 deletion src/archives/tests/deprecated-enterprise-versions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test, vi } from 'vitest'

import enterpriseServerReleases from '@/versions/lib/enterprise-server-releases'
import { get, getDOM } from '@/tests/helpers/e2etest-ts'
import { get, getDOM } from '@/tests/helpers/e2etest'
import { SURROGATE_ENUMS } from '@/frame/middleware/set-fastly-surrogate-key'

describe('enterprise deprecation', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/tests/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('render Markdown image tags', () => {
// When transformed as a source in a `<picture>` tag, it's automatically
// injected with the `mw-XXXXX` virtual indicator in the URL that
// resizes it on-the-fly.
const image = sharp(res.body as Buffer)
const image = sharp(Buffer.from(res.body as ArrayBuffer))
const { width, height } = await image.metadata()
expect(width).toBe(MAX_WIDTH)
// The `_fixtures/screenshot.png` is 2000x1494.
Expand Down
2 changes: 1 addition & 1 deletion src/search/tests/api-ai-search-autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { expect, test, vi } from 'vitest'

import { describeIfElasticsearchURL } from '@/tests/helpers/conditional-runs'
import { get } from '@/tests/helpers/e2etest-ts'
import { get } from '@/tests/helpers/e2etest'

import type { AutocompleteSearchResponse } from '@/search/types'

Expand Down
2 changes: 1 addition & 1 deletion src/search/tests/api-combined-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { expect, test, vi } from 'vitest'

import { describeIfElasticsearchURL } from '@/tests/helpers/conditional-runs'
import { get } from '@/tests/helpers/e2etest-ts'
import { get } from '@/tests/helpers/e2etest'

import type { CombinedSearchResponse } from '@/search/types'

Expand Down
2 changes: 1 addition & 1 deletion src/search/tests/api-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { expect, test, vi } from 'vitest'
import { describeIfElasticsearchURL } from '@/tests/helpers/conditional-runs'
import { get } from '@/tests/helpers/e2etest-ts'
import { get } from '@/tests/helpers/e2etest'
import { GeneralSearchResponse, SearchResultAggregations, GeneralSearchHit } from '@/search/types'

if (!process.env.ELASTICSEARCH_URL) {
Expand Down
2 changes: 1 addition & 1 deletion src/search/tests/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { expect, test, vi } from 'vitest'

import { describeIfElasticsearchURL } from '@/tests/helpers/conditional-runs'
import { get, getDOM } from '@/tests/helpers/e2etest-ts'
import { get, getDOM } from '@/tests/helpers/e2etest'
import { SURROGATE_ENUMS } from '@/frame/middleware/set-fastly-surrogate-key'

if (!process.env.ELASTICSEARCH_URL) {
Expand Down
2 changes: 1 addition & 1 deletion src/search/tests/search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test, vi } from 'vitest'
import { get, getDOM } from '@/tests/helpers/e2etest-ts'
import { get, getDOM } from '@/tests/helpers/e2etest'

describe('search results page', () => {
vi.setConfig({ testTimeout: 60 * 1000 })
Expand Down
81 changes: 0 additions & 81 deletions src/tests/helpers/e2etest.js

This file was deleted.

23 changes: 14 additions & 9 deletions src/tests/helpers/e2etest-ts.ts → src/tests/helpers/e2etest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ interface ResponseWithHeaders<T> extends Response<T> {
headers: Record<string, string>
}

// Type alias for cached DOM results to improve maintainability
type CachedDOMResult = cheerio.Root & { res: Response; $: cheerio.Root }

// Cache to store DOM objects
const getDOMCache = new Map<string, cheerio.Root>()
const getDOMCache = new Map<string, CachedDOMResult>()

/**
* Makes an HTTP request using the specified method and options.
Expand Down Expand Up @@ -119,10 +122,10 @@ export function post(
export async function getDOMCached(
route: string,
options: GetDOMOptions = {},
): Promise<cheerio.Root> {
): Promise<CachedDOMResult> {
const key = `${route}::${JSON.stringify(options)}`
if (!getDOMCache.has(key)) {
const { $ } = await getDOM(route, options)
const $ = await getDOM(route, options)
getDOMCache.set(key, $)
}
// The non-null assertion is safe here because we've just set the key if it didn't exist
Expand All @@ -134,12 +137,9 @@ export async function getDOMCached(
*
* @param route - The route to request.
* @param options - Options for fetching the DOM.
* @returns A promise that resolves to the loaded DOM object.
* @returns A promise that resolves to the loaded DOM object with res attached and destructurable.
*/
export async function getDOM(
route: string,
options: GetDOMOptions = {},
): Promise<{ $: cheerio.Root; res: Response }> {
export async function getDOM(route: string, options: GetDOMOptions = {}): Promise<CachedDOMResult> {
const { headers, allow500s = false, allow404 = false, retries = 0 } = options
const res = await get(route, { followRedirects: true, headers, retries })

Expand All @@ -152,8 +152,13 @@ export async function getDOM(
}

const $ = cheerio.load(res.body || '', { xmlMode: true })
const result = $ as CachedDOMResult
// Attach res to the cheerio object for backward compatibility
result.res = res
// Attach $ to itself for destructuring compatibility
result.$ = result

return { $, res }
return result
}

/**
Expand Down
Loading