From 3af800f77200dff68773f25edfb6f6bb80eb746f Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Fri, 9 Jun 2023 12:57:13 -0400 Subject: [PATCH] add more tests --- .gitignore | 1 + cypress/e2e/embeds.cy.ts | 38 ++++++++++++++++++++++++++++ cypress/e2e/login.cy.ts | 18 +++++++++++++ package.json | 3 ++- src/components/embed-types/music.tsx | 16 ++++++++---- 5 files changed, 70 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index de4d1f007..6e7fd322f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ dist node_modules +cypress/videos diff --git a/cypress/e2e/embeds.cy.ts b/cypress/e2e/embeds.cy.ts index ae367eac7..8a0531812 100644 --- a/cypress/e2e/embeds.cy.ts +++ b/cypress/e2e/embeds.cy.ts @@ -76,4 +76,42 @@ describe("Embeds", () => { cy.findByTitle(/youtube video player/i).should("have.attr", "src"); }); }); + + describe("Music", () => { + it("should handle wavlake links", () => { + cy.visit( + "#/n/nevent1qqsve4ud5v8gjds2f2h7exlmjvhqayu4s520pge7frpwe22wezny0pcpp4mhxue69uhkummn9ekx7mqprdmhxue69uhkvet9v3ejumn0wd68ytnzv9hxgtmdv4kk2mxs3z0" + ); + cy.findByTitle("Wavlake Embed").should("be.visible"); + }); + + it("should handle spotify links", () => { + cy.visit( + "#/n/nevent1qqsx0lz7m72qzq499exwhnfszvgwea8tv38x9wkv32yhkmwwmhgs7jgprdmhxue69uhkvet9v3ejumn0wd68ytnzv9hxgtmdv4kk25m3sln" + ); + cy.findByTitle("Spotify List Embed").should("exist"); + + cy.visit( + "#/n/nevent1qqsqxkmz49hydf8ppa9k6x6zrcq7m4evhhlye0j3lcnz8hrl2q6np4spz3mhxue69uhhyetvv9ujuerpd46hxtnfdult02qz" + ); + cy.findByTitle("Spotify Embed").should("exist"); + }); + + it("should handle apple music links", () => { + cy.visit( + "#/n/nevent1qqs9kqt9d7r4zjpawcyl82x5qsn4hals4wn294dv95knrahs4mggwasprdmhxue69uhkvet9v3ejumn0wd68ytnzv9hxgtmdv4kk2whhzvz" + ); + cy.findByTitle("Apple Music Embed").should("exist"); + + cy.visit( + "#/n/nevent1qqszyrz4uug75j4086kj4f8peg3g0v8g9f04zjxplnpq0uxljtthggqprdmhxue69uhkvet9v3ejumn0wd68ytnzv9hxgtmdv4kk2aeexmq" + ); + cy.findByTitle("Apple Music List Embed").should("exist"); + }); + + it("should handle Tidal playlist links", () => { + cy.visit("#/n/nevent1qqsg4d6rvg3te0y7sa0xp8r2rgcrnqyp2jmddzm4ufnmqs36aa2247qpp4mhxue69uhkummn9ekx7mqacwd3t"); + cy.findByTitle("Tidal List Embed").should("be.visible"); + }); + }); }); diff --git a/cypress/e2e/login.cy.ts b/cypress/e2e/login.cy.ts index e2e207076..e068c957a 100644 --- a/cypress/e2e/login.cy.ts +++ b/cypress/e2e/login.cy.ts @@ -47,4 +47,22 @@ describe("Login view", () => { cy.findByRole("button", { name: "Home" }).should("be.visible"); }); + + it("should redirect after login", () => { + cy.visit( + "#/n/nevent1qqs88gdxv36qsjfwr66k7wxuq9r2tg8rsdcnfkcqdg4sc6vlnsma98qpzpmhxue69uhkummnw3ezuamfdejsz9rhwden5te0wfjkccte9ejxzmt4wvhxjmccew89d" + ); + + cy.findByRole("link", { name: /login/i }).click(); + + cy.findByRole("link", { name: /nsec/i }).click(); + cy.findByRole("button", { name: /generate/i }).click(); + cy.findByRole("combobox", { name: /bootstrap relay/i }) + .clear() + .type("wss://nostrue.com"); + cy.findByRole("button", { name: /login/i }).click(); + + // should be redirect to note + cy.contains(/GM, and happy bday to your son/i); + }); }); diff --git a/package.json b/package.json index ed5a0d181..bce203da5 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "start": "vite serve", "build": "tsc --project tsconfig.json && vite build", "format": "prettier --ignore-path .prettierignore -w .", - "e2e": "cypress open" + "e2e": "cypress open", + "test": "cypress run --e2e --browser=chrome" }, "dependencies": { "@chakra-ui/icons": "^2.0.19", diff --git a/src/components/embed-types/music.tsx b/src/components/embed-types/music.tsx index c6121f504..0aca26d77 100644 --- a/src/components/embed-types/music.tsx +++ b/src/components/embed-types/music.tsx @@ -1,6 +1,3 @@ -import { EmbedableContent, embedJSX } from "../../helpers/embeds"; -import appSettings from "../../services/app-settings"; - // nostr:nevent1qqsve4ud5v8gjds2f2h7exlmjvhqayu4s520pge7frpwe22wezny0pcpp4mhxue69uhkummn9ekx7mqprdmhxue69uhkvet9v3ejumn0wd68ytnzv9hxgtmdv4kk2mxs3z0 export function renderWavlakeUrl(match: URL) { if (match.hostname !== "wavlake.com") return null; @@ -12,6 +9,7 @@ export function renderWavlakeUrl(match: URL) { @@ -32,6 +30,7 @@ export function renderAppleMusicUrl(match: URL) { ; + return ( + + ); }