Skip to content

Commit

Permalink
[EASI-4532]/customizable homepage status update (#1233)
Browse files Browse the repository at this point in the history
* feat: StatusPlannedActiveOrEnded to ModelBySolutionStatus. Break out into separate resolver, begin unit tests

* fix: update snapshot post merging in main

* feat: introduce feat with plans that use solutions 4innovations

* feat: add more solutions usage to model in seed data

* feat: set user view customization for MINT user

* feat: update to filter on the frontend using the backend calculated status

* feat: add cancelled model plan that uses 4i to seed data for testing

* feat: update client test

* feaT: rename StatusPlannedActiveOrEnded to ModelBySolutionStatus

* feat: add remaining statuses to unit test

* Change teset mock property to match query

* feat: update cypress homepage setting test to use different user as MINT is seeded with different views

* fix: update function name to match gql

* feat: add other type to modelBySolutionStatus unit test and update snapshots

* feat: add clarifying comment to cypress test

---------

Co-authored-by: Patrick Segura <[email protected]>
  • Loading branch information
StevenWadeOddball and patrickseguraoddball authored Jul 22, 2024
1 parent 891b6c2 commit 2fd0bcc
Show file tree
Hide file tree
Showing 17 changed files with 438 additions and 749 deletions.
116 changes: 115 additions & 1 deletion cmd/dbseed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func seed(config *viper.Viper) {
seeder := newDefaultSeeder(config)
seeder.SeedData()
seeder.CreateAnalyzedAuditData()
seeder.SetDefaultUserViews()
}

// SeedData gets resolver dependencies and calls wrapped resolver functions to seed data.
Expand All @@ -110,7 +111,28 @@ func (s *Seeder) SeedData() {
}

// Seed an empty plan
s.createModelPlan("Empty Plan", "MINT")
emptyPlan := s.createModelPlan("Empty Plan", "MINT")
s.updateModelPlan(emptyPlan, map[string]interface{}{
"abbreviation": "emptyPlan",
"status": models.ModelStatusCanceled,
})

emptyPlanOperationalNeeds := s.getOperationalNeedsByModelPlanID(emptyPlan.ID)
if len(emptyPlanOperationalNeeds) < 1 {
panic("operational needs must be populated in order to create an operational solution")
}

_ = s.addOperationalSolution(
emptyPlan,
emptyPlanOperationalNeeds[0].ID,
map[string]interface{}{
"needed": false,
"pocName": "The Gump",
"pocEmail": "[email protected]",
"mustStartDts": "2023-02-04T21:39:57.484167Z",
"mustFinishDts": "2023-12-04T21:39:57.484167Z",
},
)

// Seed a plan with some information already in it
planWithBasics := s.createModelPlan("Plan with Basics", "MINT")
Expand All @@ -132,6 +154,27 @@ func (s *Seeder) SeedData() {
},
)
s.existingModelLinkCreate(planWithBasics, models.EMLFTGeneralCharacteristicsResemblesExistingModelWhich, []int{links[3].ID, links[4].ID}, nil)
s.updateModelPlan(planWithBasics, map[string]interface{}{
"abbreviation": "basics",
"status": models.ModelStatusActive,
})

planWithBasicsOperationalNeeds := s.getOperationalNeedsByModelPlanID(planWithBasics.ID)
if len(planWithBasicsOperationalNeeds) < 1 {
panic("operational needs must be populated in order to create an operational solution")
}

_ = s.addOperationalSolution(
planWithBasics,
planWithBasicsOperationalNeeds[0].ID,
map[string]interface{}{
"needed": false,
"pocName": "The Gump",
"pocEmail": "[email protected]",
"mustStartDts": "2023-02-04T21:39:57.484167Z",
"mustFinishDts": "2023-12-04T21:39:57.484167Z",
},
)

// Seed a plan with collaborators
planWithCollaborators := s.createModelPlan("Plan With Collaborators", "MINT")
Expand All @@ -145,6 +188,28 @@ func (s *Seeder) SeedData() {
TeamRoles: []models.TeamRole{models.TeamRoleLeadership},
})

s.updateModelPlan(planWithCollaborators, map[string]interface{}{
"abbreviation": "collab",
"status": models.ModelStatusEnded,
})

planWithCollaboratorsOperationalNeeds := s.getOperationalNeedsByModelPlanID(planWithCollaborators.ID)
if len(planWithBasicsOperationalNeeds) < 1 {
panic("operational needs must be populated in order to create an operational solution")
}

_ = s.addOperationalSolution(
planWithCollaborators,
planWithCollaboratorsOperationalNeeds[0].ID,
map[string]interface{}{
"needed": false,
"pocName": "The Gump",
"pocEmail": "[email protected]",
"mustStartDts": "2023-02-04T21:39:57.484167Z",
"mustFinishDts": "2023-12-04T21:39:57.484167Z",
},
)

