@@ -114,9 +114,7 @@ vi.mock("../package-manager", async (importOriginal) => ({
114114 },
115115}));
116116
117- vi.mock("../autoconfig/details");
118117vi.mock("../autoconfig/run");
119- vi.mock("../autoconfig/frameworks");
120118vi.mock("../autoconfig/frameworks/utils/packages");
121119vi.mock("../autoconfig/c3-vendor/command");
122120
@@ -566,13 +564,13 @@ describe("deploy", () => {
566564 `);
567565 });
568566
569- it("should error helpfully if pages_build_output_dir is set in wrangler.toml", async () => {
567+ it("should error helpfully if pages_build_output_dir is set in wrangler.toml when --x-autoconfig=false ", async () => {
570568 writeWranglerConfig({
571569 pages_build_output_dir: "public",
572570 name: "test-name",
573571 });
574572 await expect(
575- runWrangler("deploy")
573+ runWrangler("deploy --x-autoconfig=false ")
576574 ).rejects.toThrowErrorMatchingInlineSnapshot(
577575 `
578576 [Error: It looks like you've run a Workers-specific command in a Pages project.
@@ -581,6 +579,22 @@ describe("deploy", () => {
581579 );
582580 });
583581
582+ it("should error helpfully if pages_build_output_dir is set in wrangler.toml and --x-autoconfig is provided", async () => {
583+ mockConfirm({
584+ text: "Are you sure that you want to proceed?",
585+ result: true,
586+ });
587+
588+ writeWranglerConfig({
589+ pages_build_output_dir: "public",
590+ name: "test-name",
591+ });
592+ await expect(runWrangler("deploy --x-autoconfig")).rejects.toThrowError();
593+ expect(std.warn).toContain(
594+ "It seems that you have run `wrangler deploy` on a Pages project, `wrangler pages deploy` should be used instead."
595+ );
596+ });
597+
584598 it("should attempt to run the autoconfig flow when pages_build_output_dir and (--x-autoconfig is used)", async () => {
585599 writeWranglerConfig({
586600 pages_build_output_dir: "public",
@@ -589,7 +603,7 @@ describe("deploy", () => {
589603
590604 const getDetailsForAutoConfigSpy = vi
591605 .spyOn(await import("../autoconfig/details"), "getDetailsForAutoConfig")
592- .mockResolvedValue ({
606+ .mockResolvedValueOnce ({
593607 configured: false,
594608 projectPath: process.cwd(),
595609 workerName: "test-name",
@@ -628,7 +642,7 @@ describe("deploy", () => {
628642
629643 const getDetailsForAutoConfigSpy = vi
630644 .spyOn(await import("../autoconfig/details"), "getDetailsForAutoConfig")
631- .mockResolvedValue ({
645+ .mockResolvedValueOnce ({
632646 configured: false,
633647 projectPath: process.cwd(),
634648 workerName: "test-name",
@@ -16603,13 +16617,13 @@ export default{
1660316617 expect(std.warn).toMatchInlineSnapshot(`""`);
1660416618 });
1660516619
16606- it("should not delegate to open-next deploy when the --x-autoconfig flag is not provided", async () => {
16620+ it("should not delegate to open-next deploy when --x-autoconfig=false is provided", async () => {
1660716621 const runCommandSpy = (await import("../autoconfig/c3-vendor/command"))
1660816622 .runCommand;
1660916623
1661016624 await mockOpenNextLikeProject();
1661116625
16612- await runWrangler("deploy");
16626+ await runWrangler("deploy --x-autoconfig=false ");
1661316627
1661416628 expect(runCommandSpy).not.toHaveBeenCalledOnce();
1661516629
0 commit comments