Skip to content

Commit

Permalink
Añadido test de creacion de grupo
Browse files Browse the repository at this point in the history
  • Loading branch information
iyanfdezz committed Apr 24, 2024
1 parent dfc1e4c commit 91c4ddc
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
File renamed without changes.
68 changes: 68 additions & 0 deletions webapp/e2e/steps/create-group.steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const puppeteer = require("puppeteer");
const { defineFeature, loadFeature } = require("jest-cucumber");
const setDefaultOptions = require("expect-puppeteer").setDefaultOptions;
const { expect } = require("expect-puppeteer");

const feature = loadFeature("./features/create-group.feature");

let page;
let browser;

defineFeature(feature, (test) => {
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 100 });
page = await browser.newPage();
setDefaultOptions({ timeout: 10000 });

await page.goto("http://localhost:3000", {
waitUntil: "networkidle0",
});
});
let username;
let password;
test("The user can create a group", ({ given, when, then }) => {
given("A logged-in user", async () => {
username = "testuser";
password = "Testpassword1";
await page.waitForSelector("#login-username");
await page.type("#login-username", username);
await page.waitForSelector("#login-password");
await page.type("#login-password", password);
await page.click("button", { text: "Login" });
//await page.waitForNavigation({ waitUntil: "networkidle0" });
});

when("I click on the Groups link and create a group", async () => {
await page.waitForTimeout(1000);

await page.click('button[aria-label="Abrir menú"]');
await page.click('[data-testid="home-grupos-link"]');
//await page.waitForNavigation({ waitUntil: "networkidle0" });

await page.waitForSelector('[name="name"]');
await page.type('[name="name"]', "Test Group");
await page.click("button", { text: "Crear" });
await page.waitForTimeout(1000);
});

then("The Group should be shown on the My Groups page", async () => {
await page.click('button[aria-label="Abrir menú"]');
await page.click('[data-testid="home-misgrupos-link"]');
//await page.waitForNavigation({ waitUntil: "networkidle0" });

const groupExists = await page.evaluate(() => {
const groupName = "Test Group";
const groups = Array.from(document.querySelectorAll("tbody tr td:first-child"));
return groups.some(td => td.textContent === groupName);
});

expect(groupExists).toBe(true);
});
});

afterAll(async () => {
await browser.close();
});
});
6 changes: 4 additions & 2 deletions webapp/e2e/steps/logout.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ defineFeature(feature, (test) => {

when("I click on the Logout link", async () => {
await page.waitForTimeout(1000);
await page.waitForSelector('[data-testid="logout-link"]');
await page.click('[data-testid="logout-link"]');

await page.click('button[aria-label="Abrir menú"]');
await page.waitForSelector('[data-testid="home-logout-link"]');
await page.click('[data-testid="home-logout-link"]');
await page.waitForNavigation({ waitUntil: "networkidle0" });
});

Expand Down
8 changes: 8 additions & 0 deletions webapp/src/components/Nav/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ const Nav = () => {
</Link>
</Flex>
</Box>

<Box>
<Flex flexDirection={"column"}>
<Link onClick={handleLogout} data-testid="home-logout-link">
{t("components.nav.disconnect")}
</Link>
</Flex>
</Box>
</Stack>
</DrawerBody>
</DrawerContent>
Expand Down

0 comments on commit 91c4ddc

Please sign in to comment.