-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [#232] added tests for generating the magnet link on torrents l…
…ist page
- Loading branch information
MMelchor
committed
Oct 16, 2023
1 parent
d0134fc
commit ee028c9
Showing
4 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { RegistrationForm, random_user_registration_data } from "../../../user/registration"; | ||
import { generateRandomTestTorrentInfo } from "../../test_torrent_info"; | ||
|
||
describe("A guest user", () => { | ||
let registration_form: RegistrationForm; | ||
|
||
before(() => { | ||
registration_form = random_user_registration_data(); | ||
cy.register_and_login(registration_form); | ||
// Generates and upload a random torrent file for the tests | ||
const torrent_info = generateRandomTestTorrentInfo(); | ||
Cypress.env("torrent_info", torrent_info); | ||
cy.upload_torrent(torrent_info); | ||
// Stores the infoHash in the Cypress's env variables | ||
cy.get("[data-cy=\"torrent-action-info-hash\"]").invoke("text").then((infoHash) => { | ||
Cypress.env("infoHash", infoHash); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.visit("/torrents"); | ||
}); | ||
|
||
after(() => { | ||
cy.delete_user_from_database(registration_form.username); | ||
}); | ||
|
||
it("should be able get the a torrent magnet link from the torrents list", () => { | ||
// Get the magnet link | ||
cy.get("[data-cy=\"torrent-list-magnet-link\"]").invoke("attr", "href").then((href) => { | ||
expect(href).to.include(`magnet:?xt=urn:btih:${Cypress.env("infoHash")}`); | ||
}); | ||
}); | ||
|
||
it("should be able get the a torrent magnet link from the torrents table", () => { | ||
// Sets the layout to "table" | ||
cy.get("[data-cy=\"torrents-table-layout-selector\"]").click(); | ||
// Gets the magnet link | ||
cy.get("[data-cy=\"torrent-table-magnet-link\"]").invoke("attr", "href").then((href) => { | ||
expect(href).to.include(`magnet:?xt=urn:btih:${Cypress.env("infoHash")}`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters