Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exclude Helminth when testing warframe regression #655

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

SlayerOrnstein
Copy link
Member

@SlayerOrnstein SlayerOrnstein commented Nov 18, 2024

What did you fix?

Regression test failed when checking warframes for components as Helminth does not have components


Reproduction steps


Evidence/screenshot/link to line

Considerations

  • Does this contain a new dependency? No
  • Does this introduce opinionated data formatting or manual data entry? Yes
  • Does this pr include updated data files in a separate commit that can be reverted for a clean code-only pr? Yes
  • Have I run the linter? Yes
  • Is is a bug fix, feature request, or enhancement? Bug Fix

Summary by CodeRabbit

  • Bug Fixes
    • Updated the exclusion criteria in tests to now exclude 'Helminth' alongside 'Excalibur Prime', enhancing the accuracy of component presence validation in warframe objects.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@SlayerOrnstein SlayerOrnstein requested a review from a team as a code owner November 18, 2024 02:13
Copy link

coderabbitai bot commented Nov 18, 2024

Walkthrough

The changes made in this pull request involve updating the namedExclusions array in the test/index.regression.spec.mjs file. The array now includes 'Helminth' alongside 'Excalibur Prime', affecting the filtering logic for the data.warframes array. This adjustment modifies the test's exclusion criteria for warframes, but the overall structure and assertions of the test cases remain the same.

Changes

File Change Summary
test/index.regression.spec.mjs Updated namedExclusions array to include 'Helminth'.

Possibly related PRs

  • feat: add Helminth abilities #643: The changes in this PR involve modifying the namedExclusions array to include 'Helminth', which directly relates to the updates made in the main PR regarding the exclusion criteria for warframes in the tests.

Suggested labels

Scope: Data

Suggested reviewers

  • Soundofdarkness
  • TobiTenno

Poem

🐇 In the garden of code, we hop and play,
Exclusions updated, brightening the day.
'Helminth' joins 'Excalibur' in the list,
Filtering warframes, none can be missed!
With tests that are strong, we leap with delight,
Ensuring our logic is perfectly right! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
test/index.regression.spec.mjs (2)

Line range hint 5-8: Consider adding error handling for API requests

The grab function could benefit from proper error handling to make tests more reliable and provide better error messages when API requests fail.

Consider this improvement:

 const grab = async (path) => {
-  return fetch(`https://api.warframestat.us/${path}/?language=en`).then((d) => d.json());
+  try {
+    const response = await fetch(`https://api.warframestat.us/${path}/?language=en`);
+    if (!response.ok) {
+      throw new Error(`API request failed: ${response.status} ${response.statusText}`);
+    }
+    return response.json();
+  } catch (error) {
+    throw new Error(`Failed to fetch ${path}: ${error.message}`);
+  }
 };

Line range hint 24-63: Consider refactoring duplicate test logic

The uniqueness tests for different items share similar logic and could be refactored into a reusable test helper.

Consider this refactor to reduce code duplication:

+  const assertUniqueResult = (items, itemName, checkComponents = false) => {
+    const matches = items
+      .filter((i) => i.name === itemName)
+      .map((i) => {
+        delete i.patchlogs;
+        return i;
+      });
+    const dd = dedupe(matches);
+    assert.strictEqual(dd.length, matches.length, 'Before and after dedupe should match');
+    assert.strictEqual(matches.length, 1, 'There can be only One');
+    if (checkComponents) {
+      assert(Object.keys(matches[0]).includes('components'));
+    }
+  };
+
   it('weapons should only have 1 result for Mausolon', () => {
-    const matches = data.weapons
-      .filter((i) => i.name === 'Mausolon')
-      .map((i) => {
-        delete i.patchlogs;
-        return i;
-      });
-    const dd = dedupe(matches);
-    assert.strictEqual(dd.length, matches.length, 'Before and after dedupe should match');
-    assert.strictEqual(matches.length, 1, 'There can be only One');
+    assertUniqueResult(data.weapons, 'Mausolon');
   });
   
   it('warframes should only have 1 result for Octavia Prime', () => {
-    const matches = data.warframes
-      .filter((i) => i.name === 'Octavia Prime')
-      .map((i) => {
-        delete i.patchlogs;
-        return i;
-      });
-    const dd = dedupe(matches);
-    assert.strictEqual(dd.length, matches.length, 'Before and after dedupe should match');
-    assert.strictEqual(matches.length, 1, 'There can be only One');
+    assertUniqueResult(data.warframes, 'Octavia Prime');
   });
   
   it('items should only have 1 result for Octavia Prime', () => {
-    const matches = data.items
-      .filter((i) => i.name === 'Octavia Prime')
-      .map((i) => {
-        delete i.patchlogs;
-        return i;
-      });
-    const dd = dedupe(matches);
-    assert.strictEqual(dd.length, matches.length, 'Before and after dedupe should match');
-    assert.strictEqual(matches.length, 1, 'There can be only One');
-    assert(Object.keys(matches[0]).includes('components'));
+    assertUniqueResult(data.items, 'Octavia Prime', true);
   });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 453921e and 0ba57e1.

📒 Files selected for processing (1)
  • test/index.regression.spec.mjs (1 hunks)
🔇 Additional comments (1)
test/index.regression.spec.mjs (1)

16-16: LGTM! Verify Helminth's lack of components

The addition of 'Helminth' to the exclusions array aligns with the PR objectives and fixes the regression test failure.

Let's verify that Helminth indeed has no components in the API data:

✅ Verification successful

Verified: Helminth exclusion is correctly added

The test file shows that namedExclusions is used to skip component verification for specific warframes in the test suite. The exclusion is necessary as the test iterates through all warframes and verifies they have components, except for those in the exclusion list. Adding Helminth to this list indicates it's a special case warframe that doesn't follow the standard component structure, similar to the existing Excalibur Prime exclusion.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that Helminth warframe has no components in the API
curl -s "https://api.warframestat.us/warframes?language=en" | jq '.[] | select(.name == "Helminth") | .components'

Length of output: 173


Script:

#!/bin/bash
# Let's examine the test file to understand how the exclusions are used
cat test/index.regression.spec.mjs

Length of output: 2180

@TobiTenno TobiTenno merged commit c490af6 into WFCD:master Nov 18, 2024
8 checks passed
@SlayerOrnstein SlayerOrnstein deleted the fix-helminth-test branch December 6, 2024 19:59
@coderabbitai coderabbitai bot mentioned this pull request Dec 6, 2024
@wfcd-bot-boi
Copy link
Collaborator

🎉 This PR is included in version 1.1265.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants