Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tailwind to Test Site and e2e-tests #422

Merged
merged 14 commits into from
Oct 26, 2023
5 changes: 4 additions & 1 deletion apps/test-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
"@yext/pages": "^1.0.0-rc.1",
"@yext/studio": "*",
"@yext/types": "^0.1.12-alpha",
"autoprefixer": "^10.4.16",
"eslint": "^8.11.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-react-perf": "^3.3.1",
"eslint-plugin-tsdoc": "^0.2.17"
"eslint-plugin-tsdoc": "^0.2.17",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.4"
},
"scripts": {
"dev": "studio",
Expand Down
6 changes: 6 additions & 0 deletions apps/test-site/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
1 change: 1 addition & 0 deletions apps/test-site/src/layouts/LocationLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Header from "../components/Header";
import "../styles/main.css";

function LocationLayout() {
return (
Expand Down
3 changes: 3 additions & 0 deletions apps/test-site/src/styles/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
1 change: 1 addition & 0 deletions apps/test-site/src/templates/LocationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import BusinessInfo from "../components/BusinessInfo";
import Header from "../components/Header";
import HoursDisplay from "../components/HoursDisplay";
import ProminentImage from "../components/ProminentImage";
import "../styles/main.css";

export const config: TemplateConfig = {
stream: {
Expand Down
1 change: 1 addition & 0 deletions apps/test-site/src/templates/UniversalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Button from "../components/Button";
import Container from "../components/Container";
import Cta from "../components/Cta";
import FixedText from "../components/FixedText";
import "../styles/main.css";

export const config: TemplateConfig = {
stream: {
Expand Down
1 change: 1 addition & 0 deletions apps/test-site/src/templates/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GetPath, TemplateProps } from "@yext/pages";
import Button from "../components/Button";
import "../styles/main.css";

export const getPath: GetPath<TemplateProps> = () => {
return "index.html";
Expand Down
9 changes: 1 addition & 8 deletions apps/test-site/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ import type { StudioTailwindConfig } from "@yext/studio";
export default {
content: ["./src/**/*.{ts,tsx}"],
theme: {
extend: {
colors: {
primary: "#aa00ff",
},
fontSize: {
medium: "14px",
},
},
extend: {},
},
} satisfies StudioTailwindConfig;
5 changes: 4 additions & 1 deletion e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
"@vitejs/plugin-react": "^2.1.0",
"@yext/pages": "^1.0.0-rc.1",
"@yext/studio": "*",
"autoprefixer": "^10.4.16",
"fs-extra": "^11.1.1",
"glob": "^10.3.1"
"glob": "^10.3.1",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.4"
},
"dependencies": {
"kill-port": "^2.0.1"
Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PlaywrightTestConfig, expect } from "@playwright/test";
import fs from "node:fs";
import os from "node:os";

expect.extend({
async toHaveContents(filepath: string, expectedContents: string) {
Expand Down Expand Up @@ -51,7 +52,7 @@ const config: PlaywrightTestConfig = {
video: "on",
},
workers: 1,
ignoreSnapshots: true,
ignoreSnapshots: os.platform() !== "darwin",
};

export default config;
6 changes: 6 additions & 0 deletions e2e-tests/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
1 change: 1 addition & 0 deletions e2e-tests/src/layouts/LocationLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Header from "../components/Header";
import "../styles/main.css";

function LocationLayout() {
return (
Expand Down
3 changes: 3 additions & 0 deletions e2e-tests/src/styles/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
1 change: 1 addition & 0 deletions e2e-tests/src/templates/BasicPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { GetPath, TemplateProps } from "@yext/pages";
import Banner from "../components/Banner";
import Container from "../components/Container";
import "../styles/main.css";

export const getPath: GetPath<TemplateProps> = () => {
return "index.html";
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/src/templates/ErrorComponentPreviews.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GetPath, TemplateProps } from "@yext/pages";
import ErrorComponent from "../components/ErrorComponent";
import "../styles/main.css";

export const getPath: GetPath<TemplateProps> = () => {
return "error-component-page";
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/src/templates/ErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GetPath, TemplateProps } from "@yext/pages";
import "../styles/main.css";

export const getPath: GetPath<TemplateProps> = () => {
return "error-page";
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/src/templates/LocationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import BusinessInfo from "../components/BusinessInfo";
import Header from "../components/Header";
import HoursDisplay from "../components/HoursDisplay";
import ProminentImage from "../components/ProminentImage";
import "../styles/main.css";

export const config: TemplateConfig = {
stream: {
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/tests/__fixtures__/add-element-expected-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Footer from "../components/Footer";
import Header from "../components/Header";
import HoursDisplay from "../components/HoursDisplay";
import ProminentImage from "../components/ProminentImage";
import "../styles/main.css";

export const config: TemplateConfig = {
stream: {
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/tests/__fixtures__/add-layout-page-expected.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GetPath, TemplateProps } from "@yext/pages";
import Header from "../components/Header";
import "../styles/main.css";

export const getPath: GetPath<TemplateProps> = () => {
return "index.html";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GetPath, TemplateProps } from "@yext/pages";
import Banner from "../components/Banner";
import Button from "../components/Button";
import Container from "../components/Container";
import "../styles/main.css";

export const getPath: GetPath<TemplateProps> = () => {
return "index.html";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GetPath, TemplateProps } from "@yext/pages";
import Button from "../components/Button";
import "../styles/main.css";

export const getPath: GetPath<TemplateProps> = () => {
return "index.html";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import BusinessInfo from "../components/BusinessInfo";
import Header from "../components/Header";
import HoursDisplay from "../components/HoursDisplay";
import ProminentImage from "../components/ProminentImage";
import "../styles/main.css";

export const config: TemplateConfig = {
stream: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GetPath, TemplateProps } from "@yext/pages";
import "../styles/main.css";

export const getPath: GetPath<TemplateProps> = () => {
return "index.html";
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/tests/custom-tailwind.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { studioTest } from "./infra/studioTest.js";
import fs from "fs";

studioTest.use({
tailwindConfigPath: "tests/__fixtures__/tailwind.config.ts",
tailwindConfigPath: "tests/__fixtures__/custom-tailwind.config.ts",
});

studioTest(
Expand Down
16 changes: 13 additions & 3 deletions e2e-tests/tests/infra/StudioPlaywrightPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,18 @@ export default class StudioPlaywrightPage {
*/
async waitForLoadState() {
await this.page.waitForLoadState();
await expect(
this.page.getByRole("button", { name: "Open Add Element Menu" })
).toBeVisible();
const overlayDomEl = this.page.getByTestId("loading-overlay");
await expect
.poll(
() =>
overlayDomEl.evaluate((e: HTMLElement) => {
return e.className.includes("opacity-0");
}),
{
message: "Waiting for LoadingOverlay to finish.",
timeout: 5000,
}
)
.toBeTruthy();
}
}
2 changes: 1 addition & 1 deletion e2e-tests/tests/infra/studioTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type StudioTestFixtures = {
export const studioTest = base.extend<StudioTestFixtures>({
createRemote: false,
debug: false,
tailwindConfigPath: undefined,
tailwindConfigPath: "tests/infra/tailwind.config.ts",
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
studioPage: async (
{ page, createRemote, debug, tailwindConfigPath },
use,
Expand Down
8 changes: 8 additions & 0 deletions e2e-tests/tests/infra/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { StudioTailwindConfig } from "@yext/studio";

export default {
content: ["./src/**/*.{ts,tsx}"],
theme: {
extend: {},
},
} satisfies StudioTailwindConfig;
Loading
Loading