@@ -6,6 +6,7 @@ import { mkdir, readFile, rm } from 'node:fs/promises'
66import { join } from 'node:path'
77import { spawnSync } from 'node:child_process'
88import { chromium , request } from '@playwright/test'
9+ import { pedroPotiPersona } from '../src/utils/pedroPotiPersona.js'
910
1011const baseURL = process . env . PLAYWRIGHT_BASE_URL ?? 'https://localhost'
1112const adminUser = process . env . NEXTCLOUD_ADMIN_USER ?? 'admin'
@@ -17,87 +18,8 @@ const demoAvatarPath = 'playwright/fixtures/pedro-poti-avatar.png'
1718
1819const legacyDemoUserIds = [ 'amina_okafor_demo' , 'araci_potira_demo' ]
1920
20- const demoUser = {
21- id : 'pedro_poti_demo' ,
22- password : 'PedroDemoPass123!' ,
23- displayName : 'Pedro Poti' ,
24- email : 'pedro.poti@example.net' ,
25- }
26-
27- const showcaseFields = [
28- {
29- fieldKey : 'showcase_support_region' ,
30- label : 'Support region' ,
31- type : 'text' ,
32- adminOnly : false ,
33- userEditable : true ,
34- userVisible : true ,
35- initialVisibility : 'users' ,
36- sortOrder : 10 ,
37- adminValue : { value : 'Northern Europe' , currentVisibility : 'users' } ,
38- demoValue : { value : 'East Africa' , currentVisibility : 'users' } ,
39- } ,
40- {
41- fieldKey : 'showcase_product_specialty' ,
42- label : 'Product specialty' ,
43- type : 'text' ,
44- adminOnly : false ,
45- userEditable : true ,
46- userVisible : true ,
47- initialVisibility : 'public' ,
48- sortOrder : 20 ,
49- adminValue : { value : 'Contract automation' , currentVisibility : 'public' } ,
50- demoValue : { value : 'Identity operations' , currentVisibility : 'public' } ,
51- } ,
52- {
53- fieldKey : 'showcase_customer_segment' ,
54- label : 'Customer segment' ,
55- type : 'text' ,
56- adminOnly : false ,
57- userEditable : true ,
58- userVisible : true ,
59- initialVisibility : 'users' ,
60- sortOrder : 30 ,
61- adminValue : { value : 'Public sector' , currentVisibility : 'users' } ,
62- demoValue : { value : 'Financial services' , currentVisibility : 'users' } ,
63- } ,
64- {
65- fieldKey : 'showcase_escalation_alias' ,
66- label : 'Escalation alias' ,
67- type : 'text' ,
68- adminOnly : false ,
69- userEditable : true ,
70- userVisible : true ,
71- initialVisibility : 'private' ,
72- sortOrder : 40 ,
73- adminValue : { value : 'north-eu-escalations' , currentVisibility : 'private' } ,
74- demoValue : { value : 'east-africa-escalations' , currentVisibility : 'private' } ,
75- } ,
76- {
77- fieldKey : 'showcase_incident_role' ,
78- label : 'Incident response role' ,
79- type : 'text' ,
80- adminOnly : false ,
81- userEditable : true ,
82- userVisible : true ,
83- initialVisibility : 'users' ,
84- sortOrder : 50 ,
85- adminValue : { value : 'Communications lead' , currentVisibility : 'users' } ,
86- demoValue : { value : 'Regional coordinator' , currentVisibility : 'users' } ,
87- } ,
88- {
89- fieldKey : 'showcase_on_call_tier' ,
90- label : 'On-call tier' ,
91- type : 'number' ,
92- adminOnly : true ,
93- userEditable : false ,
94- userVisible : true ,
95- initialVisibility : 'private' ,
96- sortOrder : 60 ,
97- adminValue : { value : 2 , currentVisibility : 'private' } ,
98- demoValue : { value : 1 , currentVisibility : 'private' } ,
99- } ,
100- ]
21+ const demoUser = pedroPotiPersona . user
22+ const showcaseFields = pedroPotiPersona . showcaseFields
10123
10224const showcaseKeys = new Set ( showcaseFields . map ( ( field ) => field . fieldKey ) )
10325const showcaseLabels = new Set ( showcaseFields . map ( ( field ) => field . label ) )
@@ -297,6 +219,25 @@ const hideNonShowcaseDialogFields = async(page) => {
297219 } , { labels : [ ...showcaseLabels ] , demoUserId : demoUser . id } )
298220}
299221
222+ const fillAccountField = async ( page , label , value ) => {
223+ const textboxes = page . getByRole ( 'textbox' , { name : label , exact : true } )
224+ const input = await textboxes . count ( ) > 0
225+ ? textboxes . first ( )
226+ : page . locator ( `input[aria-label="${ label } "], textarea[aria-label="${ label } "]` ) . first ( )
227+ await input . waitFor ( { state : 'visible' , timeout : 60_000 } )
228+ await input . fill ( value )
229+ await input . blur ( )
230+ await page . waitForTimeout ( 250 )
231+ }
232+
233+ const seedPedroPotiAccountProfile = async ( page ) => {
234+ for ( const field of pedroPotiPersona . accountFields ) {
235+ await fillAccountField ( page , field . label , field . value )
236+ }
237+
238+ await page . waitForTimeout ( 800 )
239+ }
240+
300241const prepareWorkflowScreenshot = async ( page ) => {
301242 await page . goto ( './settings/admin/workflow' )
302243 await page . getByRole ( 'heading' , { name : 'Available flows' } ) . waitFor ( { state : 'visible' , timeout : 60_000 } )
@@ -305,7 +246,7 @@ const prepareWorkflowScreenshot = async(page) => {
305246 if ( await showMoreButton . count ( ) > 0 ) {
306247 await showMoreButton . click ( )
307248 }
308- await page . getByRole ( 'heading' , { name : 'Create Talk conversation' , exact : true } ) . waitFor ( { state : 'visible' , timeout : 60_000 } )
249+ await page . getByRole ( 'heading' , { name : 'Create Talk conversation' , exact : true } ) . first ( ) . waitFor ( { state : 'visible' , timeout : 60_000 } )
309250
310251 await page . evaluate ( ( ) => {
311252 document . querySelector ( 'header' ) ?. setAttribute ( 'style' , 'display:none' )
@@ -407,6 +348,7 @@ const run = async() => {
407348 const personalPage = await demoContext . newPage ( )
408349 await personalPage . goto ( './settings/user/personal-info' )
409350 await personalPage . getByTestId ( 'profile-fields-personal-field-showcase_support_region' ) . waitFor ( { state : 'visible' , timeout : 60_000 } )
351+ await seedPedroPotiAccountProfile ( personalPage )
410352 await hideNonShowcasePersonalFields ( personalPage )
411353 await personalPage . locator ( 'main' ) . screenshot ( { path : join ( screenshotDir , 'personal-settings.png' ) , type : 'png' } )
412354
0 commit comments