mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Replace Cypress with Playwright
Playwright is more flexible and has better developer experience than Cypress.
We add end to end tests covering:
- project source browsing
- tree view
- commit list view
- commit view
- routing
- hash based
- history API based
- clipboard copy paste functionality
- seed view
- project search
- landing page view
- settings
Co-authored-by: Sebastian Martinez <me@sebastinez.dev>
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
co-authored by
Sebastian Martinez
parent
d740d7e5a1
commit
9cb9332e88
@@ -6,7 +6,7 @@
|
||||
import Loading from "@app/Loading.svelte";
|
||||
import Message from "@app/Message.svelte";
|
||||
import Widget from "@app/base/projects/Widget.svelte";
|
||||
import config from "@app/config.json";
|
||||
import { config } from "@app/config";
|
||||
import { Project } from "@app/project";
|
||||
import { setOpenGraphMetaTag, twemoji } from "@app/utils";
|
||||
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
import type { ProjectInfo } from "@app/project";
|
||||
|
||||
import BranchSelector from "./BranchSelector.svelte";
|
||||
|
||||
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,
|
||||
branches: { master: "e678629cd37c770c640a2cd997fc76303c815772" },
|
||||
revision: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
};
|
||||
|
||||
describe("Logic", () => {
|
||||
it("should show defaultBranch label and head commit if revision === head", () => {
|
||||
cy.mount(BranchSelector, {
|
||||
props: defaultProps,
|
||||
});
|
||||
cy.get("div.stat.branch")
|
||||
.should("be.visible")
|
||||
.should("have.text", "master");
|
||||
cy.get("div.hash.layout-mobile")
|
||||
.should("be.visible")
|
||||
.should("have.text", "e678629");
|
||||
});
|
||||
it("if project.head is null we should get the head from branches", () => {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
project: {
|
||||
...project,
|
||||
head: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
cy.get("div.stat.branch")
|
||||
.should("be.visible")
|
||||
.should("have.text", "master");
|
||||
cy.get("div.hash.layout-mobile")
|
||||
.should("be.visible")
|
||||
.should("have.text", "e678629");
|
||||
});
|
||||
|
||||
it("should show the branch dropdown if branches available", () => {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
branches: {
|
||||
master: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
"feature-branch": "29e8b7b0f3019b8e8a6d9bfb0964ee78f4ff12f5",
|
||||
xyz: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
|
||||
},
|
||||
},
|
||||
});
|
||||
cy.get("div.commit div.stat.branch").click();
|
||||
cy.get("div.dropdown div.dropdown-item")
|
||||
.first()
|
||||
.should("contain.text", "feature-branch")
|
||||
.next()
|
||||
.should("contain.text", "master")
|
||||
.should("have.class", "selected")
|
||||
.next()
|
||||
.should("contain.text", "xyz");
|
||||
});
|
||||
|
||||
it("should show feature-branch label and head commit, if branch label is passed as revision", () => {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
branches: {
|
||||
master: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
"feature-branch": "29e8b7b0f3019b8e8a6d9bfb0964ee78f4ff12f5",
|
||||
xyz: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
|
||||
},
|
||||
revision: "feature-branch",
|
||||
},
|
||||
});
|
||||
cy.get("div.stat.branch")
|
||||
.should("be.visible")
|
||||
.should("have.text", "feature-branch");
|
||||
cy.get("div.hash.layout-mobile")
|
||||
.should("be.visible")
|
||||
.should("have.text", "29e8b7b");
|
||||
});
|
||||
|
||||
it("should show only commit if no branchLabel nor branches are available", () => {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
|
||||
branches: {},
|
||||
},
|
||||
});
|
||||
cy.get("div.hash.layout-mobile")
|
||||
.should("be.visible")
|
||||
.should("have.text", "debf82e");
|
||||
cy.viewport("macbook-13");
|
||||
cy.get("div.hash.layout-desktop")
|
||||
.should("be.visible")
|
||||
.should("have.text", "debf82ef3623ec11751a993bda85bac2ff1c6f00");
|
||||
});
|
||||
|
||||
it("should show only commit if branches are available but no branchLabel", () => {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
|
||||
},
|
||||
});
|
||||
cy.get("div.hash.layout-mobile")
|
||||
.should("be.visible")
|
||||
.should("have.text", "debf82e");
|
||||
cy.viewport("macbook-13");
|
||||
cy.get("div.hash.layout-desktop")
|
||||
.should("be.visible")
|
||||
.should("have.text", "debf82ef3623ec11751a993bda85bac2ff1c6f00");
|
||||
});
|
||||
|
||||
it("should show defaultBranch label if revision === head", () => {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
branches: {},
|
||||
},
|
||||
});
|
||||
cy.get("div.stat.branch.not-allowed")
|
||||
.should("be.visible")
|
||||
.should("have.text", "master");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Layout", () => {
|
||||
it("should show shortened commit when on mobile, and full hash when on desktop", () => {
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "e678629cd37c770c640a2cd997fc76303c815772",
|
||||
},
|
||||
});
|
||||
cy.viewport("iphone-x");
|
||||
cy.get("div.hash.layout-mobile").should("be.visible");
|
||||
cy.get("div.hash.layout-desktop").should("not.be.visible");
|
||||
cy.viewport("macbook-15");
|
||||
cy.get("div.hash.layout-mobile").should("not.be.visible");
|
||||
cy.get("div.hash.layout-desktop").should("be.visible");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Events", () => {
|
||||
it("should dispatch a 'branchChanged' event on click", () => {
|
||||
const branchChangedSpy = cy.spy().as("branchChangedSpy");
|
||||
|
||||
cy.mount(BranchSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
revision: "feature-branch",
|
||||
branches: {
|
||||
"feature-branch": "29e8b7b0f3019b8e8a6d9bfb0964ee78f4ff12f5",
|
||||
xyz: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
|
||||
},
|
||||
},
|
||||
}).then(({ component }) => {
|
||||
component.$on("branchChanged", branchChangedSpy);
|
||||
});
|
||||
|
||||
cy.get("body").contains("feature-branch").click();
|
||||
cy.get("body").contains("xyz").click();
|
||||
cy.get("@branchChangedSpy").should("have.been.called");
|
||||
});
|
||||
});
|
||||
@@ -72,13 +72,14 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="commit" title="Switch branches">
|
||||
<div class="commit" title="Current branch">
|
||||
<!-- Check for branches listing feature -->
|
||||
{#if branchList.length > 0}
|
||||
{#if branchLabel}
|
||||
<Floating disabled={!showSelector}>
|
||||
<div
|
||||
slot="toggle"
|
||||
title="Change branch"
|
||||
class="stat branch"
|
||||
class:not-allowed={!showSelector}>
|
||||
{branchLabel}
|
||||
|
||||
@@ -35,7 +35,10 @@
|
||||
// Whether the mobile file tree is visible.
|
||||
let mobileFileTree = false;
|
||||
|
||||
const loadBlob = async (path: string, theme: Theme): Promise<proj.Blob> => {
|
||||
const loadBlob = async (
|
||||
path: string,
|
||||
theme: Theme,
|
||||
): Promise<proj.Blob | undefined> => {
|
||||
if (
|
||||
state.status === Status.Loaded &&
|
||||
state.path === path &&
|
||||
@@ -57,9 +60,12 @@
|
||||
);
|
||||
|
||||
state = { status: Status.Loading, path };
|
||||
state = { status: Status.Loaded, path, blob: await promise, theme };
|
||||
|
||||
return state.blob;
|
||||
try {
|
||||
state = { status: Status.Loaded, path, blob: await promise, theme };
|
||||
return state.blob;
|
||||
} catch (err) {
|
||||
console.warn("Could not load blob.");
|
||||
}
|
||||
};
|
||||
|
||||
// Get an image blob based on a relative path.
|
||||
@@ -206,7 +212,9 @@
|
||||
{#await getBlob}
|
||||
<Loading small center />
|
||||
{:then blob}
|
||||
<Blob {line} {blob} {getImage} {activeRoute} />
|
||||
{#if blob}
|
||||
<Blob {line} {blob} {getImage} {activeRoute} />
|
||||
{/if}
|
||||
{:catch}
|
||||
<Placeholder emoji="🍂">
|
||||
<span slot="title">
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
import PeerSelector from "./PeerSelector.svelte";
|
||||
|
||||
const defaultProps = {
|
||||
peer: "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue",
|
||||
peers: [
|
||||
{
|
||||
id: "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue",
|
||||
person: { name: "sebastinez" },
|
||||
delegate: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("Logic", () => {
|
||||
it("show delegate name and badge", () => {
|
||||
cy.mount(PeerSelector, {
|
||||
props: defaultProps,
|
||||
});
|
||||
cy.get("span.peer-id").should("have.text", "sebastinez");
|
||||
cy.get("span.badge.primary").should("have.text", "delegate");
|
||||
});
|
||||
|
||||
it("show peer id with badge if no name available", () => {
|
||||
cy.mount(PeerSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
peers: [
|
||||
{
|
||||
id: "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue",
|
||||
delegate: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
cy.get("span.peer-id").should("have.text", "hyyg55…p7ofue");
|
||||
cy.get("span.badge.primary").should("have.text", "delegate");
|
||||
});
|
||||
|
||||
it("show only peer id if no additional data available", () => {
|
||||
cy.mount(PeerSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
peers: [
|
||||
{
|
||||
id: "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue",
|
||||
delegate: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
cy.get("span.peer-id").should("have.text", "hyyg55…p7ofue");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Layout", () => {
|
||||
it("should highlight the current peer", () => {
|
||||
cy.mount(PeerSelector, {
|
||||
props: { ...defaultProps },
|
||||
});
|
||||
cy.get("div.selector").click();
|
||||
cy.get("div.dropdown-item").should("have.class", "selected");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Events", () => {
|
||||
it("dispatch peerChanged event if clicking on a peer", () => {
|
||||
const peerChangedSpy = cy.spy().as("peerChangedSpy");
|
||||
|
||||
cy.mount(PeerSelector, {
|
||||
props: {
|
||||
...defaultProps,
|
||||
peers: [
|
||||
{
|
||||
id: "hyy841u4phudmr8s5rg1jjwd1ct7x7438wmjwtsm464y8uyxyhyi6c",
|
||||
person: { name: "cloudhead" },
|
||||
delegate: true,
|
||||
},
|
||||
{
|
||||
id: "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue",
|
||||
person: { name: "sebastinez" },
|
||||
delegate: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
}).then(({ component }) => {
|
||||
component.$on("peerChanged", peerChangedSpy);
|
||||
});
|
||||
|
||||
cy.get("body").contains("sebastinez").click();
|
||||
cy.get("body").contains("cloudhead").click();
|
||||
cy.get("@peerChangedSpy").should("have.been.called");
|
||||
});
|
||||
});
|
||||
@@ -85,7 +85,7 @@
|
||||
</style>
|
||||
|
||||
<Floating>
|
||||
<div slot="toggle" class="selector" title="Switch peers">
|
||||
<div slot="toggle" class="selector" title="Change peer">
|
||||
<div class="stat peer" class:not-allowed={!peers}>
|
||||
<Icon name="fork" />
|
||||
{#if meta}
|
||||
|
||||
@@ -48,13 +48,16 @@
|
||||
activeRoute.params.route,
|
||||
project.branches,
|
||||
);
|
||||
router.updateProjectRoute({
|
||||
revision,
|
||||
path,
|
||||
line: activeRoute.params.line,
|
||||
hash: activeRoute.params.hash,
|
||||
route: undefined,
|
||||
});
|
||||
router.updateProjectRoute(
|
||||
{
|
||||
revision,
|
||||
path,
|
||||
line: activeRoute.params.line,
|
||||
hash: activeRoute.params.hash,
|
||||
route: undefined,
|
||||
},
|
||||
{ replace: true },
|
||||
);
|
||||
}
|
||||
if (!activeRoute.params.revision) {
|
||||
// We need a revision to fetch `getRoot`.
|
||||
|
||||
@@ -60,10 +60,6 @@ export const state = writable<Connection>({ connection: State.Connecting });
|
||||
|
||||
window.registrarState = state;
|
||||
|
||||
state.subscribe((s: Connection) => {
|
||||
console.debug("register.state", s);
|
||||
});
|
||||
|
||||
export async function getRegistration(
|
||||
name: string,
|
||||
wallet: Wallet,
|
||||
|
||||
Reference in New Issue
Block a user