|
| 1 | +import { RegistrationForm, random_user_registration_data } from "../../../user/registration"; |
| 2 | +import { generateRandomTestTorrentInfo } from "../../test_torrent_info"; |
| 3 | + |
| 4 | +describe("A guest user", () => { |
| 5 | + let registration_form: RegistrationForm; |
| 6 | + |
| 7 | + before(() => { |
| 8 | + registration_form = random_user_registration_data(); |
| 9 | + cy.register_and_login(registration_form); |
| 10 | + // Generates and upload a random torrent file for the tests |
| 11 | + const torrent_info = generateRandomTestTorrentInfo(); |
| 12 | + Cypress.env("torrent_info", torrent_info); |
| 13 | + cy.upload_torrent(torrent_info); |
| 14 | + // Stores the infoHash in the Cypress's env variables |
| 15 | + cy.get("[data-cy=\"torrent-action-info-hash\"]").invoke("text").then((infoHash) => { |
| 16 | + Cypress.env("infoHash", infoHash); |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + beforeEach(() => { |
| 21 | + cy.visit("/torrents"); |
| 22 | + }); |
| 23 | + |
| 24 | + after(() => { |
| 25 | + cy.delete_user_from_database(registration_form.username); |
| 26 | + }); |
| 27 | + |
| 28 | + it("should be able get the a torrent magnet link from the torrents list", () => { |
| 29 | + // Get the magnet link |
| 30 | + cy.get("[data-cy=\"torrent-list-magnet-link\"]").invoke("attr", "href").then((href) => { |
| 31 | + expect(href).to.include(`magnet:?xt=urn:btih:${Cypress.env("infoHash")}`); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + it("should be able get the a torrent magnet link from the torrents table", () => { |
| 36 | + // Sets the layout to "table" |
| 37 | + cy.get("[data-cy=\"torrents-table-layout-selector\"]").click(); |
| 38 | + // Gets the magnet link |
| 39 | + cy.get("[data-cy=\"torrent-table-magnet-link\"]").invoke("attr", "href").then((href) => { |
| 40 | + expect(href).to.include(`magnet:?xt=urn:btih:${Cypress.env("infoHash")}`); |
| 41 | + }); |
| 42 | + }); |
| 43 | +}); |
0 commit comments