@@ -20,10 +20,10 @@ describe("ak-button component", () => {
2020 } ;
2121
2222 it ( "renders as a button by default" , async ( ) => {
23- const { getByRole, getByText } = renderComponent ( "Click here" ) ;
23+ const { getByRole } = renderComponent ( "Click here" ) ;
2424 const button = await getByRole ( "button" ) ;
25- expect ( await button . getByText ( "Click here" ) ) . toBeTruthy ( ) ;
26- const element = await button . element ( ) ;
25+ expect ( button . getByText ( "Click here" ) ) . toBeTruthy ( ) ;
26+ const element = button . element ( ) ;
2727 expect ( element . tagName ) . toBe ( "BUTTON" ) ;
2828 } ) ;
2929
@@ -34,62 +34,62 @@ describe("ak-button component", () => {
3434 } ) ;
3535
3636 // When variant="link", renders <a> tag instead of <button>
37- const link = await getByText ( "Click to leave" ) ;
37+ const link = getByText ( "Click to leave" ) ;
3838 await expect . element ( link ) . toBeTruthy ( ) ;
3939 await expect . element ( link ) . toHaveAttribute ( "href" , "https://example.com" ) ;
40- const element = await getByRole ( "link" ) . element ( ) ;
40+ const element = getByRole ( "link" ) . element ( ) ;
4141 expect ( element . tagName ) . toBe ( "A" ) ;
4242
4343 // Verify slotted text content
4444 const component = document . querySelector ( "ak-button" ) ;
45- await expect ( component ?. textContent ?. trim ( ) ) . toBe ( "Click to leave" ) ;
45+ expect ( component ?. textContent ?. trim ( ) ) . toBe ( "Click to leave" ) ;
4646 } ) ;
4747
4848 it ( "applies disabled state when specified" , async ( ) => {
49- const { getByRole, getByText } = renderComponent ( "Click here" , { "?disabled" : true } ) ;
49+ const { getByRole } = renderComponent ( "Click here" , { "?disabled" : true } ) ;
5050 const button = await getByRole ( "button" ) ;
51- expect ( await button . getByText ( "Click here" ) ) . toBeTruthy ( ) ;
52- const element = await button . element ( ) ;
51+ expect ( button . getByText ( "Click here" ) ) . toBeTruthy ( ) ;
52+ const element = button . element ( ) ;
5353 expect ( element . tagName ) . toBe ( "BUTTON" ) ;
5454 await expect . element ( button ) . toHaveAttribute ( "disabled" ) ;
5555 } ) ;
5656
5757 it ( "triggers click events" , async ( ) => {
5858 const { getByRole } = renderComponent ( "Click here" ) ;
5959 const component = document . querySelector ( "ak-button" ) ;
60- await expect ( component ) . toBeTruthy ( ) ;
60+ await expect . element ( component ) . toBeTruthy ( ) ;
6161
6262 let buttonClicked = false ;
6363 component ! . addEventListener ( "click" , ( ) => {
6464 buttonClicked = true ;
6565 } ) ;
6666
6767 const button = await getByRole ( "button" ) ;
68- await expect ( ( await button . element ( ) ) . tagName ) . toBe ( "BUTTON" ) ;
68+ expect ( button . element ( ) . tagName ) . toBe ( "BUTTON" ) ;
6969 await button . click ( ) ;
7070 expect ( buttonClicked ) . toBe ( true ) ;
7171 } ) ;
7272
7373 it ( "does not trigger click events when disabled" , async ( ) => {
7474 const { getByRole } = renderComponent ( "Click here" , { "?disabled" : true } ) ;
7575 const component = document . querySelector ( "ak-button" ) ;
76- await expect ( component ) . toBeTruthy ( ) ;
76+ expect ( component ) . toBeTruthy ( ) ;
7777
7878 let buttonClicked = false ;
7979 component ! . addEventListener ( "click" , ( ) => {
8080 buttonClicked = true ;
8181 } ) ;
8282
8383 const button = await getByRole ( "button" ) ;
84- await expect ( ( await button . element ( ) ) . tagName ) . toBe ( "BUTTON" ) ;
84+ expect ( button . element ( ) . tagName ) . toBe ( "BUTTON" ) ;
8585 // Playwright will normally avoid clicking a button that is marked "disabled." We want it to
8686 // try anyway.
8787 await button . click ( { force : true } ) ;
8888 expect ( buttonClicked ) . toBe ( false ) ;
8989 } ) ;
9090
9191 it ( "when a link, it does not have an href when disabled" , async ( ) => {
92- const { getByRole , getByText } = renderComponent ( "Click to leave" , {
92+ renderComponent ( "Click to leave" , {
9393 "variant" : "link" ,
9494 "href" : "https://example.com" ,
9595 "?disabled" : true ,
@@ -98,9 +98,9 @@ describe("ak-button component", () => {
9898 const component = document . querySelector ( "ak-button" ) ;
9999 const anchor = await vi . waitUntil ( ( ) => component ?. shadowRoot ?. querySelector ( "a" ) ) ;
100100 expect ( anchor ) . not . toBeNull ( ) ;
101- const element = await page . elementLocator ( anchor ! ) ;
102- await expect ( element ) . toBeVisible ( ) ;
103- await expect ( element ) . toHaveAttribute ( "id" , "main" ) ;
104- await expect ( element ) . not . toHaveAttribute ( "href" ) ;
101+ const element = page . elementLocator ( anchor ! ) ;
102+ await expect . element ( element ) . toBeVisible ( ) ;
103+ await expect . element ( element ) . toHaveAttribute ( "id" , "main" ) ;
104+ await expect . element ( element ) . not . toHaveAttribute ( "href" ) ;
105105 } ) ;
106106} ) ;
0 commit comments