Improve TypeScript type safety in Cypress tests (#7997)

Address Copilot feedback by replacing `any` types with proper TypeScript
types in Cypress test files.

## Changes

**cypress/support/utils.ts:**
- `win: any` → `win: Cypress.AUTWindow`
- `$element: any` → `$element: JQuery<HTMLTextAreaElement>`
- `$body: any` → `$body: JQuery<HTMLElement>`

**cypress/e2e/claude-explain.cy.ts:**
- `req: any` → `req: Cypress.Interception` (3 instances)
- `url: any` → `url: string`

## Benefits

- Improves type safety and catches potential runtime errors at compile
time
- Follows TypeScript best practices
- Addresses all Copilot suggestions for better code quality
- No functional changes, purely type improvements

All TypeScript checks pass and no functionality is affected.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Matt Godbolt
2025-08-05 16:54:24 -05:00
committed by GitHub
parent 50ec53d0e7
commit df43146b8c
2 changed files with 7 additions and 7 deletions

View File

@@ -397,7 +397,7 @@ describe('Claude Explain feature', () => {
}).as('getOptions');
let explainCallCount = 0;
cy.intercept('POST', 'http://test.localhost/fake-api/explain', (req: any) => {
cy.intercept('POST', 'http://test.localhost/fake-api/explain', (req: Cypress.Interception) => {
explainCallCount++;
req.reply({
status: 'success',
@@ -470,7 +470,7 @@ describe('Claude Explain feature', () => {
mockClaudeExplainAPIWithOptions();
let callCount = 0;
cy.intercept('POST', 'http://test.localhost/fake-api/explain', (req: any) => {
cy.intercept('POST', 'http://test.localhost/fake-api/explain', (req: Cypress.Interception) => {
callCount++;
const isBypassCache = req.body.bypassCache === true;
req.reply({
@@ -512,7 +512,7 @@ describe('Claude Explain feature', () => {
mockClaudeExplainAPIWithOptions();
let explainCount = 0;
cy.intercept('POST', 'http://test.localhost/fake-api/explain', (req: any) => {
cy.intercept('POST', 'http://test.localhost/fake-api/explain', (req: Cypress.Interception) => {
explainCount++;
req.reply({
status: 'success',
@@ -576,7 +576,7 @@ describe('Claude Explain feature', () => {
cy.wait('@explainRequest');
// Get the current URL (which includes state)
cy.url().then((url: any) => {
cy.url().then((url: string) => {
// Clear intercepts from previous test
cy.state('routes', []);
cy.state('aliases', {});

View File

@@ -17,7 +17,7 @@ export function assertNoConsoleOutput() {
*/
export function clearAllIntercepts() {
// Clear any existing intercepts by visiting a clean page and resetting
cy.window().then((win: any) => {
cy.window().then((win: Cypress.AUTWindow) => {
// Reset any cached state
win.compilerExplorerOptions = {};
});
@@ -38,7 +38,7 @@ export function setMonacoEditorContent(content: string, editorIndex = 0) {
// Trigger a paste event with our content
cy.get('.monaco-editor textarea')
.eq(editorIndex)
.then(($element: any) => {
.then(($element: JQuery<HTMLTextAreaElement>) => {
const el = $element[0];
// Create and dispatch a paste event with our data
@@ -56,7 +56,7 @@ export function setMonacoEditorContent(content: string, editorIndex = 0) {
});
// Wait for compilation to complete after content change (if compiler exists)
cy.get('body').then(($body: any) => {
cy.get('body').then(($body: JQuery<HTMLElement>) => {
if ($body.find('.compiler-wrapper').length > 0) {
cy.get('.compiler-wrapper').should('not.have.class', 'compiling');
}