Merge branch 'main' of github.com:jcalixte/loopycode into main
This commit is contained in:
@@ -43,11 +43,11 @@
|
||||
"jsdom": "^21.1.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.8",
|
||||
"sass": "^1.62.0",
|
||||
"sass": "^1.62.1",
|
||||
"typescript": "~4.8.4",
|
||||
"vite": "^4.3.1",
|
||||
"vitest": "^0.30.1",
|
||||
"vue-tsc": "^1.4.4",
|
||||
"webdriverio": "^8.8.6"
|
||||
"webdriverio": "^8.8.8"
|
||||
}
|
||||
}
|
||||
4186
pnpm-lock.yaml
generated
4186
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,17 @@
|
||||
import { createTaskFixture } from '@/modules/task/models/task.fixture'
|
||||
import { fixtureTask } from '@/modules/task/models/task.fixture'
|
||||
import { router } from '@/router'
|
||||
import { toISODate } from '@/shared/types/date'
|
||||
import { withPlugins } from '@/tests/utils'
|
||||
import { faker } from '@faker-js/faker'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { createRecordableFixture } from '../interfaces/recordable.fixture'
|
||||
import { fixtureRecordable } from '../interfaces/recordable.fixture'
|
||||
import TaskRecordPreview from './TaskRecordPreview.vue'
|
||||
|
||||
const mountTaskRecordPreview = (withRecord = false) => {
|
||||
const task = createTaskFixture()
|
||||
const task = fixtureTask()
|
||||
const end = toISODate(new Date('2023-04-17T20:00:00.000Z'))
|
||||
const record = createRecordableFixture({
|
||||
const record = fixtureRecordable({
|
||||
taskId: task.id,
|
||||
stepRecords: {
|
||||
[faker.datatype.uuid()]: {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { toISODate } from '@/shared/types/date'
|
||||
import { faker } from '@faker-js/faker'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { ref } from 'vue'
|
||||
import { createRecordableFixture } from '../interfaces/recordable.fixture'
|
||||
import { fixtureRecordable } from '../interfaces/recordable.fixture'
|
||||
import { TaskRecord } from '../models/task-record'
|
||||
import { useTaskRecordMetadata } from './useTaskRecordMetadata'
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('use task record metadata', () => {
|
||||
|
||||
it('returns the right duration', () => {
|
||||
const end = toISODate(new Date('2023-04-17T20:00:00.000Z'))
|
||||
const record = createRecordableFixture({
|
||||
const record = fixtureRecordable({
|
||||
stepRecords: {
|
||||
[faker.datatype.uuid()]: {
|
||||
start: toISODate(new Date('2023-04-17T19:00:00.000Z')),
|
||||
|
||||
@@ -2,7 +2,7 @@ import { toISODate } from '@/shared/types/date'
|
||||
import { faker } from '@faker-js/faker'
|
||||
import type { Recordable } from './recordable'
|
||||
|
||||
export const createRecordableFixture = (
|
||||
export const fixtureRecordable = (
|
||||
partialRecordable?: Partial<Recordable>
|
||||
): Recordable => ({
|
||||
taskId: partialRecordable?.taskId ?? faker.datatype.uuid(),
|
||||
|
||||
18
src/modules/record/interfaces/time-range.fixture.ts
Normal file
18
src/modules/record/interfaces/time-range.fixture.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { toISODate } from '@/shared/types/date'
|
||||
import { faker } from '@faker-js/faker'
|
||||
import type { TimeRange } from './time-range'
|
||||
|
||||
export const fixtureTimeRange = (
|
||||
partialTimeRange?: Partial<TimeRange>
|
||||
): TimeRange => {
|
||||
const [start, end] = faker.date.betweens(
|
||||
toISODate(faker.date.past(1)),
|
||||
toISODate(new Date()),
|
||||
2
|
||||
)
|
||||
|
||||
return {
|
||||
start: partialTimeRange?.start ?? toISODate(start),
|
||||
end: partialTimeRange?.end ?? toISODate(end)
|
||||
}
|
||||
}
|
||||
23
src/modules/record/models/task-record.test.ts
Normal file
23
src/modules/record/models/task-record.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { toISODate } from '@/shared/types/date'
|
||||
import { faker } from '@faker-js/faker'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { Recordable } from '../interfaces/recordable'
|
||||
import { fixtureTimeRange } from '../interfaces/time-range.fixture'
|
||||
import { TaskRecord } from './task-record'
|
||||
|
||||
describe('Task Record', () => {
|
||||
it('creates a Record from a Recordable', () => {
|
||||
const recordable: Recordable = {
|
||||
taskId: faker.datatype.uuid(),
|
||||
notes: faker.lorem.paragraphs(),
|
||||
start: toISODate(faker.date.past(1)),
|
||||
end: toISODate(faker.date.past()),
|
||||
breakTime: fixtureTimeRange(),
|
||||
stepRecords: {
|
||||
[faker.datatype.uuid()]: fixtureTimeRange()
|
||||
}
|
||||
}
|
||||
|
||||
expect(TaskRecord.fromRecordable(recordable)).toEqual(recordable)
|
||||
})
|
||||
})
|
||||
@@ -22,6 +22,7 @@ export class TaskRecord implements Recordable {
|
||||
taskRecord.start = recordable.start
|
||||
taskRecord.end = recordable.end
|
||||
taskRecord.breakTime = recordable.breakTime
|
||||
taskRecord.notes = recordable.notes
|
||||
|
||||
return taskRecord
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { toISODate } from '@/shared/types/date'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createRecordableFixture } from '../interfaces/recordable.fixture'
|
||||
import { fixtureRecordable } from '../interfaces/recordable.fixture'
|
||||
import { addBreakTimeToStepRecords } from './breaktime-service'
|
||||
|
||||
describe('Break Time Service', () => {
|
||||
it('adds no break time if there is no break time', () => {
|
||||
const record = createRecordableFixture({
|
||||
const record = fixtureRecordable({
|
||||
breakTime: undefined
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('Break Time Service', () => {
|
||||
})
|
||||
|
||||
it('adds no break time if the break is not over yet', () => {
|
||||
const record = createRecordableFixture({
|
||||
const record = fixtureRecordable({
|
||||
breakTime: {
|
||||
start: toISODate(new Date('2023-04-17T19:00:00.000Z'))
|
||||
},
|
||||
@@ -28,7 +28,7 @@ describe('Break Time Service', () => {
|
||||
})
|
||||
|
||||
it('adds break time if break time is over', () => {
|
||||
const record = createRecordableFixture({
|
||||
const record = fixtureRecordable({
|
||||
breakTime: {
|
||||
start: toISODate(new Date('2023-04-17T19:00:00.000Z')),
|
||||
end: toISODate(new Date('2023-04-17T20:00:00.000Z'))
|
||||
@@ -51,7 +51,7 @@ describe('Break Time Service', () => {
|
||||
})
|
||||
|
||||
it('adds break time only for unfinished step records', () => {
|
||||
const record = createRecordableFixture({
|
||||
const record = fixtureRecordable({
|
||||
breakTime: {
|
||||
start: toISODate(new Date('2023-04-17T19:00:00.000Z')),
|
||||
end: toISODate(new Date('2023-04-17T20:00:00.000Z'))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createStepFixture } from '../models/step.fixture'
|
||||
import { fixtureStep } from '../models/step.fixture'
|
||||
import StepInput from './StepInput.vue'
|
||||
|
||||
describe('Step input textarea', () => {
|
||||
@@ -15,11 +15,7 @@ describe('Step input textarea', () => {
|
||||
})
|
||||
|
||||
it('displays the steps in the textarea', () => {
|
||||
const steps = [
|
||||
createStepFixture(),
|
||||
createStepFixture(),
|
||||
createStepFixture()
|
||||
]
|
||||
const steps = [fixtureStep(), fixtureStep(), fixtureStep()]
|
||||
|
||||
const stepsInTextarea = steps
|
||||
.map((s) => `- ${s.title} | ${s.estimation}`)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createStepFixture } from '../models/step.fixture'
|
||||
import { fixtureStep } from '../models/step.fixture'
|
||||
import {
|
||||
adaptStepsToTextarea,
|
||||
adaptTextareaToSteps
|
||||
@@ -7,12 +7,7 @@ import {
|
||||
|
||||
describe('adapt steps to textarea value', () => {
|
||||
it('returns a string with the listed steps', () => {
|
||||
const steps = [
|
||||
createStepFixture(),
|
||||
createStepFixture(),
|
||||
createStepFixture(),
|
||||
createStepFixture()
|
||||
]
|
||||
const steps = [fixtureStep(), fixtureStep(), fixtureStep(), fixtureStep()]
|
||||
|
||||
const stepsInTextarea = steps
|
||||
.map((step) => `- ${step.title} | ${step.estimation}`)
|
||||
@@ -27,17 +22,17 @@ describe('adapt steps to textarea value', () => {
|
||||
- step 3 | 5`
|
||||
|
||||
const expectedSteps = [
|
||||
createStepFixture({
|
||||
fixtureStep({
|
||||
id: expect.any(String),
|
||||
title: 'step 1',
|
||||
estimation: 3
|
||||
}),
|
||||
createStepFixture({
|
||||
fixtureStep({
|
||||
id: expect.any(String),
|
||||
title: 'step 2',
|
||||
estimation: 4
|
||||
}),
|
||||
createStepFixture({
|
||||
fixtureStep({
|
||||
id: expect.any(String),
|
||||
title: 'step 3',
|
||||
estimation: 5
|
||||
@@ -50,7 +45,7 @@ describe('adapt steps to textarea value', () => {
|
||||
it('fallbacks to 0 for the estimation if there is no estimation', () => {
|
||||
const stepInTextarea = '- step 1'
|
||||
|
||||
const expectedStep = createStepFixture({
|
||||
const expectedStep = fixtureStep({
|
||||
id: expect.any(String),
|
||||
title: 'step 1',
|
||||
estimation: 0
|
||||
@@ -62,7 +57,7 @@ describe('adapt steps to textarea value', () => {
|
||||
it('fallbacks to 0 for the estimation if it can not read the number', () => {
|
||||
const stepInTextarea = '- step 1 | not an estimation'
|
||||
|
||||
const expectedStep = createStepFixture({
|
||||
const expectedStep = fixtureStep({
|
||||
id: expect.any(String),
|
||||
title: 'step 1',
|
||||
estimation: 0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Stepable } from '@/modules/task/interfaces/stepable'
|
||||
import { faker } from '@faker-js/faker'
|
||||
|
||||
export const createStepFixture = (partialStep?: Partial<Stepable>) => ({
|
||||
export const fixtureStep = (partialStep?: Partial<Stepable>) => ({
|
||||
id: partialStep?.id ?? faker.datatype.uuid(),
|
||||
title: partialStep?.title ?? faker.animal.bird(),
|
||||
estimation:
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { faker } from '@faker-js/faker'
|
||||
import type { Stepable } from '../interfaces/stepable'
|
||||
import type { Taskable } from '../interfaces/taskable'
|
||||
import { createStepFixture } from './step.fixture'
|
||||
import { fixtureStep } from './step.fixture'
|
||||
import { Task } from './task'
|
||||
|
||||
export const createTaskFixture = (
|
||||
export const fixtureTask = (
|
||||
partialTask?: Partial<Taskable>,
|
||||
...steps: Stepable[]
|
||||
) =>
|
||||
new Task(
|
||||
partialTask?.id ?? faker.datatype.uuid(),
|
||||
partialTask?.title ?? faker.animal.bird()
|
||||
).addSteps(...(steps ?? createStepFixture()))
|
||||
).addSteps(...(steps ?? fixtureStep()))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Taskable } from '@/modules/task/interfaces/taskable'
|
||||
import { createStepFixture } from '@/modules/task/models/step.fixture'
|
||||
import { fixtureStep } from '@/modules/task/models/step.fixture'
|
||||
import { Task } from '@/modules/task/models/task'
|
||||
import { toISODate } from '@/shared/types/date'
|
||||
import { faker } from '@faker-js/faker'
|
||||
@@ -20,7 +20,7 @@ describe('Task', () => {
|
||||
date: toISODate(faker.date.recent()),
|
||||
title: faker.animal.lion(),
|
||||
link: faker.internet.url(),
|
||||
steps: [createStepFixture()]
|
||||
steps: [fixtureStep()]
|
||||
}
|
||||
const task = Task.fromTaskable(taskable)
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('Task', () => {
|
||||
it('adds steps and removes them', () => {
|
||||
const task = new Task(faker.datatype.uuid(), faker.color.human())
|
||||
|
||||
const [firstStep, secondStep] = [createStepFixture(), createStepFixture()]
|
||||
const [firstStep, secondStep] = [fixtureStep(), fixtureStep()]
|
||||
|
||||
task.addSteps(firstStep, secondStep)
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('Task', () => {
|
||||
const task = new Task(faker.datatype.uuid(), faker.color.human())
|
||||
expect(Task.validate(task)).toEqual(false)
|
||||
|
||||
task.addSteps(createStepFixture())
|
||||
task.addSteps(fixtureStep())
|
||||
expect(Task.validate(task)).toEqual(true)
|
||||
})
|
||||
|
||||
@@ -55,9 +55,9 @@ describe('Task', () => {
|
||||
const task = new Task(faker.datatype.uuid(), faker.color.human())
|
||||
|
||||
task.addSteps(
|
||||
createStepFixture({ estimation: 1 }),
|
||||
createStepFixture({ estimation: 2 }),
|
||||
createStepFixture({ estimation: 3 })
|
||||
fixtureStep({ estimation: 1 }),
|
||||
fixtureStep({ estimation: 2 }),
|
||||
fixtureStep({ estimation: 3 })
|
||||
)
|
||||
|
||||
expect(task.totalEstimation).toEqual(6)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { TaskRecordStoreState } from '@/modules/record/stores/useTaskRecordStore'
|
||||
import { createTaskFixture } from '@/modules/task/models/task.fixture'
|
||||
import { fixtureTask } from '@/modules/task/models/task.fixture'
|
||||
import type { TaskStoreState } from '@/modules/task/stores/useTask.store'
|
||||
import { router } from '@/router'
|
||||
import { toISODate } from '@/shared/types/date'
|
||||
@@ -12,7 +12,7 @@ export interface InitialState {
|
||||
'task-record-store': TaskRecordStoreState
|
||||
}
|
||||
|
||||
const tasks = [createTaskFixture(), createTaskFixture()]
|
||||
const tasks = [fixtureTask(), fixtureTask()]
|
||||
const [firstTask, secondTask] = tasks
|
||||
|
||||
const initialState: InitialState = {
|
||||
|
||||
Reference in New Issue
Block a user