mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-02 08:58:36 +02:00
fix e2e tests
This commit is contained in:
parent
2aa6ec5678
commit
8e49f85dd2
@ -1,8 +1,4 @@
|
||||
describe("Embeds", () => {
|
||||
beforeEach(() => {
|
||||
cy.loginWithNewUser();
|
||||
});
|
||||
|
||||
describe("hashtags", () => {
|
||||
it('should handle uppercase hashtags and ","', () => {
|
||||
cy.visit(
|
||||
|
@ -17,7 +17,7 @@ describe("Login view", () => {
|
||||
},
|
||||
});
|
||||
|
||||
cy.findByRole("button", { name: /nip-05/i }).click();
|
||||
cy.findByRole("link", { name: /nip-05/i }).click();
|
||||
|
||||
cy.findByRole("textbox", { name: /nip-05/i }).type("_@hzrd149.com");
|
||||
cy.contains(/found 1 relays/i);
|
||||
@ -27,7 +27,7 @@ describe("Login view", () => {
|
||||
});
|
||||
|
||||
it("login with npub", () => {
|
||||
cy.findByRole("button", { name: /npub/i }).click();
|
||||
cy.findByRole("link", { name: /npub/i }).click();
|
||||
cy.findByRole("textbox", { name: /npub/i }).type("npub1ye5ptcxfyyxl5vjvdjar2ua3f0hynkjzpx552mu5snj3qmx5pzjscpknpr");
|
||||
cy.findByRole("combobox", { name: /bootstrap relay/i })
|
||||
.clear()
|
||||
@ -38,7 +38,7 @@ describe("Login view", () => {
|
||||
});
|
||||
|
||||
it("login with new nsec", () => {
|
||||
cy.findByRole("button", { name: /nsec/i }).click();
|
||||
cy.findByRole("link", { name: /nsec/i }).click();
|
||||
cy.findByRole("button", { name: /generate/i }).click();
|
||||
cy.findByRole("combobox", { name: /bootstrap relay/i })
|
||||
.clear()
|
||||
|
22
cypress/e2e/public.cy.ts
Normal file
22
cypress/e2e/public.cy.ts
Normal file
@ -0,0 +1,22 @@
|
||||
describe("No account", () => {
|
||||
describe("note view", () => {
|
||||
it("should fetch and render note", () => {
|
||||
cy.visit(
|
||||
"/n/nevent1qqs84hwdlls703w4yf66qsszxjqfc0xselfxrzr6n4qp40vzdnczragpr4mhxue69uhkummnw3ez6ur4vgh8wetvd3hhyer9wghxuet5jcwczn"
|
||||
);
|
||||
|
||||
cy.get(".chakra-card")
|
||||
.first()
|
||||
.within(() => {
|
||||
// check for note content
|
||||
cy.contains('I didn\'t know someone had taken the "rsslay" idea and made it good');
|
||||
|
||||
// check for author name
|
||||
cy.get(".chakra-card__header .chakra-heading .chakra-link").should("not.contain", "npub");
|
||||
});
|
||||
|
||||
// check for multiple replies
|
||||
cy.get(".chakra-card").should("have.length.above", 2);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,18 +1,11 @@
|
||||
describe("Search", () => {
|
||||
beforeEach(() => {
|
||||
cy.loginWithNewUser();
|
||||
});
|
||||
|
||||
describe("Events", () => {
|
||||
const links: [string, RegExp][] = [
|
||||
[
|
||||
"nostr:nevent1qqsvg6kt4hl79qpp5p673g7ref6r0c5jvp4yys7mmvs4m50t30sy9dgpp4mhxue69uhkummn9ekx7mqpr4mhxue69uhkummnw3ez6ur4vgh8wetvd3hhyer9wghxuet59dl66z",
|
||||
/Nostr zaps - a guide/i,
|
||||
],
|
||||
// [
|
||||
// "nostr:nevent1qqsymds0vlpp4f5s0dckjf4qz283pdsen0rmx8lu7ct6hpnxag2hpacpremhxue69uhkummnw3ez6un9d3shjtnwda4k7arpwfhjucm0d5q3qamnwvaz7tmwdaehgu3wwa5kueghxyq76",
|
||||
// /testing/i,
|
||||
// ],
|
||||
["nostr:note10twumllpulza2gn45ppqydyqns7dpn7jvxy8482qr27cym8sy86sgxe3c8", /someone had taken/i],
|
||||
];
|
||||
|
||||
for (const [link, regexp] of links) {
|
||||
@ -41,6 +34,7 @@ describe("Search", () => {
|
||||
"nostr:nprofile1qqsp2alytxwazryxxjv0u0pqhkp247hc9xjetn5rch8c4s6xx5cmpxcpzpmhxue69uhkummnw3ezuamfdejsz9nhwden5te0v96xcctn9ehx7um5wghxcctwvs6ymk33",
|
||||
/npub1z4m7g\.\.\.kzdsxana6p/i,
|
||||
],
|
||||
["nostr:npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6", /npub180cvv\.\.\.gkwsyjh6w6/i],
|
||||
];
|
||||
|
||||
for (const [search, regexp] of profiles) {
|
||||
|
@ -42,7 +42,7 @@ Cypress.Commands.add("loginWithNewUser", () => {
|
||||
cy.stub($win, "prompt").returns("pass");
|
||||
});
|
||||
|
||||
cy.findByRole("button", { name: /nsec/i }).click();
|
||||
cy.findByRole("link", { name: /nsec/i }).click();
|
||||
cy.findByRole("button", { name: /generate/i }).click();
|
||||
cy.findByRole("combobox", { name: /bootstrap relay/i })
|
||||
.clear()
|
||||
|
@ -77,7 +77,7 @@ export function embedNostrHashtags(content: EmbedableContent, event: NostrEvent
|
||||
#{match[1]}
|
||||
</Link>
|
||||
);
|
||||
} else console.log(hashtag, hashtags);
|
||||
}
|
||||
|
||||
return match[0];
|
||||
},
|
||||
|
@ -18,6 +18,7 @@ import { useUserMetadata } from "../../hooks/use-user-metadata";
|
||||
import accountService from "../../services/account";
|
||||
import { AddIcon } from "../icons";
|
||||
import { UserAvatar } from "../user-avatar";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
function AccountItem({ pubkey }: { pubkey: string }) {
|
||||
const metadata = useUserMetadata(pubkey, []);
|
||||
@ -49,6 +50,7 @@ function AccountItem({ pubkey }: { pubkey: string }) {
|
||||
}
|
||||
|
||||
export function AccountSwitcherList() {
|
||||
const navigate = useNavigate();
|
||||
const accounts = useSubject(accountService.accounts);
|
||||
const current = useSubject(accountService.current);
|
||||
|
||||
@ -59,7 +61,14 @@ export function AccountSwitcherList() {
|
||||
{otherAccounts.map((account) => (
|
||||
<AccountItem key={account.pubkey} pubkey={account.pubkey} />
|
||||
))}
|
||||
<Button size="sm" leftIcon={<AddIcon />} onClick={() => accountService.logout()}>
|
||||
<Button
|
||||
size="sm"
|
||||
leftIcon={<AddIcon />}
|
||||
onClick={() => {
|
||||
accountService.logout();
|
||||
navigate("/login", { state: { from: location.pathname } });
|
||||
}}
|
||||
>
|
||||
Add Account
|
||||
</Button>
|
||||
</Flex>
|
||||
|
@ -11,13 +11,13 @@ import {
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Link as RouterLink, useLocation } from "react-router-dom";
|
||||
import AccountCard from "./components/account-card";
|
||||
import useSubject from "../../hooks/use-subject";
|
||||
import accountService from "../../services/account";
|
||||
|
||||
export default function LoginStartView() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const toast = useToast();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const accounts = useSubject(accountService.accounts);
|
||||
@ -70,9 +70,15 @@ export default function LoginStartView() {
|
||||
<Button onClick={loginWithExtension} colorScheme="brand">
|
||||
Use browser extension (NIP-07)
|
||||
</Button>
|
||||
<Button onClick={() => navigate("./nip05")}>Login with Nip-05 Id</Button>
|
||||
<Button onClick={() => navigate("./npub")}>Login with pubkey key (npub)</Button>
|
||||
<Button onClick={() => navigate("./nsec")}>Login with secret key (nsec)</Button>
|
||||
<Button as={RouterLink} to="./nip05" state={location.state}>
|
||||
Login with Nip-05 Id
|
||||
</Button>
|
||||
<Button as={RouterLink} to="./npub" state={location.state}>
|
||||
Login with pubkey key (npub)
|
||||
</Button>
|
||||
<Button as={RouterLink} to="./nsec" state={location.state}>
|
||||
Login with secret key (nsec)
|
||||
</Button>
|
||||
{accounts.length > 0 && (
|
||||
<>
|
||||
<Heading size="md" mt="4">
|
||||
|
Loading…
x
Reference in New Issue
Block a user