share-selection-all.mjs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import assert from "node:assert/strict";
  2. export async function verifySelectionSelectAll(panel) {
  3. const all = panel.getByTestId("conversation-share-selection-all");
  4. const rows = panel.locator("[data-conversation-share-selection-item]");
  5. const first = rows.first().getByRole("checkbox");
  6. const running = rows.last().getByRole("checkbox");
  7. assert.equal((await all.boundingBox()).x, (await first.boundingBox()).x);
  8. const runningState = await running.getAttribute("data-state");
  9. const toggle = rows.first().getByTestId("conversation-share-selection-toggle");
  10. const label = panel.getByTestId("conversation-share-selection-header").locator("label > span");
  11. assert.equal((await label.boundingBox()).x, (await toggle.boundingBox()).x);
  12. const locate = rows.first().getByTestId("conversation-share-selection-locate");
  13. await locate.hover();
  14. const tooltip = panel.page().getByRole("tooltip");
  15. await tooltip.waitFor();
  16. assert.equal(await locate.getAttribute("title"), null);
  17. const content = panel.page().locator('[data-slot="tooltip-content"]').filter({ has: tooltip });
  18. if (panel.page().viewportSize().width >= 600) {
  19. assert.equal(await content.getAttribute("data-side"), "right");
  20. } else {
  21. const bounds = await content.boundingBox();
  22. assert.ok(bounds.x >= 0 && bounds.x + bounds.width <= panel.page().viewportSize().width);
  23. }
  24. await toggle.click();
  25. assert.equal(await first.isChecked(), false);
  26. await locate.click();
  27. assert.equal(await first.isChecked(), false);
  28. await toggle.focus();
  29. await toggle.press("Space");
  30. assert.equal(await first.isChecked(), true);
  31. assert.equal(await all.getAttribute("aria-checked"), "true");
  32. await all.click();
  33. assert.equal(await all.getAttribute("aria-checked"), "false");
  34. assert.equal(await panel.getByTestId("conversation-share-selection-apply").isDisabled(), true);
  35. assert.equal(await rows.locator('[role="checkbox"][data-state="checked"]').count(), 0);
  36. await first.click();
  37. assert.equal(await all.getAttribute("aria-checked"), "mixed");
  38. await all.click();
  39. assert.equal(await all.getAttribute("aria-checked"), "true");
  40. assert.equal(await rows.locator('[role="checkbox"][data-state="checked"]').count(), 8);
  41. assert.equal(await running.getAttribute("data-state"), runningState);
  42. const page = panel.page();
  43. const summary = panel.getByTestId("conversation-share-selection-summary");
  44. const apply = panel.getByTestId("conversation-share-selection-apply");
  45. await page.getByTestId("toggle-limit").click();
  46. assert.match(await summary.innerText(), /110/);
  47. assert.match(await summary.getAttribute("class"), /text-warning/);
  48. assert.equal(await apply.isDisabled(), true);
  49. await first.click();
  50. assert.match(await summary.innerText(), /7/);
  51. assert.equal(await apply.isDisabled(), false);
  52. await first.click();
  53. assert.match(await summary.innerText(), /110/);
  54. await page.getByTestId("toggle-limit").click();
  55. await page.getByTestId("toggle-preflight").click();
  56. assert.equal(await apply.isDisabled(), true);
  57. await page.getByTestId("toggle-preflight").click();
  58. assert.equal(await apply.isDisabled(), false);
  59. }