# MGM HF listTitles - https://ownzones.atlassian.net/browse/CD-7719
### Issues
---
1. Error at add/update parent because some titles are missing from titles table, but are in entities table - Broken data on staging - todo: db cleanup!!!



- [ ] dev
- [ ] qa
### Known issues - not related to HF
1. [Titles navigator is not refetched after creating a hierarchy](https://ownzones.atlassian.net/browse/CD-7790)
2. [Wrong reference values added due to titles having duplicate names](https://ownzones.atlassian.net/browse/CD-7789)
3. [UpdateTitle query optimization
](https://ownzones.atlassian.net/browse/CD-7737)
4. @Laura: o chestie legata de ultimul fix si pe BE: am vorbit si cu Mihai si solutia asta introduce o alta regresie (care functioneaza acum, in momentul asta), dar apar 2 scenarii pe care nu prea le vrem:
in momentul de fata, pe pagina unui title cand schimbi entity type nu se updateaza si lista de atribute de metadata (trebuie sa dai save la noul entity type ca sa se repopuleze); odata cu virtual assets, a ramas ca at some point o sa venim cu improvement cand se schimba entity type sa se repopuleze lista de atribute (ceea ce dpdv functional este varianta corecta); la cum s-a modificat acum mutatia updateTitle, nu vei putea salva noul entityType si valorile noi de atribute la save (toate)
cu aceeasi cauza ca la punctul 1, mutatia updateTitle (pentru oricine ar vrea sa foloseasca doar zypline-api, fara web) nu va salva corect informatiile din atribute in cazul in care prin mutatie se schimba entity type
**--> it causes the following behaviour (which is a regression):**
csv import - change entity type, add new parent value to meta set, add attributes for existing title (of type child) - parent and meta attributes are added to metadata set, hierarchy NOK - https://ownzones.atlassian.net/browse/CD-7791

---
### Notes for listTitles query
1. on rise env, connect org - search within titles navigator (listTitles query) can take up to 4-5 sec - to investigate

*Marius:* Unfortunately, the queries with filter by title.name do not use the table index and, instead, use sequential scan to sort the entire table by title.name.
These queries (using Seq Scan on titles) are slower than the index queries (using Index Scan on titles).
2. load more - in titles navigator (while calling listTitles multiple times - another user navigating through pages)

- also when navigating through last pages

*Marius*: The queries for requesting last title pages are using Seq Scan on titles, so they run slower.
- [ ] dev
- [ ] qa
3. response times(max values) for listTitles query when navigating through first pages:

*Marius*: The queries for requesting first title pages are using Index Scan on titles, so they run faster.
---
## Scenarios:
**on rise - load testing** https://technicolor.ownzones.com/connect/titles
- [x] check titles listing (all views - tree, list, cards) - pagination (quick navigation through pages), search, select title
- [x] titles navigator - select titles, load more, search
**on two/staging - functional/regression testing**
- [x] create new entity types hierarchy
- [x] create titles hierarchy
- [x] add/remove parent values
- [x] update entity type on title (for parent/child title)
- [x] delete parent title
- validation errors for parent field:
- [x] change entity type on parent

- [x] delete parent title

- [x] import csv - the parent title has a wrong entity type
- [x] add/remove metadata attributes - update title
- [x] check metadata template preview - test entity.parent, entity.parent.parent annotations (e.g. https://connect.newstaging.ownzones.dev/metadate-cu-v2/metadata-templates/17a98875-e1fd-403a-a2ee-d46016a4e4c3)
- [x] import titles&metadata csv containing both parent and child titles - new titles
- [x] import titles&metadata csv containing both parent and child titles - update titles metadata
- [x] import imf
- [x] titles import plugin (titles hierarchy) - tested on rise env
---
Fixed Issues
---------------
1. Parent field still available in metadata set tab - update migration
- [x] dev
- [x] qa
2. @Marius and @Mihai - Import parent via csv import titles&meta - The Parent is added in the Metadata Sets, but the Child-Parent hierarchy isn't actually created between the Titles

- [x] dev
- [x] qa
Note: check titles import plugin as well!!
3. Have a title hierarchy (season title - episode title) - change the entity type of season title / delete the season title -> go to episode title & refresh - no validation error

before (validation error available in metadata set):

- [x] dev
- [x] qa
4. Remove parent value from metadata sets - titles hierarchy doesn't change (bc parent_id is not deleted)

- [x] dev
- [x] qa
5.@Mihai and @Laura Title having a child entity type assigned (parent field available in metadata sets, but is empty - it's not linked to another title) -> change entity type & save (the error is present only when updating the entity type on titles of type child)

- [x] dev
- [x] qa
6. If you update 2 old titles thorugh CSV Import, change their Entity Types, and try to set them in a Metadata Hierarchy, the Parent Value in metadata Sets for the Child shows a validation error. What happens here is that when the titles are updated, the old entities are not deleted.
- [x] dev
- [x] qa

7. Titles hierarchy not visible in navigator/tree view - for new titles (on org with discover enabled?)

https://connect.newstaging.ownzones.dev/testautomation/titles/e1fc0c8e-e193-4dcb-bcca-4053d5c94625?tab=metadataSets
here it works
https://connect.newstaging.ownzones.dev/metadate-cu-v2/titles/3ce48dc4-73b2-480b-81df-46ebdb9d55ef?tab=metadataSets
8. new title is created when updating entity type of an existing title by imf import
- [x] dev
- [x] qa
9. @Cristina duplicated titles - not an issue right now, to be investigated later (it seems they are some older titles, having the same name)

10. update entity type for a child title - the hierarchy is not updated (titles are still linked)

- [x] dev
- [x] qa
11. update entity type and Parent for existing title(of type child) via csv import - the parent is added to metadata set but hierarchy is not created

- [x] dev
- [x] qa
12. import via titles plugin - parent added to metadata set (in FE) but no hierarchy in titles navigator/tree view
- [x] dev
- [x] qa
13. remove parent from title metadata set for titles created by import - hierarchy does not changed, parent_id not deleted

- [x] dev
- [x] qa
---
### Last round of testing/regression
- **manual - from UI**:
- create titles, add parent to metadata set - hierarchy ok
- remove parent from meta set - ok
- add another parent - ok
- remove it again - ok
- change entity type on parent - validation error - ok
- delete parent - validation error - ok
- **csv titles/meta import**
- create new titles hierarchy by import(new titles) - ok
*!note - the csv must be imported twice to be sure that titles are linked*
- add parent to an existing title (not linked yet to another title) - ok
- update parent & attributes at the same time for child title (keep the same entity type) - ok (hierarchy updated also)
- update attribute values for root title - ok
- update attribute values for child title - ok
- ***change entity type, add new parent value to meta set, add attributes for existing title (of type child) - parent and meta attributes are added to metadata set, hierarchy NOK***
- **imf import**
- create new title by import with parent and meta attributes values - ok
- remove parent from metadata set(from FE) - ok
- imf import for existing title - update parent & meta attributes - ok
- **plugin import**
- create hierarchies with new titles and add meta attributes - ok (tested on both staging&rise)
- remove parent of a child title - from metadata set (from FE) - ok
- **metadata template** - entity.parent, entity.parent.parent - ok