@@ -12,6 +12,14 @@ async function openRelatedTasksForm(page) {
1212 return input
1313}
1414
15+ function relationSearchResults ( page ) {
16+ return page . locator ( '.task-relations .multiselect .search-results .search-result-button' )
17+ }
18+
19+ function relationTaskSearchResults ( page ) {
20+ return page . locator ( '.task-relations .multiselect .search-results .search-result-button:not(.is-create-option)' )
21+ }
22+
1523test . describe ( 'Related tasks quick add magic' , ( ) => {
1624 test ( 'Applies a label parsed via *prefix to the new related task' , async ( { authenticatedPage : page } ) => {
1725 const project = ( await ProjectFactory . create ( 1 , { id : 1 , title : 'Project A' } ) ) [ 0 ]
@@ -72,6 +80,60 @@ test.describe('Related tasks quick add magic', () => {
7280 await expect ( relatedTaskRow . locator ( '.different-project' ) ) . toContainText ( 'TargetProject' )
7381 } )
7482
83+ test ( 'Shows task identifiers in relation search results' , async ( { authenticatedPage : page } ) => {
84+ const project = ( await ProjectFactory . create ( 1 , { id : 1 , title : 'Project A' , identifier : 'PA' } ) ) [ 0 ]
85+ await createDefaultViews ( project . id )
86+ const parent = ( await TaskFactory . create ( 1 , { id : 10 , title : 'Parent task' , project_id : project . id } , false ) ) [ 0 ]
87+ await TaskFactory . create ( 1 , {
88+ id : 11 ,
89+ title : 'Identifier search candidate' ,
90+ project_id : project . id ,
91+ index : 42 ,
92+ } , false )
93+
94+ await page . goto ( `/tasks/${ parent . id } ` )
95+ const input = await openRelatedTasksForm ( page )
96+ await input . pressSequentially ( 'Identifier search candidate' )
97+
98+ const firstResult = relationTaskSearchResults ( page ) . filter ( { hasText : 'Identifier search candidate' } ) . first ( )
99+ await expect ( firstResult ) . toBeVisible ( { timeout : 10000 } )
100+ await expect ( firstResult ) . toContainText ( 'PA-42' )
101+ } )
102+
103+ test ( 'Prioritizes tasks from the current project in relation search results' , async ( { authenticatedPage : page } ) => {
104+ const currentProject = ( await ProjectFactory . create ( 1 , { id : 1 , title : 'Current Project' } ) ) [ 0 ]
105+ await createDefaultViews ( currentProject . id )
106+ const otherProject = ( await ProjectFactory . create ( 1 , { id : 2 , title : 'Other Project' } , false ) ) [ 0 ]
107+ await createDefaultViews ( otherProject . id , 5 )
108+
109+ const currentProjectParent = ( await TaskFactory . create ( 1 , {
110+ id : 30 ,
111+ title : 'Parent task' ,
112+ project_id : currentProject . id ,
113+ } , false ) ) [ 0 ]
114+ await TaskFactory . create ( 1 , {
115+ id : 5 ,
116+ title : 'Queue candidate other' ,
117+ project_id : otherProject . id ,
118+ } , false )
119+ await TaskFactory . create ( 1 , {
120+ id : 80 ,
121+ title : 'Queue candidate current' ,
122+ project_id : currentProject . id ,
123+ } , false )
124+
125+ await page . goto ( `/tasks/${ currentProjectParent . id } ` )
126+ const input = await openRelatedTasksForm ( page )
127+ await input . pressSequentially ( 'Queue candidate' )
128+
129+ const results = relationTaskSearchResults ( page )
130+ await expect ( results ) . toHaveCount ( 2 , { timeout : 10000 } )
131+ await expect ( results . first ( ) ) . toContainText ( 'Queue candidate current' )
132+ await expect ( results . first ( ) . locator ( '.different-project' ) ) . toHaveCount ( 0 )
133+ await expect ( results . nth ( 1 ) ) . toContainText ( 'Other Project' )
134+ await expect ( results . nth ( 1 ) ) . toContainText ( 'Queue candidate other' )
135+ } )
136+
75137 test ( 'Keeps the title literal when quick add magic is disabled' , async ( { page, apiContext} ) => {
76138 const user = ( await UserFactory . create ( 1 , {
77139 frontend_settings : JSON . stringify ( {
0 commit comments