-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the project dropdown (#3172)
* Refactor the project dropdown * Improve cross usage of types in bad DRY code * Address cypress test situation around shared component * Embrace a pure css solution to the truncate no-min-width * Added back the isDisabled flag to the pipeline selector variants
- Loading branch information
1 parent
80be394
commit 4a6ab8a
Showing
25 changed files
with
574 additions
and
516 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
frontend/src/__tests__/cypress/cypress/pages/components/subComponents/SearchSelector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { SubComponentBase } from '~/__tests__/cypress/cypress/pages/components/subComponents/SubComponentBase'; | ||
|
||
export class SearchSelector extends SubComponentBase { | ||
constructor(private selectorId: string, contextSelectorId?: string) { | ||
super(contextSelectorId); | ||
} | ||
|
||
private findContextualItem(suffix: string): Cypress.Chainable<JQuery<HTMLElement>> { | ||
return this.findScope().findByTestId(`${this.selectorId}-${suffix}`); | ||
} | ||
|
||
findItem(name: string): Cypress.Chainable<JQuery<HTMLElement>> { | ||
return this.findToggleButton().findDropdownItem(name); | ||
} | ||
|
||
selectItem(name: string): void { | ||
this.findItem(name).click(); | ||
} | ||
|
||
findSearchInput(): Cypress.Chainable<JQuery<HTMLElement>> { | ||
return this.findContextualItem('search'); | ||
} | ||
|
||
findToggleButton(): Cypress.Chainable<JQuery<HTMLElement>> { | ||
return this.findContextualItem('toggle'); | ||
} | ||
|
||
findSearchHelpText(): Cypress.Chainable<JQuery<HTMLElement>> { | ||
return this.findContextualItem('searchHelpText'); | ||
} | ||
|
||
findMenu(): Cypress.Chainable<JQuery<HTMLElement>> { | ||
return this.findContextualItem('menu'); | ||
} | ||
|
||
findMenuList(): Cypress.Chainable<JQuery<HTMLElement>> { | ||
return this.findContextualItem('menuList'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
frontend/src/__tests__/cypress/cypress/pages/components/subComponents/SubComponentBase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* A SubComponent is a component that doesn't make up a full page and will be consumed in other page | ||
* objects. This could be a complex field, a group of fields, or some section. Typically not large | ||
* enough to warrant its own standalone page object. | ||
* | ||
* Primary use-case example: | ||
* class Foo extends SubComponentBase { | ||
* constructor(private myTestId: string, scopedTestId?: string) { | ||
* super(scopedTestId); | ||
* } | ||
* | ||
* private find(suffix: string) { | ||
* return this.findScope().getByTestId(`${this.myTestId}-${suffix}`); | ||
* } | ||
* | ||
* selectItem(name: string) { | ||
* // "list" would be an internal suffix for your component to know where the "items" are | ||
* return this.find('list').findDropdownItem(name); | ||
* } | ||
* } | ||
* | ||
* Search uses of this component to see further examples | ||
*/ | ||
export class SubComponentBase { | ||
constructor(private scopedBaseTestId?: string) {} | ||
|
||
/** Allows for extended classes to make use of a simple one-check for their `find()` calls */ | ||
protected findScope(): (Cypress.cy & CyEventEmitter) | Cypress.Chainable<JQuery<HTMLElement>> { | ||
if (this.scopedBaseTestId) { | ||
return cy.findByTestId(this.scopedBaseTestId); | ||
} | ||
|
||
return cy; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.