mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
fix: preserve confirmed publish results during refresh
This commit is contained in:
1 parent
31af7cf3c2
commit
a04d6c287c
2 files changed
+45
-1
No files matched your search
@@ -592,6 +592,32 @@ test.each(["success", "failed"] as const)(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test("a confirmed site success survives a stale Build timeout during popover refresh", async () => {
|
||||||
|
publish = async () => {
|
||||||
|
project = makeProject("project", {
|
||||||
|
buildId: "accepted",
|
||||||
|
publishStatus: "PENDING",
|
||||||
|
});
|
||||||
|
project.latestBuildVirtual!.createdAt = new Date(
|
||||||
|
Date.now() - 10 * 60_000
|
||||||
|
).toISOString();
|
||||||
|
return accept();
|
||||||
|
};
|
||||||
|
job = async () => ({ status: "success" });
|
||||||
|
await mount();
|
||||||
|
const previousRefreshes = requests.filter(
|
||||||
|
({ route }) => route === "domain.project"
|
||||||
|
).length;
|
||||||
|
await click("Publish");
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(
|
||||||
|
requests.filter(({ route }) => route === "domain.project").length
|
||||||
|
).toBeGreaterThanOrEqual(previousRefreshes + 2)
|
||||||
|
);
|
||||||
|
expect(button("See logs")).toBeDefined();
|
||||||
|
expect(button("See issues")).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
test.each(["validation", "publish"] as const)(
|
test.each(["validation", "publish"] as const)(
|
||||||
"%s diagnostics remain available after the popover reopens",
|
"%s diagnostics remain available after the popover reopens",
|
||||||
async (action) => {
|
async (action) => {
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ export const PublishButton = ({ projectId }: PublishProps) => {
|
|||||||
const isMounted = useRef(false);
|
const isMounted = useRef(false);
|
||||||
const requestBaselineBuildId = useRef<string>();
|
const requestBaselineBuildId = useRef<string>();
|
||||||
const hasStartedPublishRequest = useRef(false);
|
const hasStartedPublishRequest = useRef(false);
|
||||||
|
const sessionPublishesRef = useRef<SessionPublish[]>([]);
|
||||||
const refreshGeneration = useRef(0);
|
const refreshGeneration = useRef(0);
|
||||||
const recoveredPoll = useRef<{
|
const recoveredPoll = useRef<{
|
||||||
generation: number;
|
generation: number;
|
||||||
@@ -270,6 +271,24 @@ export const PublishButton = ({ projectId }: PublishProps) => {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const confirmedPublish = sessionPublishesRef.current.find(
|
||||||
|
(item) =>
|
||||||
|
item.target === "site" &&
|
||||||
|
item.buildId === build.buildId &&
|
||||||
|
item.status !== "pending"
|
||||||
|
);
|
||||||
|
if (confirmedPublish?.status === "success") {
|
||||||
|
setPublishErrorState((current) =>
|
||||||
|
current?.source === "status" ? undefined : current
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
confirmedPublish?.status === "failed" &&
|
||||||
|
build.publishStatus !== "PUBLISHED"
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { status, statusContent } = getPublishStatusDisplay(build);
|
const { status, statusContent } = getPublishStatusDisplay(build);
|
||||||
const isNewBuild =
|
const isNewBuild =
|
||||||
build.buildId !== undefined &&
|
build.buildId !== undefined &&
|
||||||
@@ -659,7 +678,6 @@ export const PublishButton = ({ projectId }: PublishProps) => {
|
|||||||
}
|
}
|
||||||
}, [publishDialog, resetValidationState]);
|
}, [publishDialog, resetValidationState]);
|
||||||
|
|
||||||
const sessionPublishesRef = useRef(visiblePublishes);
|
|
||||||
sessionPublishesRef.current = visiblePublishes;
|
sessionPublishesRef.current = visiblePublishes;
|
||||||
const [diagnosticsSelection, setDiagnosticsSelection] = useState<{
|
const [diagnosticsSelection, setDiagnosticsSelection] = useState<{
|
||||||
target: "static" | "site";
|
target: "static" | "site";
|
||||||
|
|||||||
Reference in new issue
Block a user