-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: project create and delete react e2e [INFENG-456] (#9244)
- Loading branch information
1 parent
860f6a8
commit 6fa1420
Showing
17 changed files
with
246 additions
and
33 deletions.
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
webui/react/src/e2e/models/components/ProjcetActionDropdown.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,15 @@ | ||
import { DropdownMenu } from 'e2e/models/hew/Dropdown'; | ||
|
||
/** | ||
* Returns a representation of the Action Menu Dropdown component. | ||
* @param {object} obj | ||
* @param {BasePage} obj.root - root of the page | ||
* @param {ComponentBasics} [obj.childNode] - optional if `openMethod` is present. It's the element we click on to open the dropdown. | ||
* @param {Function} [obj.openMethod] - optional if `childNode` is present. It's the method to open the dropdown. | ||
*/ | ||
export class ProjectActionDropdown extends DropdownMenu { | ||
readonly edit = this.menuItem('edit'); | ||
readonly move = this.menuItem('move'); | ||
readonly archive = this.menuItem('switchArchive'); | ||
readonly delete = this.menuItem('delete'); | ||
} |
21 changes: 21 additions & 0 deletions
21
webui/react/src/e2e/models/components/ProjectCreateModal.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,21 @@ | ||
import { BaseComponent } from 'e2e/models/BaseComponent'; | ||
import { Modal } from 'e2e/models/hew/Modal'; | ||
|
||
/** | ||
* Returns a representation of the Project create/edit modal component. | ||
* This constructor represents the contents in src/components/Page.tsx. | ||
* @param {object} obj | ||
* @param {implementsGetLocator} obj.parent - The model's parent in the page hierarchy | ||
* @param {string} [obj.selector] - Used instead of `defaultSelector` | ||
*/ | ||
export class ProjectCreateModal extends Modal { | ||
readonly projectName = new BaseComponent({ | ||
parent: this, | ||
selector: 'input[id="projectName"]', | ||
}); | ||
|
||
readonly description = new BaseComponent({ | ||
parent: this, | ||
selector: 'input[id="description"]', | ||
}); | ||
} |
15 changes: 15 additions & 0 deletions
15
webui/react/src/e2e/models/components/ProjectDeleteModal.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,15 @@ | ||
import { BaseComponent } from 'e2e/models/BaseComponent'; | ||
import { Modal } from 'e2e/models/hew/Modal'; | ||
|
||
/** | ||
* Returns a representation of the Project delete modal component. | ||
* @param {object} obj | ||
* @param {implementsGetLocator} obj.parent - The parent used to locate this Page | ||
* @param {string} [obj.selector] - Used instead of `defaultSelector` | ||
*/ | ||
export class ProjectDeleteModal extends Modal { | ||
readonly nameConfirmation: BaseComponent = new BaseComponent({ | ||
parent: this, | ||
selector: 'input[id="projectName"]', | ||
}); | ||
} |
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,40 @@ | ||
import { BaseComponent, NamedComponent } from 'e2e/models/BaseComponent'; | ||
import { Card } from 'e2e/models/hew/Card'; | ||
|
||
import { ProjectActionDropdown } from './ProjcetActionDropdown'; | ||
import { ProjectCreateModal } from './ProjectCreateModal'; | ||
import { ProjectDeleteModal } from './ProjectDeleteModal'; | ||
|
||
/** | ||
* Returns a representation of the Projects Page component. | ||
* This constructor represents the contents in src/components/Page.tsx. | ||
* @param {object} obj | ||
* @param {implementsGetLocator} obj.parent - The parent used to locate this Page | ||
* @param {string} [obj.selector] - Used instead of `defaultSelector` | ||
*/ | ||
export class ProjectsComponent extends NamedComponent { | ||
override defaultSelector: string = '[id$=projects]'; | ||
readonly newProject = new BaseComponent({ | ||
parent: this._parent, | ||
selector: '[data-testid=newProject]', | ||
}); | ||
readonly createModal = new ProjectCreateModal({ | ||
parent: this.root, | ||
}); | ||
readonly deleteModal = new ProjectDeleteModal({ | ||
parent: this.root, | ||
}); | ||
readonly cardWithName = (name: string): ProjectsCard => { | ||
return Card.withName({ name: name, parent: this._parent }, ProjectsCard); | ||
}; | ||
} | ||
|
||
class ProjectsCard extends Card { | ||
override readonly actionMenu = new ProjectActionDropdown({ | ||
childNode: new BaseComponent({ | ||
parent: this, | ||
selector: Card.actionMenuSelector, | ||
}), | ||
root: this.root, | ||
}); | ||
} |
12 changes: 12 additions & 0 deletions
12
webui/react/src/e2e/models/components/ResourcePoolsPage.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,12 @@ | ||
import { NamedComponent } from 'e2e/models/BaseComponent'; | ||
|
||
/** | ||
* Returns a representation of the Resource Pools Page component. | ||
* This constructor represents the contents in src/components/Page.tsx. | ||
* @param {object} obj | ||
* @param {implementsGetLocator} obj.parent - The parent used to locate this Page | ||
* @param {string} [obj.selector] - Used instead of `defaultSelector` | ||
*/ | ||
export class ResourcePoolsComponent extends NamedComponent { | ||
override defaultSelector: string = '[id$=pools]'; | ||
} |
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,12 @@ | ||
import { NamedComponent } from 'e2e/models/BaseComponent'; | ||
|
||
/** | ||
* Returns a representation of the Tasks Page component. | ||
* This constructor represents the contents in src/components/Page.tsx. | ||
* @param {object} obj | ||
* @param {implementsGetLocator} obj.parent - The parent used to locate this Page | ||
* @param {string} [obj.selector] - Used instead of `defaultSelector` | ||
*/ | ||
export class TasksComponent extends NamedComponent { | ||
override defaultSelector: string = '[id$=tasks]'; | ||
} |
7 changes: 4 additions & 3 deletions
7
webui/react/src/e2e/models/components/WorkspaceActionDropdown.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
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 |
---|---|---|
@@ -1,12 +1,24 @@ | ||
import { NamedComponent } from 'e2e/models/BaseComponent'; | ||
import { Pivot } from 'e2e/models/hew/Pivot'; | ||
|
||
import { ModelRegistryPage } from './ModelRegistry'; | ||
import { ProjectsComponent } from './ProjectsPage'; | ||
import { ResourcePoolsComponent } from './ResourcePoolsPage'; | ||
import { TasksComponent } from './TasksPage'; | ||
|
||
/** | ||
* Returns a representation of the Projects Page component. | ||
* Returns a representation of the Workspace Details Page component. | ||
* This constructor represents the contents in src/components/Page.tsx. | ||
* @param {object} obj | ||
* @param {implementsGetLocator} obj.parent - The parent used to locate this Page | ||
* @param {string} [obj.selector] - Used instead of `defaultSelector` | ||
*/ | ||
export class WorkspaceDetails extends NamedComponent { | ||
readonly defaultSelector: string = '[id=workspaceDetails]'; | ||
// The details sections are all subpages wrapped with a Pivot tab | ||
readonly pivot = new Pivot({ parent: this }); | ||
readonly projects = this.pivot.typedTab('projects', ProjectsComponent); | ||
readonly tasks = this.pivot.typedTab('tasks', TasksComponent); | ||
readonly modelRegistry = this.pivot.typedTab('models', ModelRegistryPage); | ||
readonly resourcePools = this.pivot.typedTab('pools', ResourcePoolsComponent); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,41 @@ | ||
export { BaseComponent as Card } from 'e2e/models/BaseComponent'; | ||
import { | ||
BaseComponent, | ||
CanBeParent, | ||
NamedComponent, | ||
NamedComponentArgs, | ||
} from 'e2e/models/BaseComponent'; | ||
import { WorkspaceActionDropdown } from 'e2e/models/components/WorkspaceActionDropdown'; | ||
|
||
import { DropdownMenu } from './Dropdown'; | ||
|
||
/** | ||
* Returns a representation of the card component from Hew. | ||
* This constructor represents the contents in hew/src/kit/Card.tsx. | ||
* @param {object} obj | ||
* @param {implementsGetLocator} obj.parent - The parent used to locate this card | ||
* @param {string} obj.selector - Used instead of `defaultSelector` | ||
*/ | ||
export class Card extends NamedComponent { | ||
override defaultSelector: string = ''; // must be provided | ||
// provide an actionMenu with a Dropdown to use | ||
static actionMenuSelector = '[aria-label="Action menu"]'; | ||
|
||
// default to a workspace dropdown to avoid non-null but this should be overriden if a dropdown exists | ||
readonly actionMenu: DropdownMenu = new WorkspaceActionDropdown({ | ||
childNode: new BaseComponent({ | ||
parent: this, | ||
selector: Card.actionMenuSelector, | ||
}), | ||
root: this.root, | ||
}); | ||
|
||
static withName<T extends Card>( | ||
props: { name: string; parent: CanBeParent }, | ||
cardType: new (args: NamedComponentArgs) => T, | ||
): T { | ||
return new cardType({ | ||
parent: props.parent, | ||
selector: `[data-testid="card-${props.name}"]`, | ||
}); | ||
} | ||
} |
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.