Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"test:e2e:ci": "npx start-server-and-test serve:e2e http-get://localhost:8081/ cypress:run",
"test:e2e:no-record": "npx wait-on -r http-get://localhost:8081/ && npx start-server-and-test serve:e2e http-get://localhost:8081/ cypress:run:no-record",
"test:e2e:docker": "docker-compose run --user $(id -u):$(id -g) e2e",
"lint-staged": "lint-staged"
"lint-staged": "lint-staged",
"postinstall": "patch-package"
},
"browserslist": {
"development": [
Expand Down Expand Up @@ -53,17 +54,19 @@
"@types/node": "^20.19.0",
"@types/react": "^18.3.23",
"@types/react-dom": "^18.3.7",
"babel-jest": "^29.7.0",
"babel-jest": "^30.0.2",
"concurrently": "^9.1.2",
"cross-env": "^7.0.3",
"cypress": "^14.4.1",
"eslint": "^9.28.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest": "^30.0.2",
"jest-environment-jsdom": "^30.0.2",
"jest-websocket-mock": "^2.5.0",
"lerna": "^8.1.8",
"lint-staged": "^15.5.2",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"prettier": "^3.6.0",
"rimraf": "^6.0.1",
"ts-jest-resolver": "^2.0.1",
Expand Down
24 changes: 12 additions & 12 deletions packages/brick-container/src/loadBootstrapData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ describe("loadBootstrapData", () => {
window.BOOTSTRAP_FILE = "bootstrap.app-a.json";
window.APP_ROOT = "sa-static/app-a/versions/1.88.0/webroot/";
const promise = loadBootstrapData();
expect(RuntimeApi_runtimeMicroAppStandalone).toBeCalledWith("app-a", {
expect(RuntimeApi_runtimeMicroAppStandalone).toHaveBeenCalledWith("app-a", {
version: "1.88.0",
});
const data = await promise;
Expand Down Expand Up @@ -358,8 +358,8 @@ describe("loadBootstrapData", () => {
});

await fulfilStoryboard(data.storyboards[0]);
expect(RuntimeApi_runtimeMicroAppStandalone).toBeCalledTimes(1);
expect(registerMocks).toBeCalledTimes(1);
expect(RuntimeApi_runtimeMicroAppStandalone).toHaveBeenCalledTimes(1);
expect(registerMocks).toHaveBeenCalledTimes(1);

expect(data.storyboards[0]).toEqual({
app: {
Expand Down Expand Up @@ -428,7 +428,7 @@ describe("loadBootstrapData", () => {
window.BOOTSTRAP_FILE = "bootstrap.mini.g.json";

const promise = loadBootstrapData();
expect(RuntimeApi_runtimeMicroAppStandalone).not.toBeCalled();
expect(RuntimeApi_runtimeMicroAppStandalone).not.toHaveBeenCalled();

const data = await promise;
expect(data).toEqual({
Expand Down Expand Up @@ -705,7 +705,7 @@ describe("loadBootstrapData", () => {
},
},
});
expect(consoleWarn).toBeCalledTimes(1);
expect(consoleWarn).toHaveBeenCalledTimes(1);
});

test("standalone with invalid conf.yaml", async () => {
Expand All @@ -719,8 +719,8 @@ describe("loadBootstrapData", () => {
await expect(promise).rejects.toThrowErrorMatchingInlineSnapshot(
`"Invalid conf.yaml"`
);
expect(consoleWarn).toBeCalledTimes(1);
expect(consoleError).toBeCalledTimes(1);
expect(consoleWarn).toHaveBeenCalledTimes(1);
expect(consoleError).toHaveBeenCalledTimes(1);
});

test("standalone with conf.yaml of user_config_by_apps", async () => {
Expand All @@ -745,7 +745,7 @@ describe("loadBootstrapData", () => {
},
],
});
expect(consoleWarn).toBeCalledTimes(1);
expect(consoleWarn).toHaveBeenCalledTimes(1);
});

test("standalone with conf.yaml of missing in user_config_by_apps", async () => {
Expand All @@ -768,9 +768,9 @@ describe("loadBootstrapData", () => {
},
],
});
expect(consoleWarn).toBeCalledTimes(1);
expect(consoleWarn).toHaveBeenCalledTimes(1);
await fulfilStoryboard(data.storyboards[0]);
expect(consoleWarn).toBeCalledTimes(2);
expect(consoleWarn).toHaveBeenCalledTimes(2);
consoleWarn.mockReset();
});

Expand All @@ -794,7 +794,7 @@ describe("loadBootstrapData", () => {
},
],
});
expect(consoleWarn).toBeCalledTimes(1);
expect(consoleWarn).toHaveBeenCalledTimes(1);
});

test("non-standalone", async () => {
Expand Down Expand Up @@ -832,7 +832,7 @@ describe("loadBootstrapData", () => {
});

await fulfilStoryboard(data.storyboards[0]);
expect(mockGetAppStoryboardV2).toBeCalledTimes(1);
expect(mockGetAppStoryboardV2).toHaveBeenCalledTimes(1);

expect(data.storyboards[0]).toEqual({
app: {
Expand Down
8 changes: 4 additions & 4 deletions packages/brick-container/src/loadCheckLogin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ describe("loadCheckLogin", () => {
test("should work for when not logged in", async () => {
mockCheckLogin.mockResolvedValueOnce({ loggedIn: false });
await loadCheckLogin();
expect(auth.authenticate).not.toBeCalled();
expect(auth.authenticate).not.toHaveBeenCalled();
});

test("should work for when logged in", async () => {
mockCheckLogin.mockResolvedValueOnce({ loggedIn: true });
await loadCheckLogin();
expect(auth.authenticate).toBeCalledWith({
expect(auth.authenticate).toHaveBeenCalledWith({
loggedIn: true,
});
});

test("should work for no auth guard", async () => {
window.NO_AUTH_GUARD = true;
await loadCheckLogin();
expect(mockCheckLogin).not.toBeCalled();
expect(auth.authenticate).not.toBeCalled();
expect(mockCheckLogin).not.toHaveBeenCalled();
expect(auth.authenticate).not.toHaveBeenCalled();
window.NO_AUTH_GUARD = false;
});
});
4 changes: 3 additions & 1 deletion packages/brick-container/src/preview/initialize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ describe("initialize", () => {
"https://dev.easyops.local"
);
expect(ok).toBe(false);
expect(consoleError).toBeCalledWith(expect.stringContaining("disallowed"));
expect(consoleError).toHaveBeenCalledWith(
expect.stringContaining("disallowed")
);

(window as any).location = location;
});
Expand Down
12 changes: 6 additions & 6 deletions packages/brick-container/src/preview/listen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ describe("listen", () => {

await (global as any).flushPromises();

expect(loadBricksImperatively).toBeCalledWith(
expect(loadBricksImperatively).toHaveBeenCalledWith(
["visual-builder.inject-preview-agent"],
[
{
id: "bricks/visual-builder",
},
]
);
expect(injectPreview).toBeCalledWith(location.origin, {
expect(injectPreview).toHaveBeenCalledWith(location.origin, {
foo: "bar",
});
});
Expand Down Expand Up @@ -87,15 +87,15 @@ describe("listen", () => {

await (global as any).flushPromises();

expect(loadBricksImperatively).toBeCalledWith(
expect(loadBricksImperatively).toHaveBeenCalledWith(
["ui-test.inject-preview-agent"],
[
{
id: "bricks/ui-test",
},
]
);
expect(injectUITest).toBeCalledWith(location.origin, {
expect(injectUITest).toHaveBeenCalledWith(location.origin, {
foo: "bar",
});
});
Expand All @@ -111,7 +111,7 @@ describe("listen", () => {

await (global as any).flushPromises();

expect(loadBricksImperatively).not.toBeCalled();
expect(loadBricksImperatively).not.toHaveBeenCalled();
});

test("initialize failed", async () => {
Expand Down Expand Up @@ -141,6 +141,6 @@ describe("listen", () => {

await (global as any).flushPromises();

expect(loadBricksImperatively).not.toBeCalled();
expect(loadBricksImperatively).not.toHaveBeenCalled();
});
});
32 changes: 16 additions & 16 deletions packages/cook/src/cook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe("evaluate", () => {
if (!typescript && !containsExperimental(source)) {
expect(() =>
equivalentFunc(source, attemptToVisitGlobals)(...cloneDeep(args))
).toThrowError();
).toThrow();
}
expect(() => func(...cloneDeep(args))).toThrowErrorMatchingSnapshot();
}
Expand Down Expand Up @@ -242,7 +242,7 @@ describe("evaluate", () => {
return a;
}
`;
expect(() => equivalentFunc(source, new Set())).not.toThrowError();
expect(() => equivalentFunc(source, new Set())).not.toThrow();
const { function: funcAst, attemptToVisitGlobals } =
precookFunction(source);
const globalVariables = supply(
Expand Down Expand Up @@ -271,7 +271,7 @@ describe("evaluate", () => {
if (!containsExperimental(source)) {
expect(() =>
equivalentFunc(source, attemptToVisitGlobals, true)
).toThrowError();
).toThrow();
}
expect(() =>
cook(exprAst, source, { globalVariables })
Expand Down Expand Up @@ -328,7 +328,7 @@ describe("evaluate", () => {
}) as Function;

func(1);
expect(beforeEvaluate).toBeCalledTimes(14);
expect(beforeEvaluate).toHaveBeenCalledTimes(14);
expect(beforeEvaluate).toHaveBeenNthCalledWith(
1,
expect.objectContaining({
Expand All @@ -354,25 +354,25 @@ describe("evaluate", () => {
value: true,
})
);
expect(beforeEvaluate).not.toBeCalledWith(
expect(beforeEvaluate).not.toHaveBeenCalledWith(
expect.objectContaining({
type: "Literal",
value: false,
})
);
expect(beforeEvaluate).not.toBeCalledWith(
expect(beforeEvaluate).not.toHaveBeenCalledWith(
expect.objectContaining({
type: "ThrowStatement",
})
);
expect(beforeCall).toBeCalledTimes(1);
expect(beforeCall).toBeCalledWith(
expect(beforeCall).toHaveBeenCalledTimes(1);
expect(beforeCall).toHaveBeenCalledWith(
expect.objectContaining({
type: "FunctionDeclaration",
})
);
expect(beforeBranch).toBeCalledTimes(1);
expect(beforeBranch).toBeCalledWith(
expect(beforeBranch).toHaveBeenCalledTimes(1);
expect(beforeBranch).toHaveBeenCalledWith(
expect.objectContaining({
type: "IfStatement",
}),
Expand All @@ -381,7 +381,7 @@ describe("evaluate", () => {

jest.clearAllMocks();
func(0);
expect(beforeEvaluate).toBeCalledTimes(12);
expect(beforeEvaluate).toHaveBeenCalledTimes(12);
expect(beforeEvaluate).toHaveBeenNthCalledWith(
7,
expect.objectContaining({
Expand All @@ -401,14 +401,14 @@ describe("evaluate", () => {
value: null,
})
);
expect(beforeCall).toBeCalledTimes(1);
expect(beforeCall).toBeCalledWith(
expect(beforeCall).toHaveBeenCalledTimes(1);
expect(beforeCall).toHaveBeenCalledWith(
expect.objectContaining({
type: "FunctionDeclaration",
})
);
expect(beforeBranch).toBeCalledTimes(1);
expect(beforeBranch).toBeCalledWith(
expect(beforeBranch).toHaveBeenCalledTimes(1);
expect(beforeBranch).toHaveBeenCalledWith(
expect.objectContaining({
type: "IfStatement",
}),
Expand All @@ -423,7 +423,7 @@ describe("evaluate", () => {
return "abc".replace(reg, "");
}
`;
expect(() => equivalentFunc(source, new Set())).not.toThrowError();
expect(() => equivalentFunc(source, new Set())).not.toThrow();
const { function: funcAst, attemptToVisitGlobals } =
precookFunction(source);
const globalVariables = supply(
Expand Down
14 changes: 7 additions & 7 deletions packages/cook/src/precook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("", () => {
expect(Array.from(precook(expression, { expressionOnly: true }))).toEqual(
result
);
expect(consoleWarn).not.toBeCalled();
expect(consoleWarn).not.toHaveBeenCalled();
});

it.each<[string, string, string[]]>([
Expand Down Expand Up @@ -506,7 +506,7 @@ describe("", () => {
})
)
).toEqual(result);
expect(consoleWarn).not.toBeCalled();
expect(consoleWarn).not.toHaveBeenCalled();
});

it("should visit nodes", () => {
Expand All @@ -524,7 +524,7 @@ describe("", () => {
precook(func, {
visitors,
});
expect(visitors.CallExpression).not.toBeCalled();
expect(visitors.CallExpression).not.toHaveBeenCalled();
expect(visitors.FunctionDeclaration).toHaveBeenCalledWith(
expect.objectContaining({
type: "FunctionDeclaration",
Expand Down Expand Up @@ -556,7 +556,7 @@ describe("", () => {
withParent: true,
hooks: { beforeVisit, beforeVisitGlobal, beforeVisitUnknown },
});
expect(beforeVisit).toBeCalledTimes(5);
expect(beforeVisit).toHaveBeenCalledTimes(5);
expect(beforeVisit).toHaveBeenNthCalledWith(
1,
expect.objectContaining({
Expand Down Expand Up @@ -649,7 +649,7 @@ describe("", () => {
]
);
expect(beforeVisitGlobal).toHaveBeenCalledTimes(1);
expect(beforeVisitGlobal).toBeCalledWith(
expect(beforeVisitGlobal).toHaveBeenCalledWith(
expect.objectContaining({
type: "Identifier",
name: "b",
Expand Down Expand Up @@ -677,7 +677,7 @@ describe("", () => {
]
);
expect(beforeVisitUnknown).toHaveBeenCalledTimes(1);
expect(beforeVisitUnknown).toBeCalledWith(
expect(beforeVisitUnknown).toHaveBeenCalledWith(
expect.objectContaining({
type: "DebuggerStatement",
}),
Expand Down Expand Up @@ -710,7 +710,7 @@ describe("", () => {
withParent: true,
hooks: { beforeVisit },
});
expect(beforeVisit).toBeCalledTimes(4);
expect(beforeVisit).toHaveBeenCalledTimes(4);
expect(beforeVisit).toHaveBeenNthCalledWith(
4,
expect.objectContaining({
Expand Down
4 changes: 2 additions & 2 deletions packages/cook/src/precookFunction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ describe("precookFunction", () => {
"function test() { this }"
);
expect(Array.from(attemptToVisitGlobals.values())).toEqual([]);
expect(consoleWarn).toBeCalledTimes(1);
expect(consoleWarn).toBeCalledWith(
expect(consoleWarn).toHaveBeenCalledTimes(1);
expect(consoleWarn).toHaveBeenCalledWith(
"Unsupported node type `ThisExpression`"
);
});
Expand Down
Loading
Loading