s.existingModelLinkCreate(planWithCollaborators, models.EMLFTGeneralCharacteristicsResemblesExistingModelWhich, []int{links[4].ID}, nil)

// Seed a plan with CRs / TDLs
Expand All @@ -167,13 +232,53 @@ func (s *Seeder) SeedData() {
})
s.existingModelLinkCreate(planWithCrTDLs, models.EMLFTGeneralCharacteristicsResemblesExistingModelWhich, nil, []uuid.UUID{planWithCollaborators.ID, planWithBasics.ID})

s.updateModelPlan(planWithCrTDLs, map[string]interface{}{
"abbreviation": "crTDLPlan",
"status": models.ModelStatusAnnounced,
})

planWithCrTDLsOperationalNeeds := s.getOperationalNeedsByModelPlanID(planWithCrTDLs.ID)
if len(planWithCrTDLsOperationalNeeds) < 1 {
panic("operational needs must be populated in order to create an operational solution")
}

_ = s.addOperationalSolution(
planWithCrTDLs,
planWithCrTDLsOperationalNeeds[0].ID,
map[string]interface{}{
"needed": false,
"pocName": "The Gump",
"pocEmail": "[email protected]",
"mustStartDts": "2023-02-04T21:39:57.484167Z",
"mustFinishDts": "2023-12-04T21:39:57.484167Z",
},
)

// Seed a plan that is already archived
archivedPlan := s.createModelPlan("Archived Plan", "MINT")
s.updateModelPlan(archivedPlan, map[string]interface{}{
"archived": true,
"abbreviation": "arch",
"status": models.ModelStatusPaused,
})

archivedPlanOperationalNeeds := s.getOperationalNeedsByModelPlanID(archivedPlan.ID)
if len(archivedPlanOperationalNeeds) < 1 {
panic("operational needs must be populated in order to create an operational solution")
}

_ = s.addOperationalSolution(
archivedPlan,
archivedPlanOperationalNeeds[0].ID,
map[string]interface{}{
"needed": false,
"pocName": "The Gump",
"pocEmail": "[email protected]",
"mustStartDts": "2023-02-04T21:39:57.484167Z",
"mustFinishDts": "2023-12-04T21:39:57.484167Z",
},
)

// Seed a plan with some documents
planWithDocuments := s.createModelPlan("Plan with Documents", "MINT")
restrictedDocument := s.planDocumentCreate(planWithDocuments, "File (Unscanned)", "cmd/dbseed/data/sample.pdf", "application/pdf", models.DocumentTypeConceptPaper, true, nil, nil, false, false)
Expand Down Expand Up @@ -308,3 +413,12 @@ func (s *Seeder) CreateAnalyzedAuditData() {
}

}

func (s *Seeder) SetDefaultUserViews() {
mintPrinc := s.getTestPrincipalByUsername("MINT")
s.updateUserView(mintPrinc, map[string]interface{}{
"viewCustomization": []models.ViewCustomizationType{models.ViewCustomizationTypeModelsByOperationalSolution, models.ViewCustomizationTypeFollowedModels, models.ViewCustomizationTypeAllModelPlans},
"possibleOperationalSolutions": []models.OperationalSolutionKey{models.OpSKInnovation, models.OpSKAcoOs},
},
)
}
19 changes: 18 additions & 1 deletion cmd/dbseed/resolver_wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (s *Seeder) addOperationalSolution(
changes map[string]interface{},
) *models.OperationalSolution {
principal := s.getTestPrincipalByUUID(mp.CreatedBy)
solType := models.OpSKMarx
solType := models.OpSKInnovation

operationalSolution, err := resolvers.OperationalSolutionCreate(
s.Config.Context,
Expand Down Expand Up @@ -353,3 +353,20 @@ func (s *Seeder) existingModelLinkCreate(
}
return links
}

// updateUserView is a wrapper that allows to set default user views for a user
func (s *Seeder) updateUserView(principal authentication.Principal, changes map[string]interface{}) *models.UserViewCustomization {

view, err := resolvers.UserViewCustomizationUpdate(
s.Config.Logger,
s.Config.Store,
principal,
changes,
)

if err != nil {
panic(err)
}
return view

}
3 changes: 2 additions & 1 deletion cypress/e2e/homepageSettings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
describe('Homepage Settings', () => {
beforeEach(() => {
cy.localLogin({ name: 'MINT' });
// Using ANON since that user has no customized views
cy.localLogin({ name: 'ANON' });
cy.visit('/homepage-settings');
});

Expand Down
Loading

0 comments on commit 2fd0bcc

Please sign in to comment.