How to check attribute using playwright?

I’m using spectrum web components to show a checkbox. Here’s what I use

<sp-checkbox size="m" data-test-id="test" checked="" tabindex="0" dir="ltr"></sp-checkbox>

When sp-checkbox is not checked, I want to click on it using the click(). I do the following in playwright

  testBtn = () => this.page.getByTestId("test");

  await this.testBtn().click();

but it clicks on the checkbox regardless of whether it’s checked. I only want to click on the checkbox when it’s not checked.

How can I do this using playwright?