Skip to content

Conversation

@alokdangre
Copy link
Contributor

Description

Added e2e test for resource details section in object explorer

Related Issue

Fixes #<issue_number>

Changes Made

  • Updated ...
  • Refactored ...
  • Fixed ...
  • Added tests for ...

Checklist

Please ensure the following before submitting your PR:

  • I have reviewed the project's contribution guidelines.
  • I have written unit tests for the changes (if applicable).
  • I have updated the documentation (if applicable).
  • I have tested the changes locally and ensured they work as expected.
  • My code follows the project's coding standards.

Screenshots or Logs (if applicable)

Additional Notes

Copilot AI review requested due to automatic review settings November 13, 2025 16:26
@kubestellar-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kunal-511 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive end-to-end tests for the resource details section in the Object Explorer feature. The tests validate various aspects of the details panel functionality including tab navigation, YAML/JSON editing, and logs viewing.

Key Changes:

  • Added 10 test cases covering resource details panel, summary/edit/logs tabs, and YAML/JSON editing capabilities
  • Implemented helper function checkResourceDetailsAvailable() to verify feature availability
  • Applied MSW scenarios for mocking resource data in tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

})
) {
await summaryTab.click();
await page.waitForTimeout(500);
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple arbitrary timeouts throughout tests: Lines 60, 146, 182, 228, 286, 330, 357, 412, 426, 453, 512, and 525 all use page.waitForTimeout() with arbitrary durations. These introduce unnecessary delays and make tests slower. Consider replacing with event-driven waits using Playwright's built-in methods like waitForLoadState(), waitForSelector(), or element state checks.

Suggested change
await page.waitForTimeout(500);
// Wait for either resource name or namespace to be visible after clicking summary tab
await Promise.race([
page.locator('text=/name|Name/i').first().waitFor({ state: 'visible', timeout: 2000 }),
page.locator('text=/namespace|Namespace/i').first().waitFor({ state: 'visible', timeout: 2000 })
]);

Copilot uses AI. Check for mistakes.
await page.waitForTimeout(1000);

const errorIndicator = page
.locator('.error, .invalid, [class*="error"], [class*="invalid"]')
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overly broad error indicator selectors: The selector .locator('.error, .invalid, [class*="error"], [class*="invalid"]') is too generic and could match many unrelated elements. This could lead to false positives. Consider using more specific selectors or test IDs for error indicators.

Suggested change
.locator('.error, .invalid, [class*="error"], [class*="invalid"]')
.locator('[data-testid="yaml-error-indicator"]')

Copilot uses AI. Check for mistakes.
Comment on lines +237 to +246
const yamlContent =
(await yamlEditor.textContent().catch(error => {
console.error('Error getting YAML content:', error);
return '';
})) ||
(await yamlEditor.inputValue().catch(error => {
console.error('Error getting YAML input value:', error);
return '';
})) ||
'';
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complex nested logic for retrieving YAML content: This pattern of trying multiple methods to get content (textContent(), inputValue()) with fallbacks is repeated on lines 237-246, 339-348, 360-368, 435-444, 456-464. Consider extracting this into a helper function like getEditorContent(editor) to reduce duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
})) ||
'';

if (yamlContent && yamlContent.length > 10) {
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number without explanation: The value 10 is used to check if content length is sufficient, but there's no explanation why 10 characters is the threshold. Consider extracting this as a named constant like MIN_YAML_CONTENT_LENGTH with a comment explaining the rationale.

Copilot uses AI. Check for mistakes.
if (originalContent && originalContent.length > 10) {
try {
await yamlEditor.click();
await page.keyboard.press('Control+A');
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keyboard shortcut may not work cross-platform: Using Control+A (line 353, 449, 523) won't work on macOS where Meta+A (Command+A) is the standard. Consider using Playwright's cross-platform keyboard API or detecting the platform to use the appropriate modifier key.

Suggested change
await page.keyboard.press('Control+A');
// Cross-platform "Select All" shortcut
const isMac = await page.evaluate(() => navigator.platform.includes('Mac'));
await page.keyboard.press(isMac ? 'Meta+A' : 'Control+A');

Copilot uses AI. Check for mistakes.
Comment on lines +354 to +356
await page.keyboard.type(
'apiVersion: v1\nkind: Pod\nmetadata:\n name: test-pod\n namespace: default'
);
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded test data in multiple locations: YAML/JSON test content is hard-coded inline at lines 354-356, 450-452, and 524. Consider extracting these as constants at the top of the file or in a separate fixtures file for better maintainability and reusability.

Copilot uses AI. Check for mistakes.

test('should open resource details panel when clicking on resource card', async ({ page }) => {
await objectExplorerPage.changeViewMode('grid');
await page.waitForTimeout(500);
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded arbitrary timeout: Using page.waitForTimeout(500) introduces unnecessary delays and makes tests slower. Consider using Playwright's built-in waiting mechanisms like waitForLoadState() or waiting for specific elements to be ready instead of arbitrary waits.

Suggested change
await page.waitForTimeout(500);
// Wait for the first resource card to be visible after changing view mode
await page.locator('.MuiCard-root').first().waitFor({ state: 'visible' });

Copilot uses AI. Check for mistakes.
@SakshamDutt
Copy link
Contributor

@alokdangre Good work mate

@btwshivam
Copy link
Contributor

@alokdangre reduce time .. same

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

This pull request has been automatically marked as stale because it has not had recent activity.
It will be closed if no further activity occurs within 7 days.
If this PR is still relevant, please leave a comment or push new commits to keep it open.
Thank you for your contribution! 🙏

@github-actions github-actions bot added the stale label Jan 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants