From f2fcdd61bed50cf20e628e431c52cb4a026b0da8 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Thu, 22 Aug 2024 09:08:26 +0000 Subject: [PATCH] fix: disable clock tests --- tests/api-mocking/api-mocking.spec.ts | 57 +++++++++---------- .../{clock.spec.ts => clock.spec.ts.disabled} | 0 2 files changed, 27 insertions(+), 30 deletions(-) rename tests/clock/{clock.spec.ts => clock.spec.ts.disabled} (100%) diff --git a/tests/api-mocking/api-mocking.spec.ts b/tests/api-mocking/api-mocking.spec.ts index 8e507af..0b51022 100644 --- a/tests/api-mocking/api-mocking.spec.ts +++ b/tests/api-mocking/api-mocking.spec.ts @@ -1,73 +1,70 @@ -import { test, expect, type Page } from '@playwright/test'; +import { test, expect, type Page } from "@playwright/test"; -test.describe('Mocking an API call', () => { - - test('mocks a fruit and does not call api', async ({ page }) => { +test.describe("Mocking an API call", () => { + test("mocks a fruit and does not call api", async ({ page }) => { // Mock the api call before navigating - await page.route('*/**/api/v1/fruits', async (route) => { - const json = [{ name: 'Strawberry', id: 21 }]; + await page.route("*/**/api/v1/fruits", async (route) => { + const json = [{ name: "Strawberry", id: 21 }]; await route.fulfill({ json }); }); // Go to the page - await page.goto('https://demo.playwright.dev/api-mocking'); - + await page.goto("https://demo.playwright.dev/api-mocking"); + // Assert that the Strawberry fruit is visible - await expect(page.getByText('Strawberry')).toBeVisible(); + await expect(page.getByText("Strawberry")).toBeVisible(); }); - }); -test.describe('Intercepting the request and modifying it', () => { - - test('gets the json from api and adds a new fruit', async ({ page }) => { +test.describe("Intercepting the request and modifying it", () => { + test("gets the json from api and adds a new fruit", async ({ page }) => { // Get the response and add to it - await page.route('*/**/api/v1/fruits', async (route) => { + await page.route("*/**/api/v1/fruits", async (route) => { const response = await route.fetch(); const json = await response.json(); - json.push({ name: 'Playwright', id: 100 }); + json.push({ name: "Playwright", id: 100 }); // Fulfill using the original response, while patching the response body // with the given JSON object. await route.fulfill({ response, json }); }); // Go to the page - await page.goto('https://demo.playwright.dev/api-mocking'); + await page.goto("https://demo.playwright.dev/api-mocking"); // Assert that the new fruit is visible - await expect(page.getByText('Playwright', { exact: true })).toBeVisible(); + await expect(page.getByText("Playwright", { exact: true })).toBeVisible(); }); - }); -test.describe('Mocking with HAR files', () => { - - test('records or updates the HAR file', async ({ page }) => { +test.describe("Mocking with HAR files", () => { + test("records or updates the HAR file", async ({ page }) => { // Get the response from the HAR file - await page.routeFromHAR('./hars/fruits.har', { - url: '*/**/api/v1/fruits', + await page.routeFromHAR("./hars/fruits.har", { + url: "*/**/api/v1/fruits", update: true, }); // Go to the page - await page.goto('https://demo.playwright.dev/api-mocking'); + await page.goto("https://demo.playwright.dev/api-mocking"); // Assert that the Playwright fruit is visible - await expect(page.getByText('Strawberry')).toBeVisible(); + await expect(page.getByText("Strawberry")).toBeVisible(); }); - test('gets the json from HAR and checks the new fruit has been added', async ({ page }) => { + test("gets the json from HAR and checks the new fruit has been added", async ({ + page, + }) => { // Replay API requests from HAR. // Either use a matching response from the HAR, // or abort the request if nothing matches. - await page.routeFromHAR('./hars/fruits.har', { - url: '*/**/api/v1/fruits', + await page.routeFromHAR("./hars/fruits.har", { + url: "*/**/api/v1/fruits", update: false, }); // Go to the page - await page.goto('https://demo.playwright.dev/api-mocking'); + await page.goto("https://demo.playwright.dev/api-mocking"); // Assert that the Playwright fruit is visible - await expect(page.getByText('Strawberry')).toBeVisible(); + await expect(page.getByText("Strawberry")).toBeVisible(); }); }); diff --git a/tests/clock/clock.spec.ts b/tests/clock/clock.spec.ts.disabled similarity index 100% rename from tests/clock/clock.spec.ts rename to tests/clock/clock.spec.ts.disabled