mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Upgrade Cypress dependency
This gets rid of the testing-library-* and cypress-vite-devserver dependencies and updates the specs according to the latest Cypress documentation. Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
@@ -1,25 +1,31 @@
|
||||
import type { ProjectInfo } from "@app/project";
|
||||
|
||||
import BranchSelector from "./BranchSelector.svelte";
|
||||
import { fireEvent, render } from "@testing-library/svelte";
|
||||
import "@public/index.css";
|
||||
|
||||
const project: ProjectInfo = {
|
||||
head: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
urn: "rad:git:hnrkqdpm9ub19oc8dccx44echy76hzfsezyio",
|
||||
name: "nakamoto",
|
||||
description: "Privacy-preserving Bitcoin light-client implementation in Rust",
|
||||
defaultBranch: "master",
|
||||
remotes: ["rad:git:hnrkqdpm9ub19oc8dccx44echy76hzfsezyio"],
|
||||
delegates: [
|
||||
{
|
||||
type: "direct",
|
||||
id: "hyn9diwfnytahjq8u3iw63h9jte1ydcatxax3saymwdxqu1zo645pe",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
project: {
|
||||
head: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
urn: "rad:git:hnrkqdpm9ub19oc8dccx44echy76hzfsezyio",
|
||||
name: "nakamoto",
|
||||
description:
|
||||
"Privacy-preserving Bitcoin light-client implementation in Rust",
|
||||
defaultBranch: "master",
|
||||
maintainers: ["rad:git:hnrkqdpm9ub19oc8dccx44echy76hzfsezyio"],
|
||||
delegates: ["hyn9diwfnytahjq8u3iw63h9jte1ydcatxax3saymwdxqu1zo645pe"],
|
||||
},
|
||||
project,
|
||||
branches: { master: "e678629cd37c770c640a2cd997fc76303c815772" },
|
||||
revision: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
};
|
||||
|
||||
describe("Logic", () => {
|
||||
it("should show defaultBranch label and head commit if revision === head", () => {
|
||||
const { rerender } = render(BranchSelector, {
|
||||
cy.mount(BranchSelector, {
|
||||
props: defaultProps,
|
||||
});
|
||||
cy.get("div.stat.branch")
|
||||
@@ -28,9 +34,9 @@ describe("Logic", () => {
|
||||
cy.get("div.hash.mobile")
|
||||
.should("be.visible")
|
||||
.should("have.text", "e678629");
|
||||
|
||||
// If project.head is null we should get the head from branches.
|
||||
rerender({
|
||||
});
|
||||
it("if project.head is null we should get the head from branches", () => {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
project: {
|
||||
@@ -54,7 +60,7 @@ describe("Logic", () => {
|
||||
});
|
||||
|
||||
it("should show the branch dropdown if branches available", () => {
|
||||
render(BranchSelector, {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
branches: {
|
||||
@@ -76,7 +82,7 @@ describe("Logic", () => {
|
||||
});
|
||||
|
||||
it("should show feature-branch label and head commit, if branch label is passed as revision", () => {
|
||||
render(BranchSelector, {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
branches: {
|
||||
@@ -96,7 +102,7 @@ describe("Logic", () => {
|
||||
});
|
||||
|
||||
it("should show only commit if no branchLabel nor branches are available", () => {
|
||||
render(BranchSelector, {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
|
||||
@@ -113,7 +119,7 @@ describe("Logic", () => {
|
||||
});
|
||||
|
||||
it("should show only commit if branches are available but no branchLabel", () => {
|
||||
render(BranchSelector, {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
|
||||
@@ -129,7 +135,7 @@ describe("Logic", () => {
|
||||
});
|
||||
|
||||
it("should show defaultBranch label if revision === head", () => {
|
||||
render(BranchSelector, {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
@@ -144,7 +150,7 @@ describe("Logic", () => {
|
||||
|
||||
describe("Layout", () => {
|
||||
it("should show shortened commit when on mobile, and full hash when on desktop", () => {
|
||||
render(BranchSelector, {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
@@ -161,7 +167,9 @@ describe("Layout", () => {
|
||||
|
||||
describe("Events", () => {
|
||||
it("should dispatch a 'branchChanged' event on click", () => {
|
||||
const { getByText, component } = render(BranchSelector, {
|
||||
const branchChangedSpy = cy.spy().as("branchChangedSpy");
|
||||
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "feature-branch",
|
||||
@@ -170,18 +178,12 @@ describe("Events", () => {
|
||||
xyz: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
|
||||
},
|
||||
},
|
||||
}).then(({ component }) => {
|
||||
component.$on("branchChanged", branchChangedSpy);
|
||||
});
|
||||
|
||||
cy.get("div.commit div.stat.branch")
|
||||
.click()
|
||||
.then(() => {
|
||||
const branchLabel = getByText("xyz");
|
||||
|
||||
const mock = cy.spy();
|
||||
component.$on("branchChanged", mock);
|
||||
|
||||
fireEvent.click(branchLabel);
|
||||
expect(mock).to.have.been.calledOnce;
|
||||
});
|
||||
cy.get("body").contains("feature-branch").click();
|
||||
cy.get("body").contains("xyz").click();
|
||||
cy.get("@branchChangedSpy").should("have.been.called");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import PeerSelector from "./PeerSelector.svelte";
|
||||
import { fireEvent, render } from "@testing-library/svelte";
|
||||
import "@public/index.css";
|
||||
|
||||
const defaultProps = {
|
||||
peer: "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue",
|
||||
@@ -15,7 +13,7 @@ const defaultProps = {
|
||||
|
||||
describe("Logic", () => {
|
||||
it("show delegate name and badge", () => {
|
||||
render(PeerSelector, {
|
||||
cy.mount(PeerSelector, {
|
||||
props: defaultProps,
|
||||
});
|
||||
cy.get("span.peer-id").should("have.text", "sebastinez");
|
||||
@@ -23,7 +21,7 @@ describe("Logic", () => {
|
||||
});
|
||||
|
||||
it("show peer id with badge if no name available", () => {
|
||||
render(PeerSelector, {
|
||||
cy.mount(PeerSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
peers: [
|
||||
@@ -39,12 +37,13 @@ describe("Logic", () => {
|
||||
});
|
||||
|
||||
it("show only peer id if no additional data available", () => {
|
||||
render(PeerSelector, {
|
||||
cy.mount(PeerSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
peers: [
|
||||
{
|
||||
id: "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue",
|
||||
delegate: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -55,7 +54,7 @@ describe("Logic", () => {
|
||||
|
||||
describe("Layout", () => {
|
||||
it("should highlight the current peer", () => {
|
||||
render(PeerSelector, {
|
||||
cy.mount(PeerSelector, {
|
||||
props: { ...defaultProps },
|
||||
});
|
||||
cy.get("div.selector").click();
|
||||
@@ -65,8 +64,9 @@ describe("Layout", () => {
|
||||
|
||||
describe("Events", () => {
|
||||
it("dispatch peerChanged event if clicking on a peer", () => {
|
||||
cy.viewport("macbook-13");
|
||||
const { getByText, component } = render(PeerSelector, {
|
||||
const peerChangedSpy = cy.spy().as("peerChangedSpy");
|
||||
|
||||
cy.mount(PeerSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
peers: [
|
||||
@@ -82,17 +82,12 @@ describe("Events", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
}).then(({ component }) => {
|
||||
component.$on("peerChanged", peerChangedSpy);
|
||||
});
|
||||
|
||||
cy.get("div.selector")
|
||||
.click()
|
||||
.then(() => {
|
||||
const peer = getByText("cloudhead");
|
||||
const mock = cy.spy();
|
||||
component.$on("peerChanged", mock);
|
||||
|
||||
fireEvent.click(peer);
|
||||
expect(mock).to.have.been.calledOnce;
|
||||
});
|
||||
cy.get("body").contains("sebastinez").click();
|
||||
cy.get("body").contains("cloudhead").click();
|
||||
cy.get("@peerChangedSpy").should("have.been.called");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
error = e;
|
||||
}
|
||||
});
|
||||
|
||||
let latestBlock: number;
|
||||
config.provider.on("block", (block: number) => {
|
||||
latestBlock = block;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -91,7 +96,7 @@
|
||||
<span class="highlight">{registrationOwner}</span>
|
||||
{:else if $state.connection === State.WaitingToRegister && $state.commitmentBlock}
|
||||
<BlockTimer
|
||||
{config}
|
||||
{latestBlock}
|
||||
startBlock={$state.commitmentBlock}
|
||||
duration={$state.minAge} />
|
||||
{:else}
|
||||
|
||||
Reference in New Issue
Block a user