1
1
import { expect } from '@playwright/test' ;
2
- import { AdditionalFilter } from 'dsm/component/filters/sections/search/search-enums ' ;
2
+ import { test } from 'fixtures/dsm-fixture ' ;
3
3
import { SamplesNavEnum } from 'dsm/component/navigation/enums/samplesNav-enum' ;
4
4
import { StudyEnum } from 'dsm/component/navigation/enums/selectStudyNav-enum' ;
5
5
import { StudyNavEnum } from 'dsm/component/navigation/enums/studyNav-enum' ;
@@ -11,129 +11,47 @@ import ParticipantPage from 'dsm/pages/participant-page/participant-page';
11
11
import AtcpSearchPage , { SearchByField } from 'dsm/pages/samples/search-page' ;
12
12
import { WelcomePage } from 'dsm/pages/welcome-page' ;
13
13
import Radiobutton from 'dss/component/radiobutton' ;
14
- import { test } from 'fixtures/dsm-fixture' ;
15
14
import { getUtcDate } from 'utils/date-utils' ;
16
15
import { generateAlphaNumeric } from 'utils/faker-utils' ;
17
- import { logError , logGenomeStudySampleKitReceived , logInfo } from 'utils/log-utils' ;
18
16
import { studyShortName , waitForNoSpinner , waitForResponse } from 'utils/test-utils' ;
17
+ import { logInfo } from 'utils/log-utils' ;
19
18
20
19
test . describe ( 'Receive Genome Study Kit' , ( ) => {
21
20
const studies = [ StudyEnum . AT ] ;
22
21
for ( const study of studies ) {
23
22
let newBarcode = generateAlphaNumeric ( ) . toUpperCase ( ) ;
24
23
25
24
let shortId : string ;
26
- let guid : string ;
27
25
28
26
let participantPage : ParticipantPage ;
29
27
let participantListPage : ParticipantListPage ;
30
28
let navigation : Navigation ;
31
29
32
- // Fallback to use non-e2e participant if all e2e participants have kit received before
33
- const nonE2EParticipants : string [ ] = [ ] ;
34
-
35
30
test . beforeEach ( async ( { page, request} ) => {
36
31
navigation = new Navigation ( page , request ) ;
37
32
const welcomePage = new WelcomePage ( page ) ;
38
33
await welcomePage . selectStudy ( study ) ;
39
34
} ) ;
40
35
41
36
test ( `Receive genome sample kit for ${ study } @dsm @${ study } @functional` , async ( { page} ) => {
42
- // Instead using UI table filter and search, it is much quicker and more accurate to intercept DSM API request to find the right participant to use.
43
- // Find a Playwright test user that does not have GENOME_STUDY_SPIT_KIT_BARCODE.
44
- await page . route ( '**/*' , async ( route , request ) : Promise < void > => {
45
- const regex = new RegExp ( / a p p l y F i l t e r \? r e a l m = .* & u s e r I d = .* & p a r e n t = p a r t i c i p a n t L i s t / i) ;
46
- if ( ! shortId && request && request . url ( ) . match ( regex ) ) {
47
- logInfo ( `Intercepting API request ${ request . url ( ) } to search for a E2E participant` ) ;
48
- const response = await route . fetch ( ) ;
49
- const json = JSON . parse ( await response . text ( ) ) ;
50
- for ( const i in json . participants ) {
51
- const participant = json . participants [ i ] ;
52
- const profile = participant . esData . profile ;
53
- const participantData = participant . esData . dsm . participantData ;
54
- let hruId = profile . hruid ;
55
- expect ( hruId ) . toBeTruthy ( ) ; // hruid must exists
56
- try {
57
- let existField = false ;
58
- for ( const dataId in participantData ) {
59
- if ( ( participantData [ dataId ] . fieldTypeId as string ) === 'AT_GROUP_GENOME_STUDY' ) {
60
- existField = true ;
61
- if ( ( participantData [ dataId ] . data as string ) . indexOf ( 'GENOME_STUDY_SPIT_KIT_BARCODE' ) !== - 1 ) {
62
- hruId = null ; // discard this participant because person has received genome study kit before
63
- }
64
- break ;
65
- }
66
- }
67
- expect ( existField ) . toBe ( true ) ; // AT_GROUP_GENOME_STUDY must exists in participantData
68
- if ( hruId && profile . firstName ) {
69
- if ( profile . firstName . includes ( 'E2E' ) ) {
70
- shortId = hruId ;
71
- break ; // finish searching for a participant who is Playwright automation test created and does not have genome study kit barcode
72
- } else {
73
- // save non-e2e participant short id then check next participant
74
- nonE2EParticipants . push ( hruId ) ;
75
- }
76
- }
77
- } catch ( err ) {
78
- logError ( `Failed to read response json.\n${ err } ` ) ;
79
- logError ( JSON . stringify ( participant ) ) ;
80
- }
81
- }
82
- }
83
- return route . continue ( ) ;
84
- } ) ;
85
-
86
37
await test . step ( 'Search for the right participant on Participant List page' , async ( ) => {
87
38
participantListPage = await navigation . selectFromStudy < ParticipantListPage > ( StudyNavEnum . PARTICIPANT_LIST ) ;
88
39
await participantListPage . waitForReady ( ) ;
89
40
90
- // Search for a participant that meets the search criteria
91
- const customizeViewPanel = participantListPage . filters . customizeViewPanel ;
92
- await customizeViewPanel . open ( ) ;
93
- await customizeViewPanel . selectColumns ( 'Participant Columns' , [ 'Registration Date' ] ) ;
94
- await customizeViewPanel . selectColumns ( 'Genome Study Columns' , [ 'Sample kit barcode for genome study' ] , { nth : 1 } ) ;
95
- await customizeViewPanel . close ( ) ;
96
-
97
- const searchPanel = participantListPage . filters . searchPanel ;
98
- await searchPanel . open ( ) ;
99
- await searchPanel . checkboxes ( 'Status' , { checkboxValues : [ 'Registered' , 'Enrolled' ] } ) ;
100
- await searchPanel . text ( 'Sample kit barcode for genome study' , { additionalFilters : [ AdditionalFilter . EMPTY ] } ) ;
101
- await searchPanel . search ( ) ;
102
- } ) ;
103
-
104
- await test . step ( 'Verify participant detail on Participant page' , async ( ) => {
105
- const searchPanel = participantListPage . filters . searchPanel ;
106
- await searchPanel . clear ( ) ;
107
-
108
- if ( ! shortId ) {
109
- // Attempt to find a non-e2e test participant
110
- const [ firstParticipant ] = nonE2EParticipants ;
111
- shortId = firstParticipant ;
112
- }
113
-
114
- await participantListPage . filterListByShortId ( shortId ) ;
115
- logGenomeStudySampleKitReceived ( shortId ) ;
41
+ const rowIndex = await participantListPage . findParticipantFor ( 'Genome Study Columns' , 'Sample kit barcode for genome study' , { nth : 1 } ) ;
116
42
117
- const row = 0 ;
118
- const participantsTable = participantListPage . participantListTable ;
119
- const status = await participantsTable . getParticipantDataAt ( row , 'Status' ) ;
120
- expect ( status ) . toMatch ( / E n r o l l e d | R e g i s t e r e d / ) ;
121
- const rowShortId = await participantsTable . getParticipantDataAt ( row , 'Short ID' ) ;
122
- expect ( rowShortId ) . toBe ( shortId ) ;
123
- const registrationDate = await participantsTable . getParticipantDataAt ( row , 'Registration Date' , { exactMatch : false } ) ;
124
-
125
- // Open the Participant page
126
- participantPage = await participantsTable . openParticipantPageAt ( row ) ;
127
-
128
- expect ( await participantPage . getStatus ( ) ) . toBe ( status ) ;
129
- expect ( await participantPage . getShortId ( ) ) . toBe ( shortId ) ;
130
- expect ( await participantPage . getRegistrationDate ( ) ) . toBe ( registrationDate ) ;
131
- guid = await participantPage . getGuid ( ) ;
43
+ const participantListTable = participantListPage . participantListTable ;
44
+ shortId = await participantListTable . getParticipantDataAt ( rowIndex , 'Short ID' ) ;
45
+ participantPage = await participantListTable . openParticipantPageAt ( rowIndex ) ;
46
+ logInfo ( `Participant Short ID: ${ shortId } ` ) ;
132
47
} ) ;
133
48
134
49
await test . step ( 'Set new sample kit barcode' , async ( ) => {
135
50
newBarcode = `${ shortId } -${ newBarcode } ` ;
136
51
const genomeStudyTab = await participantPage . clickTab < GenomeStudyTab > ( TabEnum . GENOME_STUDY ) ;
52
+ const value = await genomeStudyTab . getField ( 'Sample kit barcode for genome study' ) . locator ( 'input' ) . inputValue ( ) ;
53
+ expect ( value ) . toBe ( '' ) ; // Sample Kit Barcode input should be empty
54
+
137
55
await Promise . all ( [
138
56
genomeStudyTab . setValue ( 'Sample kit barcode for genome study' , newBarcode ) ,
139
57
page . waitForResponse ( resp => {
@@ -157,6 +75,7 @@ test.describe('Receive Genome Study Kit', () => {
157
75
expect ( await table . getRowText ( row , 'Short ID' ) ) . toBe ( shortId ) ;
158
76
159
77
const button = table . findButtonInCell ( table . rowLocator ( ) , { label : 'Mark Received' } ) ;
78
+ await expect ( button . toLocator ( ) ) . toBeVisible ( ) ;
160
79
await Promise . all ( [
161
80
waitForResponse ( page , { uri : `ui/receivedKits?realm=${ studyShortName ( study ) . realm } &userId=` } ) ,
162
81
button . click ( )
0 commit comments