Skip to content

Conversation

mario-nt
Copy link
Contributor

Resolves #310.

@mario-nt mario-nt force-pushed the #310-E2E-tests-list-page-should-be-displayed-to-a-guest-user-when-there-are-no-torrents-in-the-index branch from d1df838 to c969ad3 Compare October 19, 2023 08:28
@mario-nt mario-nt force-pushed the #310-E2E-tests-list-page-should-be-displayed-to-a-guest-user-when-there-are-no-torrents-in-the-index branch 2 times, most recently from 5f68e24 to 82ed545 Compare November 16, 2023 12:44
@mario-nt mario-nt force-pushed the #310-E2E-tests-list-page-should-be-displayed-to-a-guest-user-when-there-are-no-torrents-in-the-index branch from 82ed545 to b1e9ab6 Compare November 16, 2023 12:58
@mario-nt
Copy link
Contributor Author

mario-nt commented Nov 16, 2023

https://github.com/torrust/torrust-index-gui/blob/b1e9ab6b3a7f89295d22781b73542c21fe176b74/cypress/e2e/contexts/torrent/specs/list/no_torrents_to_display.cy.ts#L1-L14

import { baseURL } from "nuxt/dist/core/runtime/nitro/paths";


describe("A guest user", () => {
  before(() => {
    // Deletes all torrents and their related info from the database so the test can pass
    cy.clear_torrent_info_from_database();
  });


  it("Should be able to see the list page when there are no torrents", () => {
    cy.visit("/torrents");
    cy.url().should("match", /\/torrents$/);
    cy.get("[data-cy=\"no-results-element\"]").invoke("text").should("match", /No results./i);
  });
});

@josecelano Do you think is worth implementing the test with an admin/logged in user too?, I don't think it would change the result of the test, but wanted a second opinion.

@josecelano
Copy link
Member

https://github.com/torrust/torrust-index-gui/blob/b1e9ab6b3a7f89295d22781b73542c21fe176b74/cypress/e2e/contexts/torrent/specs/list/no_torrents_to_display.cy.ts#L1-L14

import { baseURL } from "nuxt/dist/core/runtime/nitro/paths";


describe("A guest user", () => {
  before(() => {
    // Deletes all torrents and their related info from the database so the test can pass
    cy.clear_torrent_info_from_database();
  });


  it("Should be able to see the list page when there are no torrents", () => {
    cy.visit("/torrents");
    cy.url().should("match", /\/torrents$/);
    cy.get("[data-cy=\"no-results-element\"]").invoke("text").should("match", /No results./i);
  });
});

@josecelano Do you think is worth implementing the test with an admin/logged in user too?, I don't think it would change the result of the test, but wanted a second opinion.

I always have doubts about E2E tests. The other two tests seem more like a test for the permissions. I guess here we are testing the feature that users see a friendly message when there are no torrents, not that users can see this content. Since we are using the role with the lowest permissions, I think it's ok.

Maybe we can change the describe section describe("A guest user", () => {...} to describe("Users", () => {...} to avoid misunderstandings. People can think only guests can see that message. Even if the test is using a concrete role.

@mario-nt mario-nt marked this pull request as ready for review November 16, 2023 13:27
@mario-nt mario-nt requested a review from josecelano November 16, 2023 13:27
@mario-nt
Copy link
Contributor Author

@josecelano I really like the idea of using "Users", I will refactor that part.

@mario-nt mario-nt marked this pull request as draft November 16, 2023 13:29
@mario-nt mario-nt marked this pull request as ready for review November 16, 2023 13:29
@mario-nt
Copy link
Contributor Author

@josecelano Ready for review

@josecelano
Copy link
Member

ACK 6d6806d

@josecelano josecelano merged commit 8b816ee into torrust:develop Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

E2E tests: List page should be displayed to a guest user when there are no torrents in the index

2 participants