nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: wix/Detox
Pull request #4365 (2024-02-10 16:47:50)

fix(ios): track hierarchy artifacts
## Description

This pull request addresses absent UI hierarchy artifacts in our Allure reports.

It should be helpful for anyone who's using: https://github.com/wix-incubator/detox-allure2-adapter


Patch:
diff --git a/detox/src/artifacts/uiHierarchy/IosUIHierarchyPlugin.js b/detox/src/artifacts/uiHierarchy/IosUIHierarchyPlugin.js
index f20d45601..031270984 100644
--- a/detox/src/artifacts/uiHierarchy/IosUIHierarchyPlugin.js
+++ b/detox/src/artifacts/uiHierarchy/IosUIHierarchyPlugin.js
@@ -51,6 +51,7 @@ class IosUIHierarchyPlugin extends ArtifactPlugin {
     if (this.enabled) {
       const scope = this.context.testSummary ? 'perTest' : 'perSession';
       setUniqueProperty(this._artifacts[scope], name, artifact);
+      this.api.trackArtifact(artifact);
     } else {
       this._pendingDeletions.push(artifact.discard());
     }
@@ -97,6 +98,7 @@ class IosUIHierarchyPlugin extends ArtifactPlugin {
       .map(async ([key, artifact]) => {
         const destination = await this.api.preparePathForArtifact(`${key}.viewhierarchy`, testSummary);
         await artifact.save(destination);
+        this.api.untrackArtifact(artifact);
       })
       .value();
 


Test patch:
diff --git a/detox/src/artifacts/uiHierarchy/IosUIHierarchyPlugin.test.js b/detox/src/artifacts/uiHierarchy/IosUIHierarchyPlugin.test.js
index 340422bb7..06dcf0b4e 100644
--- a/detox/src/artifacts/uiHierarchy/IosUIHierarchyPlugin.test.js
+++ b/detox/src/artifacts/uiHierarchy/IosUIHierarchyPlugin.test.js
@@ -32,6 +32,8 @@ describe('IosUIHierarchyPlugin', () => {
       requestIdleCallback: jest.fn(async (callback) => {
         await callback();
       }),
+      trackArtifact: jest.fn(),
+      untrackArtifact: jest.fn(),
       userConfig: {
         enabled: true,
         keepOnlyFailedTestsArtifacts: false,
@@ -65,6 +67,8 @@ describe('IosUIHierarchyPlugin', () => {
       expect(session2.save).toHaveBeenCalledWith('artifacts/ui2.viewhierarchy');
       expect(test1.save).toHaveBeenCalledWith('artifacts/test/ui.viewhierarchy');
       expect(test2.save).toHaveBeenCalledWith('artifacts/test/ui2.viewhierarchy');
+      expect(api.trackArtifact).toHaveBeenCalledTimes(4);
+      expect(api.untrackArtifact).toHaveBeenCalledTimes(4);
     });
 
     it('should relocate existing artifacts before the app gets uninstalled', async () => {