Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin - Model Registry RBAC Management Projects #3057

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/src/__mocks__/mockRoleBindingK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type MockResourceConfigType = {
roleRefName?: string;
uid?: string;
modelRegistryName?: string;
isProjectSubject?: boolean;
};

export const mockRoleBindingK8sResource = ({
Expand All @@ -22,6 +23,7 @@ export const mockRoleBindingK8sResource = ({
],
roleRefName = 'view',
uid = genUID('rolebinding'),
isProjectSubject = false,
modelRegistryName = '',
}: MockResourceConfigType): RoleBindingKind => {
let labels;
Expand All @@ -33,6 +35,7 @@ export const mockRoleBindingK8sResource = ({
'app.kubernetes.io/part-of': 'model-registry',
[KnownLabels.DASHBOARD_RESOURCE]: 'true',
component: 'model-registry',
...(isProjectSubject && { [KnownLabels.PROJECT_SUBJECT]: 'true' }),
};
} else {
labels = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,35 @@ import { TableRow } from './components/table';

class PermissionsTableRow extends TableRow {}

class UsersTab {
class UsersTab extends Contextual<HTMLElement> {
findAddUserButton() {
return this.find().findByTestId('add-button user');
}

findAddGroupButton() {
return this.find().findByTestId('add-button group');
}

getUserTable() {
return new PermissionTable(() => this.find().findByTestId('role-binding-table User'));
}

getGroupTable() {
return new PermissionTable(() => this.find().findByTestId('role-binding-table Group'));
}
}

class ProjectsTab extends Contextual<HTMLElement> {
findAddProjectButton() {
return this.find().findByTestId('add-button project');
}

getProjectTable() {
return new PermissionTable(() => this.find().findByTestId('role-binding-table Group'));
}
}

class MRPermissions {
visit(mrName: string, wait = true) {
cy.visitWithLogin(`/modelRegistrySettings/permissions/${mrName}`);
if (wait) {
Expand All @@ -16,20 +44,16 @@ class UsersTab {
cy.testA11y();
}

findAddUserButton() {
return cy.findByTestId('add-button User');
}

findAddGroupButton() {
return cy.findByTestId('add-button Group');
findProjectTab() {
return cy.findByTestId('projects-tab');
}

getUserTable() {
return new PermissionTable(() => cy.findByTestId('role-binding-table User'));
getUsersContent() {
return new UsersTab(() => cy.findByTestId('users-tab-content'));
}

getGroupTable() {
return new PermissionTable(() => cy.findByTestId('role-binding-table Group'));
getProjectsContent() {
return new ProjectsTab(() => cy.findByTestId('projects-tab-content'));
}
}

Expand All @@ -46,7 +70,7 @@ class PermissionTable extends Contextual<HTMLElement> {
return this.find().findByTestId(['role-binding-name-input', id]);
}

findGroupSelect() {
findNameSelect() {
return this.find().get(`[aria-label="Name selection"]`);
}

Expand All @@ -69,4 +93,4 @@ class PermissionTable extends Contextual<HTMLElement> {
}
}

export const usersTab = new UsersTab();
export const modelRegistryPermissions = new MRPermissions();
4 changes: 2 additions & 2 deletions frontend/src/__tests__/cypress/cypress/pages/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class PermissionsTab {
}

findAddUserButton() {
return cy.findByTestId('add-button User');
return cy.findByTestId('add-button user');
}

findAddGroupButton() {
return cy.findByTestId('add-button Group');
return cy.findByTestId('add-button group');
}

getUserTable() {
Expand Down
Loading
Loading