inluxc / playwright-xray

XRAY reporter for Playwright
MIT License
24 stars 10 forks source link

Is it possible to import Label for test execution #62

Open NiklasBack opened 7 months ago

NiklasBack commented 7 months ago
          @Niklas-Back  Hello again is it possible to import Label for test execution also ? 
Screenshot 2024-03-06 at 11 19 20

maybe i can already with the current config but dont know which key point to that , as per code i can see only those options testExecutionKey: this.options.testExecution, info: { summary: this.defaultRunName, project: this.options.projectKey, startDate: this.help.getFormatData(new Date()), finishDate: this.help.getFormatData(new Date()), testPlanKey: this.options.testPlan, revision: this.options.revision, description: this.options.description, testEnvironments: this.options.testEnvironments, version: this.options.version, }, Would be great in general to add custom fields customFields: { Browser: 'Google Chrome', Device: 'MacOS', },

Originally posted by @HamzaMiz in https://github.com/inluxc/playwright-xray/issues/59#issuecomment-1980538331

inluxc commented 7 months ago

Maybe we can add to the testEnvironments field in the import. Link the example says https://docs.getxray.app/display/XRAY/v2.0#/Import/post-import-execution

inluxc commented 7 months ago

Be the way the custom field are only available in the test level and not in the execution

NiklasBack commented 7 months ago

Be the way the custom field are only available in the test level and not in the execution

Hm, that means we have to look at something similar to what they have in the playwright-junit-reporter using testInfo.annotations.push. I don't know if there's currently a need for it at my company but I can raise the issue.

HamzaMiz commented 7 months ago

@NiklasBack @inluxc i made test with postman it works not the custom fields , the label which is my original request curl --location 'https://xray.cloud.getxray.app/api/v1/import/execution/junit/multipart' \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnQiOiI5ZTE2ZDUzNi0yMGZkLTMxNTgtOTFkZS1jOWNlNzQ0YTdiZDYiLCJhY2NvdW50SWQiOiI2MzExZjM1NzZhOGJiNGVkYTY3NzZiOTciLCJpc1hlYSI6ZmFsc2UsImlhdCI6MTcwOTg0NDQ2NiwiZXhwIjoxNzA5OTMwODY2LCJhdWQiOiJFQjlDMEMyRTdFMTI0NzcxOEU0MTE4NjJDOTZFQzI1OCIsImlzcyI6ImNvbS54cGFuZGl0LnBsdWdpbnMueHJheSIsInN1YiI6IkVCOUMwQzJFN0UxMjQ3NzE4RTQxMTg2MkM5NkVDMjU4In0._HHE5UlV8y7MZdyb5l5fVEiagu0mASFo1ctzmTDAY4I' \ --form 'info=@"/Users/hamzabouchoucha/Documents/issueFields.json"' \ --form 'results=@"/Users/hamzabouchoucha/Documents/mobility-business-rev-automation-testing/xray-report.xml"' \ --form 'testInfo=@"/Users/hamzabouchoucha/Documents/testIssueFields.json"' issueFields.json testIssueFields.json, i added field called labels on issueFields.json which points to test execution informations
Here's the result

Screenshot 2024-03-07 at 21 49 57

I want give u a context why we need this , because we have a webhook on teams each time test execution launch , we recieve notification with the results on a channel , but it works for all test excutions on the project , we need to put label so we can filter that image this from xray documentation https://docs.getxray.app/display/XRAY/Integration+with+Microsoft+Teams

HamzaMiz commented 7 months ago

@inluxc we re not using this https://docs.getxray.app/display/XRAY/v2.0#/Import/post-import-execution-multipart ?

NiklasBack commented 7 months ago

No, that's correct

inluxc commented 7 months ago

@inluxc we re not using this https://docs.getxray.app/display/XRAY/v2.0#/Import/post-import-execution-multipart ?

You are right, but the payload is the same as is mention in the API Docs

result *
string($binary)
The Xray JSON file, same as described in the POST /import/execution ([link](https://docs.getxray.app/display/XRAY420/v2.0#/Import/post-import-execution)). This file must be of type application/json.

UPDATE:

Sorry for misleading but I was wrong about it /import/execution and not the multipart.

I need to update to multipart so we can add labels to it. We also can add Flaky to the labels.

HamzaMiz commented 7 months ago

@inluxc

Screenshot 2024-03-12 at 17 03 05 Screenshot 2024-03-12 at 17 04 44

the payload of info where i can put "Labels" not result

inluxc commented 7 months ago

I was just checking that

inluxc commented 7 months ago

I will add Labels to the project tonight.

inluxc commented 7 months ago

Sorry guys, but a lot of work lately, I will try to do this week

NiklasBack commented 4 months ago

I've done some research regarding custom field when using my test importer. The issue is that there are a lot of different formats for the custom field so I have solved it by putting it in the configuration file (see example below for a select list, single choice) but then all tests will be tagged with the same custom field. Currently we are using it inhouse and I could make a pr with it if it would be interesting.

"customField": {
        "customfield_11548": {
            "Value": "JUMP"
        }
    }
HamzaMiz commented 4 months ago

that works i guess since Label is A field Used in all test so i can put the customfield of Label

NiklasBack commented 4 months ago

In order to get the right format one has to get it with a GET, e.g. as below and thereafter set it in the config file. The question is, if this is too complicated? https://xxx.atlassian.net/rest/api/2/search?jql=key=TESTCASE-12345&fields=customfield_10133,key' returns if a single select option

"customfield_10133": {
                    "self": "https://xxx.atlassian.net/rest/api/2/customFieldOption/10920",
                    "value": "A Value",
                    "id": "10920"
                }

In this case the config file should look like:

"customField": {
        "customfield_10133": {
            "Value": "A Value"
        }
    }

And if a string "customfield_10133": "The-Automaters"

In this case the config file should look like:

"customField": {
        "customfield_10133":  "The-Automaters"
    }
HamzaMiz commented 4 months ago

you a right the person needs to know the right format before send it in the json file , its complicated for non experienced person i guess , but we can add it the detail in the readme as instructions to check the customfield format with jira api and shouldn't be mandatory , because customFields are not always needed

Niklas-Back commented 4 months ago

I tried to get it to work with the import executions but there seems to be an issue with custom fields. The examples I showed above works when I import testscases, so I thought the same applied to executions. According to Xray importing executions only works with Xray test execution custom fields. Their work around is to import the execution and thereafter use the Jira APIs to update the cutom fields (haven't tried it so I don't know if it works) They have registered an issue regarding this https://jira.getxray.app/browse/XRAYCLOUD-6830

HamzaMiz commented 4 months ago

oh i see thanks for the update , i dont like workarounds so we need to wait for this one