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

feat: update Datagrid filter to account for reoccuring metadata columns #10045

Closed
wants to merge 6 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ export class InteractiveTable<

readonly table: Table<RowType, HeadRowType>;
readonly skeleton = new SkeletonTable({ parent: this });

// TODO: add getRowByColumnValue (maybe base on the DataGrid model)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BaseReactFragment } from 'playwright-page-model-base/BaseReactFragment'
import { Select } from 'e2e/models/common/hew/Select';
import { Toggle } from 'e2e/models/common/hew/Toggle';
import { GridListRadioGroup } from 'e2e/models/components/GridListRadioGroup';
import { ProjectActionDropdown } from 'e2e/models/components/ProjectActionDropdown';
import { ProjectCard } from 'e2e/models/components/ProjectCard';
import { ProjectCreateModal } from 'e2e/models/components/ProjectCreateModal';
import { ProjectDeleteModal } from 'e2e/models/components/ProjectDeleteModal';
Expand All @@ -15,13 +16,72 @@ class ProjectHeadRow extends HeadRow {
parent: this,
selector: '[data-testid="Name"]',
});
readonly description = new BaseComponent({
parent: this,
selector: '[data-testid="Description"]',
});
readonly numExperiments = new BaseComponent({
parent: this,
selector: '[data-testid="NumExperiments"]',
});
readonly lastUpdated = new BaseComponent({
parent: this,
selector: '[data-testid="LastUpdated"]',
});
readonly userId = new BaseComponent({
parent: this,
selector: '[data-testid="UserId"]',
});
readonly archived = new BaseComponent({
parent: this,
selector: '[data-testid="Archived"]',
});
readonly state = new BaseComponent({
parent: this,
selector: '[data-testid="State"]',
});
readonly action = new BaseComponent({
parent: this,
selector: '[data-testid="Action"]',
});
}

class ProjectRow extends Row {
readonly name = new BaseComponent({
parent: this,
selector: '[data-testid="name"]',
});
readonly description = new BaseComponent({
parent: this,
selector: '[data-testid="description"]',
});
readonly numExperiments = new BaseComponent({
parent: this,
selector: '[data-testid="numExperiments"]',
});
readonly lastUpdated = new BaseComponent({
parent: this,
selector: '[data-testid="lastUpdated"]',
});
readonly userId = new BaseComponent({
parent: this,
selector: '[data-testid="userId"]',
});
readonly archived = new BaseComponent({
parent: this,
selector: '[data-testid="archived"]',
});
readonly state = new BaseComponent({
parent: this,
selector: '[data-testid="state"]',
});
readonly action = new ProjectActionDropdown({
clickThisComponentToOpen: new BaseComponent({
parent: this,
selector: '[data-testid="actionMenu"]',
}),
root: this.root,
});
}

