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: map project owners to projects list #6928

Merged
merged 2 commits into from
Apr 25, 2024
Merged

Conversation

Tymek
Copy link
Member

@Tymek Tymek commented Apr 25, 2024

About the changes

Follow-up for #6916

  • Combining list of projects with owners
  • Additional tests and checks

Internal ticket: https://linear.app/unleash/issue/1-2320/project-owners-mapping

Copy link

vercel bot commented Apr 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2024 9:22am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Apr 25, 2024 9:22am

@Tymek Tymek marked this pull request as ready for review April 25, 2024 08:23
src/lib/features/project/project-owners-read-model.ts Outdated Show resolved Hide resolved
Comment on lines 20 to 55
describe('unit tests', () => {
test('maps owners to projects', () => {});
test('maps owners to projects', () => {
const projects = [{ name: 'project1' }, { name: 'project2' }] as any;

const owners = {
project1: [{ ownerType: 'user' as const, name: 'Owner Name' }],
project2: [{ ownerType: 'user' as const, name: 'Owner Name' }],
};

const projectsWithOwners = ProjectOwnersReadModel.addOwnerData(
projects,
owners,
);

expect(projectsWithOwners).toMatchObject([
{ name: 'project1', owners: [{ name: 'Owner Name' }] },
{ name: 'project2', owners: [{ name: 'Owner Name' }] },
]);
});

test('returns "system" when a project has no owners', async () => {
// this is a mapping test; not an integration test
const projects = [{ name: 'project1' }, { name: 'project2' }] as any;

const owners = {};

const projectsWithOwners = ProjectOwnersReadModel.addOwnerData(
projects,
owners,
);

expect(projectsWithOwners).toMatchObject([
{ name: 'project1', owners: [{ ownerType: 'system' }] },
{ name: 'project2', owners: [{ ownerType: 'system' }] },
]);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be done later, but I think we should put the unit tests in a separate file? So we'll probably have project-owners-read-model.test.ts and project-owners-read-model.integration.test.ts. Feels like it jives better with what we're doing most the time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have 3 types that correlate better to methods under test then to any specific test type. I think we can just describe what part of the class we are testing instead of moving it to a separate file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough 💁🏼

src/lib/features/project/project-owners-read-model.test.ts Outdated Show resolved Hide resolved
src/lib/features/project/project-owners-read-model.test.ts Outdated Show resolved Hide resolved
src/lib/features/project/project-owners-read-model.test.ts Outdated Show resolved Hide resolved
@Tymek Tymek merged commit 34c1da5 into main Apr 25, 2024
12 of 13 checks passed
@Tymek Tymek deleted the feat/project-owner-mapping branch April 25, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants