Skip to content

Commit a6e837d

Browse files
committed
refactor: add test for hitting password reset.
1 parent 163cb62 commit a6e837d

File tree

4 files changed

+106
-59
lines changed

4 files changed

+106
-59
lines changed

tests/end-to-end/web-UI/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ configure_file(
88
"${CMAKE_CURRENT_SOURCE_DIR}/auth.setup.js"
99
@ONLY
1010
)
11-
11+
message("ENABLE END TO END!!!!!!!")
1212
#FIXTHIS
1313
# For E2E web ui test
1414
if(ENABLE_END_TO_END_WEB_TESTS)

tests/end-to-end/web-UI/playwright.config.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,5 @@ module.exports = defineConfig({
5050
...devices["Desktop Chrome"],
5151
},
5252
},
53-
54-
// {
55-
// name: 'firefox',
56-
// use: {
57-
// ...devices['Desktop Firefox'],
58-
// },
59-
// },
60-
61-
// {
62-
// name: 'webkit',
63-
// use: {
64-
// ...devices['Desktop Safari'],
65-
// },
66-
// },
6753
],
6854
});
Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,50 @@
11
import { test, expect } from "@playwright/test";
22

33
// checking visibility and expanding some dropdowns
4-
test("test visibility", async ({ page }) => {
5-
try {
6-
console.log("******Begin test******");
7-
// Temporary fix
8-
let domain = process.env.DATAFED_DOMAIN;
9-
await page.goto("https://" + domain + "/");
10-
if (await page.getByRole("button", { name: "Log In / Register" }).isVisible()) {
11-
console.log("NOT LOGGED IN");
4+
test.describe("DataFed UI Navigation", () => {
5+
test("should display main navigation elements", async ({ page }) => {
6+
const domain = process.env.DATAFED_DOMAIN;
7+
if (!domain) {
8+
throw new Error("DATAFED_DOMAIN environment variable not set");
129
}
13-
if (await expect(page.getByText("Continue Registration")).toBeVisible()) {
14-
await page.getByText("Continue Registration").click({ timeout: 20000 });
10+
11+
await page.goto(`https://${domain}/`);
12+
13+
// Handle optional registration continuation
14+
const continueReg = page.getByText("Continue Registration");
15+
if (await continueReg.isVisible()) {
16+
await continueReg.click();
1517
}
16-
await expect(page.locator(".ui-icon").first()).toBeVisible({
17-
timeout: 20000,
18-
});
18+
19+
// Verify main elements
20+
await expect(page.locator(".ui-icon").first()).toBeVisible();
1921
await expect(page.getByText("DataFed - Scientific Data")).toBeVisible();
2022
await expect(page.getByRole("link", { name: "My Data" })).toBeVisible();
2123
await expect(page.getByRole("link", { name: "Catalog" })).toBeVisible();
22-
await expect(page.getByRole("button", { name: "" })).toBeVisible();
23-
24-
await page
25-
.getByRole("treeitem", { name: "  Public Collections" })
26-
.getByRole("button")
27-
.click();
28-
await page
29-
.getByRole("treeitem", { name: "  Public Collections" })
30-
.getByRole("group")
31-
.click();
32-
await page.getByRole("treeitem", { name: "  Allocations" }).getByRole("button").click();
33-
await page.getByRole("treeitem", { name: "  Project Data" }).getByRole("button").click();
34-
await page.getByRole("treeitem", { name: "  Shared Data" }).getByRole("button").click();
35-
await page
36-
.getByRole("treeitem", { name: "  Saved Queries" })
37-
.locator("span")
38-
.first()
39-
.click();
40-
await page.getByRole("treeitem", { name: "  Saved Queries" }).getByRole("button").click();
41-
await page.getByText("Provenance Annotate Upload").click({ timeout: 20000 });
42-
await page.getByRole("treeitem", { name: "  By User" }).getByRole("button").click();
43-
} catch (error) {
44-
// element not visible, either the test broke due to tags changing, or not logged in
45-
// try to log out, because if not logged out, future tests will fail due to globus being annoying
46-
if (await page.getByRole("button", { name: "" }).isVisible()) {
47-
await page.getByRole("button", { name: "" }).click();
48-
} else {
49-
// if in here, check if you logged out properly
50-
throw error;
24+
});
25+
26+
test("should expand tree navigation items", async ({ page }) => {
27+
const domain = process.env.DATAFED_DOMAIN;
28+
if (!domain) {
29+
throw new Error("DATAFED_DOMAIN environment variable not set");
30+
}
31+
32+
await page.goto(`https://${domain}/`);
33+
34+
// Define tree items to expand
35+
const treeItems = [
36+
"Public Collections",
37+
"Allocations",
38+
"Project Data",
39+
"Shared Data",
40+
"Saved Queries",
41+
"By User",
42+
];
43+
44+
for (const item of treeItems) {
45+
const treeItem = page.getByRole("treeitem", { name: new RegExp(item) });
46+
await treeItem.getByRole("button").click();
47+
// Add assertion that it expanded if needed
5148
}
52-
}
53-
//removed logout
49+
});
5450
});
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
// checking visibility and expanding some dropdowns
4+
test.describe("DataFed UI password change", () => {
5+
// Since auth is handled by global setup, we start from authenticated state
6+
test.beforeEach(async ({ page }) => {
7+
const domain = process.env.DATAFED_DOMAIN || "domain.com";
8+
9+
// Navigate to main page (already authenticated via storageState)
10+
await page.goto(`https://${domain}/ui/main`, {
11+
waitUntil: "networkidle",
12+
});
13+
14+
// Verify we're on the main page and authenticated
15+
await expect(page).toHaveURL(new RegExp(`https://${domain}/ui/main`));
16+
17+
// Wait for main UI to be ready
18+
await page
19+
.waitForSelector('[data-testid="main-content"], .main-content, #main', {
20+
state: "visible",
21+
timeout: 15000,
22+
})
23+
.catch(() => {
24+
// Fallback: just wait for any main element
25+
return page.waitForTimeout(2000);
26+
});
27+
28+
// Log current page state for debugging
29+
console.log(`INFO - Test starting on: ${page.url()}`);
30+
});
31+
32+
test("should display main page after entering password", async ({ page }) => {
33+
await test.step("Open settings menu", async () => {
34+
const button = page.locator("#btn_settings");
35+
36+
if (await button.isVisible()) {
37+
console.log("INFO - Button is visible (btn_settings)");
38+
await button.click();
39+
} else {
40+
console.log("INFO - Button is not visible (btn_settings)");
41+
}
42+
});
43+
44+
await test.step("Enter password and confirmation password", async () => {
45+
// Define locators for the elements
46+
const newPasswordInput = page.locator("#cli_new_pw");
47+
const confirmPasswordInput = page.locator("#cli_confirm_pw");
48+
const revokeButton = page.locator("#btn_revoke_cred");
49+
const saveButton = page.getByRole("button", { name: "Save" });
50+
51+
// Wait for all elements to be visible
52+
await Promise.all([
53+
newPasswordInput.waitFor({ state: "visible", timeout: 5000 }),
54+
confirmPasswordInput.waitFor({ state: "visible", timeout: 5000 }),
55+
revokeButton.waitFor({ state: "visible", timeout: 5000 }),
56+
saveButton.waitFor({ state: "visible", timeout: 5000 }),
57+
]);
58+
await newPasswordInput.click();
59+
await newPasswordInput.fill("Terrible2s!!!");
60+
await confirmPasswordInput.click();
61+
await confirmPasswordInput.fill("Terrible2s!!!");
62+
await saveButton.click();
63+
});
64+
});
65+
});

0 commit comments

Comments
 (0)