|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | +import { |
| 3 | + setupDevServer, |
| 4 | + setupBuildAndPreview, |
| 5 | + setupWaitForLogs, |
| 6 | + expectColor, |
| 7 | +} from "../../utils"; |
| 8 | + |
| 9 | +test("Emotion plugin build", async ({ page }) => { |
| 10 | + const { testUrl, server } = await setupBuildAndPreview("emotion-plugin"); |
| 11 | + await page.goto(testUrl); |
| 12 | + |
| 13 | + const button = page.locator("button"); |
| 14 | + await button.hover(); |
| 15 | + await expectColor(button, "color", "#646cff"); |
| 16 | + |
| 17 | + await button.click(); |
| 18 | + await expect(button).toHaveText("count is 1"); |
| 19 | + |
| 20 | + const code = page.locator("code"); |
| 21 | + await expectColor(code, "color", "#646cff"); |
| 22 | + |
| 23 | + await server.httpServer.close(); |
| 24 | +}); |
| 25 | + |
| 26 | +test("Emotion plugin HMR", async ({ page }) => { |
| 27 | + const { testUrl, server, editFile } = await setupDevServer("emotion-plugin"); |
| 28 | + const waitForLogs = await setupWaitForLogs(page); |
| 29 | + await page.goto(testUrl); |
| 30 | + await waitForLogs("[vite] connected."); |
| 31 | + |
| 32 | + const button = page.locator("button"); |
| 33 | + await button.hover(); |
| 34 | + await expectColor(button, "color", "#646cff"); |
| 35 | + |
| 36 | + await button.click(); |
| 37 | + await expect(button).toHaveText("count is 1"); |
| 38 | + |
| 39 | + const code = page.locator("code"); |
| 40 | + await expectColor(code, "color", "#646cff"); |
| 41 | + |
| 42 | + editFile("src/Button.jsx", [ |
| 43 | + "background-color: #d26ac2;", |
| 44 | + "background-color: #646cff;", |
| 45 | + ]); |
| 46 | + await waitForLogs("[vite] hot updated: /src/Button.jsx"); |
| 47 | + await expect(button).toHaveText("count is 1"); |
| 48 | + await expectColor(button, "backgroundColor", "#646cff"); |
| 49 | + |
| 50 | + editFile("src/App.jsx", ['color="#646cff"', 'color="#d26ac2"']); |
| 51 | + await waitForLogs("[vite] hot updated: /src/App.jsx"); |
| 52 | + await expect(button).toHaveText("count is 1"); |
| 53 | + await expectColor(button, "color", "#d26ac2"); |
| 54 | + |
| 55 | + editFile("src/Button.jsx", ["color: #646cff;", "color: #d26ac2;"]); |
| 56 | + await waitForLogs("[vite] hot updated: /src/Button.jsx"); |
| 57 | + await expect(button).toHaveText("count is 1"); |
| 58 | + await expectColor(code, "color", "#d26ac2"); |
| 59 | + |
| 60 | + await server.close(); |
| 61 | +}); |
0 commit comments