Skip to content

Commit

Permalink
refactor: 🗃️ drop null values on project description
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudTA authored and clairenollet committed Jul 26, 2024
1 parent 70945f7 commit 11c6480
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions apps/client/cypress/e2e/specs/admin/projects.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ describe('Administration projects', () => {
cy.getByDataTestid('description').invoke('text').then((text) => {
const maxDescriptionlength = 60
if (text?.length > maxDescriptionlength) {
const lastSpaceIndex = project.description?.slice(0, maxDescriptionlength).lastIndexOf(' ')
const truncatedDescription = project.description?.slice(0, lastSpaceIndex > 0 ? lastSpaceIndex : maxDescriptionlength)
const lastSpaceIndex = project.description.slice(0, maxDescriptionlength).lastIndexOf(' ')
const truncatedDescription = project.description.slice(0, lastSpaceIndex > 0 ? lastSpaceIndex : maxDescriptionlength)
expect(text).to.equal(truncatedDescription + ' ...')
} else {
expect(text).to.equal(project.description ?? '')
expect(text).to.equal(project.description)
}
})
cy.get('td:nth-of-type(4)').should('contain', project.members.find(m => m.role === 'owner').email)
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/views/admin/ListProjects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ const untruncateDescription = (span: HTMLElement) => {
<div v-else>
<DsfrCallout
:title="selectedProject.name"
:content="selectedProject.description ?? ''"
:content="selectedProject.description"
/>
<div class="w-full flex gap-4 fr-mb-2w">
<DsfrButton
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Warnings:
- Made the column `description` on table `Project` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "Project" ALTER COLUMN "description" SET NOT NULL,
ALTER COLUMN "description" SET DEFAULT '';
2 changes: 1 addition & 1 deletion apps/server/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ model Project {
id String @id @unique @default(uuid()) @db.Uuid
name String
organizationId String @db.Uuid
description String?
description String @default("")
status ProjectStatus @default(initializing)
locked Boolean @default(false)
createdAt DateTime @default(now())
Expand Down
3 changes: 0 additions & 3 deletions apps/server/src/resources/project/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export const listProjects = async ({ status, statusIn, statusNotIn, filter = 'me
}).then(projects => projects
.map(({ clusters, roles, ...project }) => ({
...project,
description: project.description ?? '',
clusterIds: clusters.map(({ id }) => id),
members: rolesToMembers(roles),
})))
Expand Down Expand Up @@ -164,7 +163,6 @@ export const createProject = async (dataDto: CreateProjectBody, requestor: UserD

return {
...projectInfos,
description: projectInfos.description ?? '',
clusterIds: projectInfos.clusters.map(({ id }) => id),
members: rolesToMembers(projectInfos.roles),
}
Expand Down Expand Up @@ -203,7 +201,6 @@ export const updateProject = async (data: UpdateProjectBody, projectId: Project[

return {
...projectInfos,
description: projectInfos.description ?? '',
clusterIds: projectInfos.clusters.map(({ id }) => id),
members: rolesToMembers(projectInfos.roles),
}
Expand Down
8 changes: 4 additions & 4 deletions packages/test-utils/src/imports/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const data = {
id: '22e7044f-8414-435d-9c4a-2df42a65034b',
name: 'betaapp',
organizationId: '2368a61e-f243-42f6-b471-a85b056ee131',
description: null,
description: '',
status: 'created',
locked: false,
createdAt: '2023-07-03T14:46:56.814Z',
Expand All @@ -43,7 +43,7 @@ export const data = {
id: '9dabf3f9-6c86-4358-8598-65007d78df65',
name: 'projecttoarchive',
organizationId: '2368a61e-f243-42f6-b471-a85b056ee131',
description: null,
description: '',
status: 'created',
locked: false,
createdAt: '2023-07-03T14:46:56.824Z',
Expand Down Expand Up @@ -628,7 +628,7 @@ export const data = {
project: 'int-2',
createdAt: '2023-06-08T15:14:53.517Z',
updatedAt: '2023-06-08T15:14:53.517Z',
description: null,
description: '',
organization: 'mi',
},
nexus: {
Expand Down Expand Up @@ -766,7 +766,7 @@ export const data = {
project: 'int-2',
createdAt: '2023-06-08T15:14:53.517Z',
updatedAt: '2023-06-08T15:16:49.011Z',
description: null,
description: '',
organization: 'mi',
},
nexus: {
Expand Down

0 comments on commit 11c6480

Please sign in to comment.