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)(
|
||||
"%s diagnostics remain available after the popover reopens",
|
||||
async (action) => {
|
||||
|
||||
@@ -157,6 +157,7 @@ export const PublishButton = ({ projectId }: PublishProps) => {
|
||||
const isMounted = useRef(false);
|
||||
const requestBaselineBuildId = useRef<string>();
|
||||
const hasStartedPublishRequest = useRef(false);
|
||||
const sessionPublishesRef = useRef<SessionPublish[]>([]);
|
||||
const refreshGeneration = useRef(0);
|
||||
const recoveredPoll = useRef<{
|
||||
generation: number;
|
||||
@@ -270,6 +271,24 @@ export const PublishButton = ({ projectId }: PublishProps) => {
|
||||
);
|
||||
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 isNewBuild =
|
||||
build.buildId !== undefined &&
|
||||
@@ -659,7 +678,6 @@ export const PublishButton = ({ projectId }: PublishProps) => {
|
||||
}
|
||||
}, [publishDialog, resetValidationState]);
|
||||
|
||||
const sessionPublishesRef = useRef(visiblePublishes);
|
||||
sessionPublishesRef.current = visiblePublishes;
|
||||
const [diagnosticsSelection, setDiagnosticsSelection] = useState<{
|
||||
target: "static" | "site";
|
||||
|
||||
Reference in new issue
Block a user