Skip to content

Fix the last 4 tests that are failing #28

@jack-mumford

Description

@jack-mumford
  1. The test should handle missing price elements in content-price.test.js is failing because the extracted price doesn't match the expected value. The test expects "Price not found" to be returned when no price element is present, but the current implementation returns something else or fails to extract any value.

Related Test

test('should handle missing price elements', () => {
  document.body.innerHTML = '<div>No price here</div>';
  require('../content-price.js');
  expect(chrome.runtime.sendMessage).toHaveBeenCalledWith(
    expect.objectContaining({
      data: expect.objectContaining({
        price: 'Price not found',
        // other expected values...
      })
    }),
    expect.any(Function)
  );
});

2. ## Problem
The test for extracting product titles is failing. The implementation isn't reliably extracting the expected title from the page.

## Failing Test
Test: `should extract product title when available` in [content-price.test.js]

## Error Details
The test expects the title to be extracted correctly when present in a `<title>` tag, but the expectation is failing.

## Root Cause
The title extraction logic in `extractProductData()` may not be correctly prioritizing title sources or handling document.title correctly in the JSDOM environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions