11import { expect } from "chai" ;
2-
32import { ShallowReference , TestConfiguration , TestPoint , WorkItemReference } from "azure-devops-node-api/interfaces/TestInterfaces" ;
43import { TestFrameworkResult } from "../framework/TestFrameworkResult" ;
54import { TestAutomationPropertyMatchStrategy , TestConfigMatchStrategy , TestIdMatchStrategy , TestNameMatchStrategy , TestRegexMatchStrategy } from "../processing/TestResultProcessorFactory" ;
65import { TestResultMatch } from "../processing/TestResultMatchStrategy" ;
7- import * as util from './testUtil' ;
86
97describe ( "TestCaseMatchStrategy" , ( ) => {
108
@@ -28,21 +26,22 @@ describe("TestCaseMatchStrategy", () => {
2826 point = < TestPoint > { id : 1 , configuration : < ShallowReference > { id : "1" , name :"Config1" } } ;
2927
3028 // setup subject
31- subject = new TestConfigMatchStrategy ( allowedConfigs , "Config" ) ;
29+ // The default testConfigProperty is "Config"
30+ subject = new TestConfigMatchStrategy ( allowedConfigs , "Config" ) ;
3231 } )
3332
34- it ( 'Should match if testpoint has the same category as filter ' , async ( ) => {
33+ it ( 'Should match if testpoint has a supported configuration ' , async ( ) => {
3534 // arrange
36-
35+ test . properties . set ( "Config" , "Config1" ) ; // dummy
3736 // act
3837 var result = subject . isMatch ( test , point ) ;
3938
4039 // assert
41- expect ( result ) . eq ( TestResultMatch . None ) ;
40+ expect ( result ) . eq ( TestResultMatch . None ) ;
4241 } ) ;
4342
44- // test point does not have same category
45- it ( 'Should not match if testpoint does not have the same category as filter ' , async ( ) => {
43+ // test point does not have same configuration as allowed configurations
44+ it ( 'Should not match if testpoint does not have supported configuration ' , async ( ) => {
4645 // arrange
4746 point . configuration = < ShallowReference > { id : "2" , name : "Different Config" } ;
4847
@@ -53,6 +52,35 @@ describe("TestCaseMatchStrategy", () => {
5352 expect ( result ) . eq ( TestResultMatch . Fail ) ;
5453 } ) ;
5554
55+ // assuming that testConfigProperty is opt-in and the majority of TestPoints won't have configurations
56+ // could translate into a bug if a TestPoint has multiple configurations but the TestFramework result doesn't
57+ it ( 'Should match even if TestFramework result does not have a defined testConfigProperty' , ( ) => {
58+ // arrange
59+ test . properties . clear ( ) ; // no config property
60+
61+ // act
62+ var result = subject . isMatch ( test , point ) ;
63+
64+ // assert
65+ expect ( result ) . eq ( TestResultMatch . None ) ;
66+ } ) ;
67+
68+ // https://github.com/bryanbcook/azdevops-testplan-extension/issues/92
69+ // looks like the API is returning a number for the id instead of a string in the shallowreference
70+ it ( 'Should match if config id in shallow reference is not a string' , async ( ) => {
71+ // arrange
72+ test . properties . set ( "Config" , "Config1" )
73+
74+ // emulate API response as number by using <unknown> cast
75+ point . configuration = < ShallowReference > < unknown > { id : 1 , name : "Config1" } ;
76+
77+ // act
78+ var result = subject . isMatch ( test , point ) ;
79+
80+ // assert
81+ expect ( result ) . eq ( TestResultMatch . None ) ;
82+ } ) ;
83+
5684 it ( 'Should match if test result has matching config' , async ( ) => {
5785 // arrange
5886 test . properties . set ( "Config" , "1" ) ;
@@ -74,13 +102,6 @@ describe("TestCaseMatchStrategy", () => {
74102 // assert
75103 expect ( result ) . eq ( TestResultMatch . None ) ;
76104 } ) ;
77- // // arrange
78- // // act
79- // // assert
80- // throw new Error("Not implemented");
81-
82-
83-
84105 } ) ;
85106
86107 context ( "TestCase Name Matcher" , ( ) => {
0 commit comments