Skip to content

Commit 853a7fe

Browse files
committed
fix: Fix incorrect notification when registering snap name in the global store
1 parent 5aef531 commit 853a7fe

2 files changed

Lines changed: 69 additions & 2 deletions

File tree

static/js/publisher/pages/RegisterSnap/RegistrationError.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ type Props = {
1111
function RegistrationError({ snapName, errorCode, isPrivate, store }: Props) {
1212
if (errorCode === "name-review-required") {
1313
return (
14-
<Notification severity="information">
15-
<strong>{snapName}</strong> has been submitted for review
14+
<Notification severity="caution">
15+
All snap names are currently subject to a review. Please see{" "}
16+
<a href="https://forum.snapcraft.io/t/manual-review-of-all-new-snap-name-registrations/39440">
17+
https://forum.snapcraft.io/t/manual-review-of-all-new-snap-name-registrations/39440
18+
</a>{" "}
19+
for details. Follow this link to submit a name request for your snap:
20+
<a href="https://dashboard.snapcraft.io/register-snap">
21+
https://dashboard.snapcraft.io/register-snap
22+
</a>
1623
</Notification>
1724
);
1825
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { BrowserRouter } from "react-router-dom";
2+
import { render, screen } from "@testing-library/react";
3+
import "@testing-library/jest-dom";
4+
5+
import RegistrationError from "../RegistrationError";
6+
7+
function renderComponent(errorCode: string) {
8+
return render(
9+
<BrowserRouter>
10+
<RegistrationError
11+
snapName="test-snap-name"
12+
isPrivate="private"
13+
store="ubuntu"
14+
errorCode={errorCode}
15+
/>
16+
</BrowserRouter>,
17+
);
18+
}
19+
20+
describe("RegistrationError", () => {
21+
test("points user to dashboard when registering snap in global store", () => {
22+
renderComponent("name-review-required");
23+
expect(
24+
screen.getByRole("link", {
25+
name: "https://dashboard.snapcraft.io/register-snap",
26+
}),
27+
).toBeInTheDocument();
28+
});
29+
30+
test("informs user if they already own snap", () => {
31+
renderComponent("already_owned");
32+
const el = screen.getByText("You already own", { exact: false });
33+
expect(el.textContent).toEqual("You already own 'test-snap-name'.");
34+
});
35+
36+
test("directs user to request a reserved name", () => {
37+
renderComponent("reserved_name");
38+
expect(
39+
screen.getByRole("link", { name: "request a reserved name" }),
40+
).toBeInTheDocument();
41+
});
42+
43+
test("informs user if no permission to register snap", () => {
44+
renderComponent("no-permission");
45+
expect(
46+
screen.getByText(
47+
"You do not have permission to register snaps to this store. Contact the store administrator.",
48+
),
49+
).toBeInTheDocument();
50+
});
51+
52+
test("informs user if snap needs to be registered", () => {
53+
renderComponent("other_error_code");
54+
expect(
55+
screen.getByText(
56+
"Before you can push your snap to the store, its name must be registered",
57+
),
58+
).toBeInTheDocument();
59+
});
60+
});

0 commit comments

Comments
 (0)