/**
Expand Down
87 changes: 77 additions & 10 deletions webui/react/src/e2e/tests/projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { ProjectDetails } from 'e2e/models/pages/ProjectDetails';
import { WorkspaceDetails } from 'e2e/models/pages/WorkspaceDetails';
import { WorkspaceProjects } from 'e2e/models/pages/WorkspaceDetails/WorkspaceProjects';
import { randId, safeName } from 'e2e/utils/naming';
import { V1Project } from 'services/api-ts-sdk';
import { V1PostProjectResponse, V1Project, V1Workspace } from 'services/api-ts-sdk';

const getCurrentProjectNames = async (workspaceProjects: WorkspaceProjects) => {
const getCurrentProjectCardNames = async (workspaceProjects: WorkspaceProjects) => {
await workspaceProjects.projectCards.pwLocator.nth(0).waitFor();

const cardTitles = await workspaceProjects.projectCards.title.pwLocator.all();
Expand All @@ -33,7 +33,7 @@ test.describe('Project UI CRUD', () => {
}
});

test('Create a Project', async ({ authedPage, newWorkspace }) => {
test.skip('Create a Project', async ({ authedPage, newWorkspace }) => {
const projectName = safeName('test-project');
const workspaceDetails = new WorkspaceDetails(authedPage);
const projectDetails = new ProjectDetails(authedPage);
Expand Down Expand Up @@ -61,7 +61,7 @@ test.describe('Project UI CRUD', () => {
});
});

test('Archive and Unarchive Project', async ({
test.skip('Archive and Unarchive Project', async ({
authedPage,
newWorkspace,
backgroundApiProject,
Expand Down Expand Up @@ -94,7 +94,7 @@ test.describe('Project UI CRUD', () => {
});
});

test('Move a Project', async ({
test.skip('Move a Project', async ({
authedPage,
newWorkspace,
backgroundApiWorkspace,
Expand Down Expand Up @@ -188,7 +188,7 @@ test.describe('Project List', () => {
const workspaceDetails = new WorkspaceDetails(authedPage);
const workspaceProjects = workspaceDetails.workspaceProjects;

const namesAfterNewest = await getCurrentProjectNames(workspaceProjects);
const namesAfterNewest = await getCurrentProjectCardNames(workspaceProjects);
const idSortedProjectNames = _.orderBy(projects, 'id', 'desc').map((p) => p.name);
expect(idSortedProjectNames).toEqual(
namesAfterNewest.filter((n) => {
Expand All @@ -198,7 +198,7 @@ test.describe('Project List', () => {

await workspaceProjects.sortSelect.selectMenuOption('Alphabetical');

const namesAfterAlphabetical = await getCurrentProjectNames(workspaceProjects);
const namesAfterAlphabetical = await getCurrentProjectCardNames(workspaceProjects);
const nameSortedProjectNames = _.orderBy(projects, 'name', 'asc').map((p) => p.name);
expect(nameSortedProjectNames).toEqual(
namesAfterAlphabetical.filter((n) => {
Expand All @@ -223,17 +223,17 @@ test.describe('Project List', () => {

await authedPage.reload();

const namesAfterAll = await getCurrentProjectNames(workspaceProjects);
const namesAfterAll = await getCurrentProjectCardNames(workspaceProjects);
expect(namesAfterAll).toContain(otherUserProjectName);
expect(namesAfterAll).toContain(currentUserProjectName);

await workspaceProjects.whoseSelect.selectMenuOption("Others' Projects");
const namesAfterOthers = await getCurrentProjectNames(workspaceProjects);
const namesAfterOthers = await getCurrentProjectCardNames(workspaceProjects);
expect(namesAfterOthers).toContain(otherUserProjectName);
expect(namesAfterOthers).not.toContain(currentUserProjectName);

await workspaceProjects.whoseSelect.selectMenuOption('My Projects');
const namesAfterMy = await getCurrentProjectNames(workspaceProjects);
const namesAfterMy = await getCurrentProjectCardNames(workspaceProjects);
expect(namesAfterMy).toContain(currentUserProjectName);
expect(namesAfterMy).not.toContain(otherUserProjectName);

Expand All @@ -255,4 +255,71 @@ test.describe('Project List', () => {
await firstRow.pwLocator.waitFor({ state: 'hidden' });
await firstCard.pwLocator.waitFor();
});

test.describe('List View', () => {
let newProject: V1PostProjectResponse;
let destinationWorkspace: V1Workspace;

test.beforeAll(async ({ newWorkspace, backgroundApiProject, backgroundApiWorkspace }) => {
newProject = await backgroundApiProject.createProject(
newWorkspace.response.workspace.id,
backgroundApiProject.new(),
);
destinationWorkspace = (
await backgroundApiWorkspace.createWorkspace(backgroundApiWorkspace.new())
).workspace;
});
test.beforeEach(async ({ authedPage }) => {
const workspaceDetails = new WorkspaceDetails(authedPage);

const workspaceProjects = workspaceDetails.workspaceProjects;

await workspaceProjects.gridListRadioGroup.list.pwLocator.click();
});
test.afterAll(async ({ backgroundApiWorkspace }) => {
await backgroundApiWorkspace.deleteWorkspace(destinationWorkspace.id);
});

test('move a project to a different workspace', async ({ authedPage }) => {
const workspaceDetails = new WorkspaceDetails(authedPage);
const workspaceProjects = workspaceDetails.workspaceProjects;

const projectsTable = workspaceProjects.table.table;

let newProjectRow = (
await projectsTable.filterRows(
async (row) => (await row.name.pwLocator.textContent()) === newProject.project.name,
)
)[0];

expect(await newProjectRow.name.pwLocator.innerText()).toBe(newProject.project.name);

const moveMenuItem = newProjectRow.action;

await moveMenuItem.open();
await moveMenuItem.move.pwLocator.click();
await workspaceProjects.moveModal.destinationWorkspace.pwLocator.fill(
destinationWorkspace.name,
);
await workspaceProjects.moveModal.destinationWorkspace.pwLocator.press('Enter');
await workspaceProjects.moveModal.footer.submit.pwLocator.click();

await workspaceProjects.moveModal.pwLocator.waitFor({ state: 'hidden' });
await newProjectRow.pwLocator.waitFor({ state: 'hidden' });

newProjectRow = (
await projectsTable.filterRows(
async (row) => (await row.name.pwLocator.textContent()) === newProject.project.name,
)
)[0];

await expect(newProjectRow).toBeUndefined();

await workspaceDetails.gotoWorkspace(destinationWorkspace.id);

const projectCard = workspaceProjects.cardByName(newProject.project.name);

await expect(projectCard.pwLocator).toBeVisible();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ const WorkspaceProjects: React.FC<Props> = ({ workspace, id, pageRef }) => {
defaultWidth: DEFAULT_COLUMN_WIDTHS['action'],
fixed: 'right',
key: 'action',
onCell: onRightClickableCell,
onCell: () => ({ ...onRightClickableCell(), 'data-testid': 'actionMenu' }),
render: actionRenderer,
title: '',
},
Expand Down
Loading