Udemy Playwright: Web Automation Testing From Zero to Hero: Difference between revisions

Jump to navigation Jump to search
m
Line 1,200: Line 1,200:
* refresh the Global Feed tab
* refresh the Global Feed tab
* Confirm the article is no longer listed
* Confirm the article is no longer listed
<nowiki>
test("Delete Article", async ({ page, request }) => {
  const response = await request.post(
    "https://conduit-api.bondaracademy.com/api/users/login",
    {
      data: {
        user: {
          email: "conduit@dirksonline.net",
          password: "qB85R86#ZMKME$jVEVq#vJMDr*A!cJk",
        },
      },
    }
  )
  const responseBody = await response.json()
  const accessToken = responseBody.user.token
  const articleResponse = await request.post(
    "https://conduit-api.bondaracademy.com/api/articles/",
    {
      data: {
        article: {
          title: "Test Title",
          description: "Test description",
          body: "Test body",
          tagList: [],
        },
      },
      headers: {
        Authorization: `Token ${accessToken}`,
      },
    }
  )
  expect(articleResponse.status()).toEqual(201)
  await page.getByText('Global Feed').click()
  await page.getByText('Test Title').click()
  await page.getByRole('button',{name:'Delete Article'}).first().click()
  await page.getByText('Global Feed').click()
  await expect(page.locator("app-article-list h1").first()).not.toContainText(
    "Test Title"
  )
})</nowiki>


=== Intercept Browser API Response ===
=== Intercept Browser API Response ===
=== Sharing Authentication State ===
=== Sharing Authentication State ===
=== API Authentication ===
=== API Authentication ===

Navigation menu