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

feat: Switch to Argos & fix E2E tests #1949

Merged
merged 15 commits into from
Jan 8, 2025
Merged
16 changes: 9 additions & 7 deletions e2e/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import {
locatorFixtures as fixtures,
LocatorFixtures as TestingLibraryFixtures,
} from "@playwright-testing-library/test/fixture";
import { test as base, Page, PlaywrightTestOptions } from "@playwright/test";
import { Page, PlaywrightTestOptions, test as base } from "@playwright/test";

import { Actions, createActions, } from "./actions";
import { Actions, createActions } from "./actions";
import { createSelectors, Selectors } from "./selectors";
import slugify from "./slugify";

type RouteFromHAROptions = Parameters<Page['routeFromHAR']>[1];
type RouteFromHAROptions = Parameters<Page["routeFromHAR"]>[1];

const setup = (contextOptions?: PlaywrightTestOptions["contextOptions"]) => {
const test = base.extend<TestingLibraryFixtures>(fixtures).extend<{
Expand All @@ -28,18 +28,20 @@ const setup = (contextOptions?: PlaywrightTestOptions["contextOptions"]) => {
},
replayFromHAR: async ({ page }, use, testInfo) => {
let index = 0;
const replay = async (routeFromHAROptions?: RouteFromHAROptions
) => {
const replay = async (routeFromHAROptions?: RouteFromHAROptions) => {
const name = `${testInfo.titlePath
.map((x) => x.replace(/\.spec\.ts$/, ""))
.map((x) => x.replace(/@[^\s]+$/, ""))
.map(slugify)
.join(" > ")} ${index++}`;
if (process.env.E2E_HAR !== "false") {
if (
process.env.E2E_HAR !== undefined &&
process.env.E2E_HAR !== "false"
) {
await page.routeFromHAR(`./e2e/har/${name}.zip`, {
url: /api\/graphql/,
notFound: "abort",
...routeFromHAROptions
...routeFromHAROptions,
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion e2e/har-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const getEnv = (name: string) => {
*/

export const harReplayGraphqlEndpointQueryParam =
process.env.E2E_HAR !== "false"
process.env.E2E_HAR !== undefined && process.env.E2E_HAR !== "false"
bprusinowski marked this conversation as resolved.
Show resolved Hide resolved
? `flag__graphql.endpoint=${encodeURIComponent(
JSON.stringify(`http://localhost:3000/api/graphql`)
)}`
Expand Down