Skip to content

Conversation

@bellmano
Copy link
Owner

No description provided.

@bellmano bellmano self-assigned this Sep 13, 2025
@bellmano bellmano requested a review from Copilot September 13, 2025 17:07
Copy link

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 test coverage for the main script file using Jest, along with supporting configuration for SonarQube analysis. The purpose is to improve code quality metrics and ensure the countdown timer functionality is properly tested.

  • Adds Jest test suite covering the countUpFromTime function with various scenarios including leap years, DST changes, and edge cases
  • Configures package.json with Jest setup and test scripts for coverage reporting
  • Updates CI/CD pipeline to run tests and generate coverage reports for SonarQube integration

Reviewed Changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/script.test.js Comprehensive test suite with DOM mocking and various test scenarios for the timer function
src/script.js Adds CommonJS export for Node.js compatibility in test environment
package.json Jest configuration with coverage settings and test scripts
sonar-project.properties SonarQube configuration for source paths and coverage reporting
README.md Documentation updates with test running instructions and coverage badge
.github/workflows/sonarscan.yml CI pipeline updates to run tests and generate coverage before SonarQube scan

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

bellmano and others added 3 commits September 13, 2025 19:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bellmano bellmano requested a review from Copilot September 13, 2025 17:50
Copy link

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

Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

bellmano and others added 3 commits September 13, 2025 19:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…DOM elements gracefully; add corresponding tests for robustness
@bellmano bellmano requested a review from Copilot September 13, 2025 18:12
Copy link

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

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

bellmano and others added 2 commits September 13, 2025 20:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bellmano bellmano requested a review from Copilot September 13, 2025 19:46
Copy link

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

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

tests/script.test.js:1

  • The assertion expect(exported.countUpFromTime).toBe('function') is incorrect. It should use expect(typeof exported.countUpFromTime).toBe('function') to check the type, similar to line 5.
describe('Main Script Tests', () => {

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

bellmano and others added 2 commits September 13, 2025 21:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sonarqubecloud
Copy link

@bellmano bellmano requested a review from Copilot September 13, 2025 19:50
Copy link

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

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const mockEl = createMockDOM();
global.document.getElementById = jest.fn(() => mockEl);
script.countUpFromTime('Sep 13, 2025 11:59:00', 'countup1');
expect(mockEl.years.innerHTML).toBe(0);
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

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

Inconsistent type checking - line 170 expects a number (0) but other lines in the same test convert to Number() first. Either convert to Number() here or use string comparison '0' for consistency.

Suggested change
expect(mockEl.years.innerHTML).toBe(0);
expect(Number(mockEl.years.innerHTML)).toBe(0);

Copilot uses AI. Check for mistakes.
test('module.exports is set correctly', () => {
const exported = require('../src/script.js');
expect(exported.countUpFromTime).toBeDefined();
expect(typeof exported.countUpFromTime).toBe('function');
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

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

Incorrect assertion - line 13 should use typeof operator like line 5, but line 13 is missing typeof and will fail since the function object is not equal to the string 'function'.

Copilot uses AI. Check for mistakes.
@bellmano bellmano merged commit f204f3c into main Sep 13, 2025
2 checks passed
@bellmano bellmano deleted the add_testcoverage branch September 13, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants