Skip to content

Commit

Permalink
feat(FilePage): add datasetVersion property to File model
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Dec 18, 2023
1 parent 030b794 commit 3d4c78a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/files/domain/models/File.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { DatasetVersion } from '../../../dataset/domain/models/Dataset'

export interface File {
name: string
datasetTitle: string
datasetVersion: DatasetVersion
}
2 changes: 1 addition & 1 deletion src/sections/file/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function File({ repository, id }: FileProps) {
<header className={styles.header}>
<h1>{file.name}</h1>
<span className={styles.subtext}>
{t('subtext', { datasetTitle: file.datasetTitle })}
{t('subtext', { datasetTitle: file.datasetVersion.title })}
</span>
</header>
<div className={styles.container}>
Expand Down
5 changes: 3 additions & 2 deletions tests/component/files/domain/models/FileMother.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { File } from '../../../../../src/files/domain/models/File'
import { faker } from '@faker-js/faker'
import { DatasetVersionMother } from '../../../dataset/domain/models/DatasetMother'

export class FileMother {
static create(props?: Partial<File>): File {
return {
name: faker.system.fileName(),
datasetTitle: faker.lorem.words(3),
datasetVersion: DatasetVersionMother.create(),
...props
}
}

static createRealistic(props?: Partial<File>): File {
return this.create({
name: 'file.csv',
datasetTitle: 'Dataset title',
datasetVersion: DatasetVersionMother.createRealistic(),
...props
})
}
Expand Down
2 changes: 1 addition & 1 deletion tests/component/sections/file/File.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('File', () => {
cy.wrap(fileRepository.getById).should('be.calledWith', 19)

cy.findAllByText(testFile.name).should('exist')
cy.findByText(`This file is part of "${testFile.datasetTitle}".`).should('exist')
cy.findByText(`This file is part of "${testFile.datasetVersion.title}".`).should('exist')
})

it('renders skeleton while loading', () => {
Expand Down

0 comments on commit 3d4c78a

Please sign in to comment.