Skip to content

chore: routingform org attribute seed#17510

Merged
keithwillcode merged 15 commits intomainfrom
feat/routingform-org-attribute-seed
Nov 14, 2024
Merged

chore: routingform org attribute seed#17510
keithwillcode merged 15 commits intomainfrom
feat/routingform-org-attribute-seed

Conversation

@sean-brydon
Copy link
Copy Markdown
Member

What does this PR do?

This PR adds a way to seed a organization with routing forms and attirbutes.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Reset your DB.
Run migrations
Run yarn seed (This should create an acme organization with now 10 users to make this a bit easier - you can change this value if you want more users in your org).
Run yarn seed-insights - This will seed the "Acme" org with a bunch of data. Previous bookings, Teams, Routing forms and attributes

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 6, 2024

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

Unknown release type "core" found in pull request title "core: routingform org attribute seed". 

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@dosubot dosubot Bot added organizations area: organizations, orgs routing-forms area: routing forms, routing, forms labels Nov 6, 2024
@keithwillcode keithwillcode added consumer core area: core, team members only labels Nov 6, 2024
@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 6, 2024

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

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Nov 14, 2024 4:27pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Nov 14, 2024 4:27pm

@graphite-app graphite-app Bot requested a review from a team November 6, 2024 11:40
Comment thread yourProjectName.inlang/.gitignore Outdated
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will remove

Comment thread packages/prisma/seed.ts
],
},
{
...Array.from({ length: 10 }, (_, i) => ({
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Creates 10 members . Feel free to change length to anything you want to test orgs


const attributeRaw: { id: string; options: { id: string; value: string }[] }[] = [];

for (const attr of mockAttributes) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Assign users random attributes

Comment on lines +434 to +441
{
id: "8a898988-89ab-4cde-b012-31823f708642",
value: "team/insights-team/team-javascript",
},
{
id: "8b2224b2-89ab-4cde-b012-31823f708642",
value: "team/insights-team/team-sales",
},
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Key info needed that can't change as its used in routingFormResponses

},
],
formFieldFilled: {
id: "83316968-45bf-4c9d-b5d4-5368a8d2d2a8",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This formField that is filled when the users previews the attribute

Comment on lines +458 to +460
if (attributeRaw.length === 0) {
throw new Error("No attributes found - Please call seedAttributes first");
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Make this dependant on attributes

properties: {
field: attributeRaw[2].id,
value: [
attributeRaw[2].options.filter((opt) => opt.value === "JavaScript").map((opt) => opt.id),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This currently relys on the set attributeArray being passed in. Down the line we can make this more flexible of a factory if we really need

],
fields: [
{
id: seededForm.formFieldFilled.id,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The field ID we use to fill in the form

Comment on lines +544 to +547
options: attributeRaw[2].options.map((opt) => ({
id: opt.id,
label: opt.value,
})),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Make sure options and id are the same so we can link to responses

Comment thread packages/prisma/seed-utils.ts Outdated
response: {
[seededForm.formFieldFilled.id]: {
label: "skills",
value: selectedSkills.map((opt) => opt.id),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can pass multiple responses in here Note: These responses may not match the rules that are created. They are just for visual and display purposes for insights.

@sean-brydon sean-brydon changed the title core: routingform org attribute seed chore: routingform org attribute seed Nov 6, 2024
},
});

if (!insightsAdmin) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note we may need to add this user back. I'm pretty sure it is used in a e2e test. Will check just wanted to get this out for early reviews

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Nov 6, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (11/06/24)

1 reviewer was added to this PR based on Keith Williams's automation.

@hariombalhara
Copy link
Copy Markdown
Member

Works great !!

@PeerRich
Copy link
Copy Markdown
Member

PeerRich commented Nov 8, 2024

test failing @sean-brydon image

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 11, 2024

E2E results are ready!

where: { email: "member2-acme@example.com" },
});

expect(accessibleUserIds.length).toBe(3);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Matches new count

@keithwillcode keithwillcode merged commit 12c5005 into main Nov 14, 2024
@keithwillcode keithwillcode deleted the feat/routingform-org-attribute-seed branch November 14, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer core area: core, team members only organizations area: organizations, orgs ready-for-e2e routing-forms area: routing forms, routing, forms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants