Skip to content

Commit b485028

Browse files
committed
Add end-to-end tests for table action buttons
- Implemented tests for edit, delete, and custom action buttons in the table component. - Verified visibility and correct href attributes for action buttons. - Added checks for disabled action buttons in the table. Updated package dependencies for Playwright and Node types in package.json and package-lock.json.
1 parent f466bcc commit b485028

File tree

3 files changed

+104
-20
lines changed

3 files changed

+104
-20
lines changed

tests/end-to-end/official-site.spec.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,87 @@ test("modal", async ({ page }) => {
213213
await modal.getByRole("button", { label: "Close" }).first().click();
214214
await expect(modal).not.toBeVisible();
215215
});
216+
217+
test("table action buttons - edit_url and delete_url", async ({ page }) => {
218+
await page.goto(`${BASE}/documentation.sql?component=table`);
219+
const tableSection = page.locator(".table-responsive", {
220+
has: page.getByRole("cell", { name: "PharmaCo" }),
221+
});
222+
223+
const editButton = tableSection.getByTitle("Edit").first();
224+
await expect(editButton).toBeVisible();
225+
await expect(editButton).toHaveAttribute("href", /action=edit&update_id=\d+/);
226+
227+
const deleteButton = tableSection.getByTitle("Delete").first();
228+
await expect(deleteButton).toBeVisible();
229+
await expect(deleteButton).toHaveAttribute(
230+
"href",
231+
/action=delete&delete_id=\d+/,
232+
);
233+
});
234+
235+
test("table action buttons - custom_actions", async ({ page }) => {
236+
await page.goto(`${BASE}/documentation.sql?component=table`);
237+
const tableSection = page.locator(".table-responsive", {
238+
has: page.getByRole("cell", { name: "PharmaCo" }),
239+
});
240+
241+
const historyButton = tableSection
242+
.getByTitle("View Standard History")
243+
.first();
244+
await expect(historyButton).toBeVisible();
245+
await expect(historyButton).toHaveAttribute(
246+
"href",
247+
/action=history&standard_id=\d+/,
248+
);
249+
});
250+
251+
test("table action buttons - _sqlpage_actions", async ({ page }) => {
252+
await page.goto(`${BASE}/documentation.sql?component=table`);
253+
const tableSection = page.locator(".table-responsive", {
254+
has: page.getByRole("cell", { name: "PharmaCo" }),
255+
});
256+
257+
const pdfButtons = tableSection.getByTitle("View Presentation");
258+
await expect(pdfButtons.first()).toBeVisible();
259+
await expect(pdfButtons).toHaveCount(3);
260+
261+
const firstPdfButton = pdfButtons.first();
262+
await expect(firstPdfButton).toHaveAttribute(
263+
"href",
264+
"https://sql-page.com/pgconf/2024-sqlpage-badass.pdf",
265+
);
266+
267+
const setInUseButton = tableSection.getByTitle("Set In Use");
268+
await expect(setInUseButton).toBeVisible();
269+
await expect(setInUseButton).toHaveAttribute(
270+
"href",
271+
/action=set_in_use&standard_id=32/,
272+
);
273+
274+
const retireButton = tableSection.getByTitle("Retire Standard");
275+
await expect(retireButton).toBeVisible();
276+
await expect(retireButton).toHaveAttribute(
277+
"href",
278+
/action=retire&standard_id=33/,
279+
);
280+
});
281+
282+
test("table action buttons - disabled action", async ({ page }) => {
283+
await page.goto(`${BASE}/documentation.sql?component=table`);
284+
const tableSection = page.locator(".table-responsive", {
285+
has: page.getByRole("cell", { name: "PharmaCo" }),
286+
});
287+
288+
const viewPresentationButtons = tableSection.getByTitle("View Presentation");
289+
await expect(viewPresentationButtons).toHaveCount(3);
290+
291+
const actionColumnButtons = tableSection.locator(
292+
"td._col_Action a[data-action='Action']",
293+
);
294+
await expect(actionColumnButtons).toHaveCount(3);
295+
296+
const emptyActionButton = actionColumnButtons.last();
297+
await expect(emptyActionButton).toHaveAttribute("href", "null");
298+
await expect(emptyActionButton).toHaveAttribute("title", "Action");
299+
});

tests/end-to-end/package-lock.json

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/end-to-end/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"license": "ISC",
1313
"devDependencies": {
1414
"@playwright/test": "^1.45.3",
15-
"@types/node": "^22.1.0"
15+
"@types/node": "^24.9.1"
1616
}
1717
}

0 commit comments

Comments
 (0)