Updated at 6 p.m. with testimony wrapping up for the day.

Leiliana Wright spent her final hours beaten and bound in a dark closet, the Grand Prairie 4-year-old's mother testified Wednesday.

The capital murder trial of 36-year-old Charles Wayne Phifer began Wednesday in Dallas. He is accused of beating Leiliana to death with a belt and a bamboo stick in March 2016.

The little girl's death exposed a staffing crisis in the state's child-welfare system. Social workers had been warned months earlier that Leiliana was in danger.

Her mother, 32-year-old Jeri Quezada, pleaded guilty to felony injury to a child in July 2017 as part of a plea agreement that will put her behind bars for up to 50 years.

As part of her deal with prosecutors, Quezada agreed to testify during Phifer's trial.

"My daughter deserves justice," Quezada said Wednesday. "I know where I went wrong. I'm not the only one who did it."

Several jurors put their heads in their hands and cried while Quezada described what she saw Phifer do to her daughter on March 12, 2016.

Months before Leiliana was killed, the child's grandmother had sent pictures of bruising on the girl's face to Child Protective Services, but a CPS investigator was slow to check on the girl and her younger brother.

Leiliana Wright had a black eye in a photo taken two months before her death.

In February 2016, the investigator found the children living with Quezada, a convicted felon with a documented history of child abuse. Caseworkers did not review Quezada's history, which would have shown previous run-ins with child protection workers in Illinois and Texas.

Quezada had already given up custody of her three older children.

After Leiliana's death, the caseworker and supervisor on her case were fired, and a special investigator resigned.

Quezada admitted Wednesday that she had struck her stepson in Illinois and that she had been ordered into anger management classes. She also said she had hit Leiliana in the days before her death, including using a bamboo switch to strike the little girl's legs.

She said she had been frustrated with Leiliana because she wouldn't eat and was throwing up. She said her daughter had been acting out.

"She was talking back a lot," she said. "It frustrated me because I didn't understand what was going on."

In a text message she sent to her boyfriend the day before the beating, Quezada described Leiliana as "trying to get attention from everyone" by vomiting.

Phifer was living in a Grand Prairie home that had belonged to Quezada's grandmother at the time of Leiliana's death. He was alone with the girl for several hours on March 12, 2016, at the home.

Jeri Quezada (Dallas County Jail)

Quezada said she had left the Grand Prairie house a couple times that day with her 18-month-old son, including to go to dinner with her parents at an Arlington steakhouse. She opted to leave Leiliana in Phifer's care because the girl was sick.

When she returned to the Grand Prairie home, she went into the bathroom with Phifer to use heroin. She didn't immediately look for or ask about her daughter.

"What was the first thing on your mind?" prosecutor Eren Price asked Quezada.

"Getting high," the mother said.

After Phifer injected her and himself with drugs, Quezada asked where Leiliana was, and he told her the girl was in the closet.

1 / 9Charles Phifer entered the courtroom Wednesday at the Frank Crowley Courts Building in Dallas. He's charged with capital murder in the March 2016 beating death of 4-year-old Leiliana Wright.(Ashley Landis / Staff Photographer) 2 / 9Jeri Quezada testifies in the capital murder trial of Charles Phifer, who's accused of beating Leiliana Wright to death in March 2016.(Ashley Landis / Staff Photographer) 3 / 9Charles Phifer called 911 to report the girl's injuries saying, "My girlfriend's daughter's having trouble breathing. ... She's been hurting herself, too."(Ashley Landis / Staff Photographer) 4 / 9Jeri Quezada testifies Wednesday at the Frank Crowley Courts Building in Dallas. (Ashley Landis / Staff Photographer) 5 / 9Judge Robert D. Burns III will preside over the capital murder trial of Charles Phifer, accused in the death of 4-year-old Leiliana Wright. (Ashley Landis / Staff Photographer) 6 / 9Prosecutor Eren Price shows a photo of 4-year-old Leiliana Wright during her opening statement Wednesday.(Ashley Landis / Staff Photographer) 7 / 9Jeri Quezada faces 50 years in prison for her daughter's death but says, "I'm not the only one who did it."(Ashley Landis / Staff Photographer) 8 / 9Firefighter Andrew Grondin said Leiliana Wright was limp and cold when he carried her to an ambulance in March 2016.(Ashley Landis / Staff Photographer) 9 / 9As part of a plea deal, Jeri Quezada agreed to testify against Charles Phifer. "My daughter deserves justice," she said Wednesday.(Ashley Landis / Staff Photographer)

Quezada said she "didn't really know what to do" when she saw her daughter "strung up" in the tiny living room closet. She said the girl's hands were tied behind her back with electrical wire and something was wrapped around her stomach.

The girl was bent at her waist and hanging from a rod, Quezada said.

Quezada recalled asking Phifer to untie the girl and let her out of the closet. Quezada said her daughter was conscious at the time and "would just say she loved me and would say 'Mommy,' and that's it."

The woman made a peanut butter sandwich for the girl, but Leiliana was having trouble eating it.

Phifer then put on gloves, grabbed the girl's cheeks, lifted her off the ground and poured Pedialyte into her mouth.

"What are you doing while he's doing this to your baby?" Price asked.

"Sitting there," Quezada said.

Afterward, the little girl vomited. And then the abuse continued.

"I seen him pick her up by the throat and threw her against the closet," Quezada said.

After the mother saw that her daughter had soiled herself and was covered in vomit, she put her in the shower.

Leiliana Wright's death revealed a state child-welfare agency in disarray.

Then she left the room.

Quezada testified that she heard a thump. When Quezada went to check, she saw Phifer leaving the bathroom.

She tried to dress the child, but the girl had stopped breathing. That's when the couple called for help.

In the 911 call, Phifer sounded frantic.

"My girlfriend's daughter's having trouble breathing," he told the operator.

At one point during the call, he said, "She's been hurting herself, too."

An operator tried to walk him through performing CPR, but Phifer kept talking and didn't sound as if he was trying to help the girl.

Andrew Grondin, a Grand Prairie firefighter who tried to save Leiliana, choked back tears on the witness stand while recalling the night he and other paramedics found the girl.

He said the girl was covered in bruises and had a black eye, and there were ligature marks on her wrists.

"I picked up the little girl and she was limp. She was cold," Grondin said after taking a minute to compose himself.

Grondin carried the girl to the ambulance instead of waiting to get a stretcher. He then said he needed everyone to come with him to the hospital. The firefighters left the fire truck, with lights on and doors open, at the scene.

Emergency room doctors and nurses spent 30 minutes trying to resuscitate the girl. She was pronounced dead at the hospital.

Leiliana died from blunt-force injuries to her head and stomach.

Leiliana Wright's paternal grandparents, Alisa and Craig Clakley, documented injuries to her face in photos they sent to CPS more than a year before her death.

Jurors were shown photos of the little girl's bruised and battered face. They also saw photos of the marks on her wrists and whip marks on her back.

In early reports on Leiliana's death, police said the beating had started after the girl drank her younger brother's juice. Quezada did not testify that that happened.

The younger brother was placed in state custody after Leiliana's death. He now lives with his father's parents. Quezada's three older children live with their father.

If convicted, Phifer will receive an automatic life sentence without the possibility of parole.

Testimony in his trial will continue Thursday morning.