Sort index views by id
This commit is contained in:
@@ -86,7 +86,10 @@ const errorMessage = ref('');
|
|||||||
// Initialize currentView from the store's default setting for asistencias
|
// Initialize currentView from the store's default setting for asistencias
|
||||||
const currentView = ref(ui.defaultViewAsistencias);
|
const currentView = ref(ui.defaultViewAsistencias);
|
||||||
|
|
||||||
const asistenciasList = computed(() => asistenciasStore.asistencias);
|
// Show asistencias ordered by id descending
|
||||||
|
const asistenciasList = computed(() =>
|
||||||
|
[...(asistenciasStore.asistencias || [])].sort((a, b) => b.id - a.id)
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ describe('AsistenciasIndex.vue', () => {
|
|||||||
|
|
||||||
|
|
||||||
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).exists()).toBe(true)
|
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).exists()).toBe(true)
|
||||||
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).props('asistencias')).toEqual(asistenciasStoreMock.asistencias)
|
const expected = [...asistenciasStoreMock.asistencias].sort((a, b) => b.id - a.id)
|
||||||
|
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).props('asistencias')).toEqual(expected)
|
||||||
expect(wrapper.findComponent({ name: 'CardAsistencia' }).exists()).toBe(false)
|
expect(wrapper.findComponent({ name: 'CardAsistencia' }).exists()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -99,8 +100,9 @@ describe('AsistenciasIndex.vue', () => {
|
|||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const cardWrappers = wrapper.findAllComponents({ name: 'CardAsistencia' })
|
const cardWrappers = wrapper.findAllComponents({ name: 'CardAsistencia' })
|
||||||
expect(cardWrappers.length).toBe(asistenciasStoreMock.asistencias.length)
|
const expected = [...asistenciasStoreMock.asistencias].sort((a, b) => b.id - a.id)
|
||||||
expect(cardWrappers[0].props('asistencia')).toEqual(asistenciasStoreMock.asistencias[0])
|
expect(cardWrappers.length).toBe(expected.length)
|
||||||
|
expect(cardWrappers[0].props('asistencia')).toEqual(expected[0])
|
||||||
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).exists()).toBe(false)
|
expect(wrapper.findComponent({ name: 'TablaAsistencias' }).exists()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,10 @@ const empleadosStore = useEmpleadosStore();
|
|||||||
const { empleados } = storeToRefs(empleadosStore);
|
const { empleados } = storeToRefs(empleadosStore);
|
||||||
|
|
||||||
// alias para plantilla
|
// alias para plantilla
|
||||||
const employees = empleados;
|
// Sort employees by id descending for display
|
||||||
|
const employees = computed(() =>
|
||||||
|
[...(empleados?.value || [])].sort((a, b) => b.id - a.id)
|
||||||
|
);
|
||||||
|
|
||||||
// --- helpers ---
|
// --- helpers ---
|
||||||
// Removed btnClass as manual toggle buttons are removed
|
// Removed btnClass as manual toggle buttons are removed
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ describe('EmpleadosIndex.vue', () => {
|
|||||||
await wrapper.vm.$nextTick() // Wait for any reactivity updates
|
await wrapper.vm.$nextTick() // Wait for any reactivity updates
|
||||||
|
|
||||||
expect(wrapper.findComponent({ name: 'TablaEmpleados' }).exists()).toBe(true)
|
expect(wrapper.findComponent({ name: 'TablaEmpleados' }).exists()).toBe(true)
|
||||||
expect(wrapper.findComponent({ name: 'TablaEmpleados' }).props('employees')).toEqual(empleadosStoreMock.empleados)
|
const expected = [...empleadosStoreMock.empleados].sort((a, b) => b.id - a.id)
|
||||||
|
expect(wrapper.findComponent({ name: 'TablaEmpleados' }).props('employees')).toEqual(expected)
|
||||||
expect(wrapper.findComponent({ name: 'CardEmpleado' }).exists()).toBe(false)
|
expect(wrapper.findComponent({ name: 'CardEmpleado' }).exists()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -103,8 +104,9 @@ describe('EmpleadosIndex.vue', () => {
|
|||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const cardWrappers = wrapper.findAllComponents({ name: 'CardEmpleado' })
|
const cardWrappers = wrapper.findAllComponents({ name: 'CardEmpleado' })
|
||||||
expect(cardWrappers.length).toBe(empleadosStoreMock.empleados.length)
|
const expected = [...empleadosStoreMock.empleados].sort((a, b) => b.id - a.id)
|
||||||
expect(cardWrappers[0].props('employee')).toEqual(empleadosStoreMock.empleados[0])
|
expect(cardWrappers.length).toBe(expected.length)
|
||||||
|
expect(cardWrappers[0].props('employee')).toEqual(expected[0])
|
||||||
expect(wrapper.findComponent({ name: 'TablaEmpleados' }).exists()).toBe(false)
|
expect(wrapper.findComponent({ name: 'TablaEmpleados' }).exists()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -86,8 +86,10 @@ const errorMessage = ref('');
|
|||||||
// Initialize currentView from the store's default setting for planillas
|
// Initialize currentView from the store's default setting for planillas
|
||||||
const currentView = ref(ui.defaultViewPlanillas);
|
const currentView = ref(ui.defaultViewPlanillas);
|
||||||
|
|
||||||
// Computed property to get planillas from the store
|
// Computed property sorted by id descending
|
||||||
const planillasList = computed(() => planillasStore.planillas);
|
const planillasList = computed(() =>
|
||||||
|
[...(planillasStore.planillas || [])].sort((a, b) => b.id - a.id)
|
||||||
|
);
|
||||||
|
|
||||||
// Fetch planillas when the component is mounted
|
// Fetch planillas when the component is mounted
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ describe('PlanillasIndex.vue', () => {
|
|||||||
await wrapper.vm.$nextTick() // Additional tick if loading state causes multiple updates
|
await wrapper.vm.$nextTick() // Additional tick if loading state causes multiple updates
|
||||||
|
|
||||||
expect(wrapper.findComponent({ name: 'TablaPlanillas' }).exists()).toBe(true)
|
expect(wrapper.findComponent({ name: 'TablaPlanillas' }).exists()).toBe(true)
|
||||||
expect(wrapper.findComponent({ name: 'TablaPlanillas' }).props('planillas')).toEqual(planillasStoreMock.planillas)
|
const expected = [...planillasStoreMock.planillas].sort((a, b) => b.id - a.id)
|
||||||
|
expect(wrapper.findComponent({ name: 'TablaPlanillas' }).props('planillas')).toEqual(expected)
|
||||||
expect(wrapper.findComponent({ name: 'CardPlanilla' }).exists()).toBe(false)
|
expect(wrapper.findComponent({ name: 'CardPlanilla' }).exists()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -94,8 +95,9 @@ describe('PlanillasIndex.vue', () => {
|
|||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const cardWrappers = wrapper.findAllComponents({ name: 'CardPlanilla' })
|
const cardWrappers = wrapper.findAllComponents({ name: 'CardPlanilla' })
|
||||||
expect(cardWrappers.length).toBe(planillasStoreMock.planillas.length)
|
const expected = [...planillasStoreMock.planillas].sort((a, b) => b.id - a.id)
|
||||||
expect(cardWrappers[0].props('planilla')).toEqual(planillasStoreMock.planillas[0])
|
expect(cardWrappers.length).toBe(expected.length)
|
||||||
|
expect(cardWrappers[0].props('planilla')).toEqual(expected[0])
|
||||||
expect(wrapper.findComponent({ name: 'TablaPlanillas' }).exists()).toBe(false)
|
expect(wrapper.findComponent({ name: 'TablaPlanillas' }).exists()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,10 @@ const errorMessage = ref('');
|
|||||||
// Initialize currentView from the store's default setting for tareas
|
// Initialize currentView from the store's default setting for tareas
|
||||||
const currentView = ref(ui.defaultViewTareas);
|
const currentView = ref(ui.defaultViewTareas);
|
||||||
|
|
||||||
const tareasList = computed(() => tareasStore.tareas);
|
// Display tareas sorted by id descending
|
||||||
|
const tareasList = computed(() =>
|
||||||
|
[...(tareasStore.tareas || [])].sort((a, b) => b.id - a.id)
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ describe('TareasIndex.vue', () => {
|
|||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.findComponent({ name: 'TablaTareas' }).exists()).toBe(true)
|
expect(wrapper.findComponent({ name: 'TablaTareas' }).exists()).toBe(true)
|
||||||
expect(wrapper.findComponent({ name: 'TablaTareas' }).props('tareas')).toEqual(tareasStoreMock.tareas)
|
const expected = [...tareasStoreMock.tareas].sort((a, b) => b.id - a.id)
|
||||||
|
expect(wrapper.findComponent({ name: 'TablaTareas' }).props('tareas')).toEqual(expected)
|
||||||
expect(wrapper.findComponent({ name: 'CardTarea' }).exists()).toBe(false)
|
expect(wrapper.findComponent({ name: 'CardTarea' }).exists()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -94,8 +95,9 @@ describe('TareasIndex.vue', () => {
|
|||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const cardWrappers = wrapper.findAllComponents({ name: 'CardTarea' })
|
const cardWrappers = wrapper.findAllComponents({ name: 'CardTarea' })
|
||||||
expect(cardWrappers.length).toBe(tareasStoreMock.tareas.length)
|
const expected = [...tareasStoreMock.tareas].sort((a, b) => b.id - a.id)
|
||||||
expect(cardWrappers[0].props('tarea')).toEqual(tareasStoreMock.tareas[0])
|
expect(cardWrappers.length).toBe(expected.length)
|
||||||
|
expect(cardWrappers[0].props('tarea')).toEqual(expected[0])
|
||||||
expect(wrapper.findComponent({ name: 'TablaTareas' }).exists()).toBe(false)
|
expect(wrapper.findComponent({ name: 'TablaTareas' }).exists()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user