chore: remove the option to trigger transition from the UI (#2489)

This commit is contained in:
Karol Sójko
2023-09-12 09:25:05 +02:00
committed by GitHub
parent e50cc591c0
commit d6a3e69d8c
14 changed files with 1 additions and 251 deletions

View File

@@ -1,34 +0,0 @@
import { HttpServiceInterface } from '@standardnotes/api'
import { GetTransitionStatus } from './GetTransitionStatus'
describe('GetTransitionStatus', () => {
let httpService: HttpServiceInterface
const createUseCase = () => new GetTransitionStatus(httpService)
beforeEach(() => {
httpService = {
get: jest.fn(),
} as unknown as HttpServiceInterface
})
it('should get transition status', async () => {
const useCase = createUseCase()
;(httpService.get as jest.Mock).mockResolvedValueOnce({ status: 200, data: { status: 'TO-DO' } })
const result = await useCase.execute()
expect(result.isFailed()).toBe(false)
expect(result.getValue()).toBe('TO-DO')
})
it('should fail to get transition status', async () => {
const useCase = createUseCase()
;(httpService.get as jest.Mock).mockResolvedValueOnce({ status: 400 })
const result = await useCase.execute()
expect(result.isFailed()).toBe(true)
})
})

View File

@@ -1,17 +0,0 @@
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
import { HttpServiceInterface } from '@standardnotes/api'
import { HttpStatusCode } from '@standardnotes/responses'
export class GetTransitionStatus implements UseCaseInterface<'TO-DO' | 'STARTED' | 'FINISHED' | 'FAILED'> {
constructor(private httpService: HttpServiceInterface) {}
async execute(): Promise<Result<'TO-DO' | 'STARTED' | 'FINISHED' | 'FAILED'>> {
const response = await this.httpService.get('/v1/users/transition-status')
if (response.status !== HttpStatusCode.Success) {
return Result.fail('Failed to get transition status')
}
return Result.ok((response.data as { status: 'TO-DO' | 'STARTED' | 'FINISHED' | 'FAILED' }).status)
}
}

View File

@@ -1,33 +0,0 @@
import { HttpServiceInterface } from '@standardnotes/api'
import { StartTransition } from './StartTransition'
describe('StartTransition', () => {
let httpService: HttpServiceInterface
const createUseCase = () => new StartTransition(httpService)
beforeEach(() => {
httpService = {
post: jest.fn(),
} as unknown as HttpServiceInterface
})
it('should start transition', async () => {
const useCase = createUseCase()
;(httpService.post as jest.Mock).mockResolvedValueOnce({ status: 200 })
const result = await useCase.execute()
expect(result.isFailed()).toBe(false)
})
it('should fail to start transition', async () => {
const useCase = createUseCase()
;(httpService.post as jest.Mock).mockResolvedValueOnce({ status: 400 })
const result = await useCase.execute()
expect(result.isFailed()).toBe(true)
})
})

View File

@@ -1,17 +0,0 @@
import { HttpServiceInterface } from '@standardnotes/api'
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
import { HttpStatusCode } from '@standardnotes/responses'
export class StartTransition implements UseCaseInterface<void> {
constructor(private httpService: HttpServiceInterface) {}
async execute(): Promise<Result<void>> {
const response = await this.httpService.post('/v1/items/transition')
if (response.status !== HttpStatusCode.Success) {
return Result.fail('Failed to start transition')
}
return Result.ok()
}
}