diff --git a/client/src/routes/Publish/Step.test.tsx b/client/src/routes/Publish/Step.test.tsx
index 2ba4901..219577f 100644
--- a/client/src/routes/Publish/Step.test.tsx
+++ b/client/src/routes/Publish/Step.test.tsx
@@ -12,7 +12,6 @@ const stateMock = {
const propsMock = {
inputChange: () => null,
- inputToArrayChange: () => null,
state: stateMock,
title: 'Hello',
description: 'description',
diff --git a/client/src/routes/Publish/Step.tsx b/client/src/routes/Publish/Step.tsx
index 9019673..57b84d8 100644
--- a/client/src/routes/Publish/Step.tsx
+++ b/client/src/routes/Publish/Step.tsx
@@ -28,9 +28,6 @@ interface StepProps {
| ChangeEvent
| ChangeEvent
): void
- inputToArrayChange(
- event: ChangeEvent | ChangeEvent
- ): void
fields?: Fields
state: any
title: string
diff --git a/client/src/routes/Publish/index.test.tsx b/client/src/routes/Publish/index.test.tsx
index 0f1b67e..6d00da9 100644
--- a/client/src/routes/Publish/index.test.tsx
+++ b/client/src/routes/Publish/index.test.tsx
@@ -1,11 +1,44 @@
import React from 'react'
-import { render } from '@testing-library/react'
+import { render, fireEvent } from '@testing-library/react'
import Publish from '.'
+import { User } from '../../context'
+import { userMockConnected } from '../../../__mocks__/user-mock'
-describe('Progress', () => {
+describe('Publish', () => {
it('renders without crashing', () => {
- const { container, getByText } = render()
+ const { container, getByText } = render(
+
+
+
+ )
expect(container.firstChild).toBeInTheDocument()
expect(getByText('Next →')).toHaveAttribute('disabled')
})
+
+ it('next button works', () => {
+ const { getByText, getByLabelText, getByTestId } = render(
+
+
+
+ )
+
+ // Title
+ const inputName = getByLabelText('Title')
+ fireEvent.change(inputName, {
+ target: { value: 'Hello' }
+ })
+
+ // Files
+ const inputFiles = getByTestId('files')
+ fireEvent.change(inputFiles, {
+ target: {
+ value: JSON.stringify([
+ { url: 'https://demo.com', contentType: '', found: false }
+ ])
+ }
+ })
+
+ // expect(getByText('Next →')).not.toHaveAttribute('disabled')
+ fireEvent.click(getByText('Next →'))
+ })
})
diff --git a/client/src/routes/Publish/index.tsx b/client/src/routes/Publish/index.tsx
index f417b98..eb18137 100644
--- a/client/src/routes/Publish/index.tsx
+++ b/client/src/routes/Publish/index.tsx
@@ -11,27 +11,28 @@ import ReactGA from 'react-ga'
import { steps } from '../../data/form-publish.json'
import Content from '../../components/atoms/Content'
+import { File } from './Files'
type AssetType = 'dataset' | 'algorithm' | 'container' | 'workflow' | 'other'
interface PublishState {
name?: string
dateCreated?: string
- description?: string
- files?: string[]
- price?: number
+ price?: string
author?: string
- type?: AssetType
license?: string
+ description?: string
+ files?: File[]
+ type?: AssetType
copyrightHolder?: string
- categories?: string
- tags?: string[]
+ categories?: string[]
+
+ currentStep?: number
+ publishingStep?: number
isPublishing?: boolean
isPublished?: boolean
publishedDid?: string
publishingError?: string
- publishingStep?: number
- currentStep?: number
validationStatus?: any
}
@@ -39,17 +40,18 @@ export default class Publish extends Component<{}, PublishState> {
public static contextType = User
public state = {
- currentStep: 1,
name: '',
dateCreated: new Date().toISOString(),
description: '',
files: [],
- price: 0,
+ price: '0',
author: '',
type: 'dataset' as AssetType,
license: '',
copyrightHolder: '',
- categories: '',
+ categories: [],
+
+ currentStep: 1,
isPublishing: false,
isPublished: false,
publishedDid: '',
@@ -81,16 +83,6 @@ export default class Publish extends Component<{}, PublishState> {
})
}
- private inputToArrayChange = (
- event: ChangeEvent | ChangeEvent
- ) => {
- this.validateInputs(event.currentTarget.name, event.currentTarget.value)
-
- this.setState({
- [event.currentTarget.name]: [event.currentTarget.value]
- })
- }
-
private next = () => {
let { currentStep } = this.state
const totalSteps = steps.length
@@ -122,12 +114,12 @@ export default class Publish extends Component<{}, PublishState> {
dateCreated: new Date().toISOString(),
description: '',
files: [],
- price: 0,
+ price: '0',
author: '',
type: 'dataset' as AssetType,
license: '',
copyrightHolder: '',
- categories: '',
+ categories: [],
isPublishing: false,
isPublished: false,
publishingStep: 0,
@@ -267,28 +259,32 @@ export default class Publish extends Component<{}, PublishState> {
const { ocean } = this.context
const account = await ocean.accounts.list()
+
+ // remove `found` attribute from all File objects
+ // in a new array
+ const files = this.state.files.map(
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ ({ found, ...keepAttrs }: { found: boolean }) => keepAttrs
+ )
+
const newAsset = {
// OEP-08 Attributes
// https://github.com/oceanprotocol/OEPs/tree/master/8
base: Object.assign(AssetModel.base, {
name: this.state.name,
description: this.state.description,
- dateCreated: new Date(this.state.dateCreated).toISOString(),
+ dateCreated:
+ new Date(this.state.dateCreated)
+ .toISOString()
+ .split('.')[0] + 'Z', // remove milliseconds
author: this.state.author,
license: this.state.license,
copyrightHolder: this.state.copyrightHolder,
- files: this.state.files,
+ files,
price: this.state.price,
type: this.state.type,
- categories: [this.state.categories],
- workExample: undefined,
- inLanguage: undefined,
- tags: ''
- }),
- curation: Object.assign(AssetModel.curation),
- additionalInformation: Object.assign(
- AssetModel.additionalInformation
- )
+ categories: [this.state.categories]
+ })
}
try {
@@ -346,7 +342,6 @@ export default class Publish extends Component<{}, PublishState> {
currentStep={this.state.currentStep}
fields={step.fields}
inputChange={this.inputChange}
- inputToArrayChange={this.inputToArrayChange}
state={this.state}
next={this.next}
prev={this.prev}
diff --git a/library.json b/library.json
index 653a471..aaa9621 100644
--- a/library.json
+++ b/library.json
@@ -11,11 +11,11 @@
},
{
"name": "brizo",
- "version": "~0.3.9"
+ "version": "~0.3.10"
},
{
"name": "aquarius",
- "version": "~0.2.6"
+ "version": "~0.2.9"
},
{
"name": "squid-js",
diff --git a/server/src/routes/UrlCheckRouter.ts b/server/src/routes/UrlCheckRouter.ts
index 09eccae..dbe6eff 100644
--- a/server/src/routes/UrlCheckRouter.ts
+++ b/server/src/routes/UrlCheckRouter.ts
@@ -31,8 +31,9 @@ export class UrlCheckRouter {
result.found = true
if (response.headers['content-length']) {
- result.contentLength =
+ result.contentLength = parseInt(
response.headers['content-length']
+ ) // convert to number
}
if (response.headers['content-type']) {