sidebar-primary-navigation.test.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { join } from "node:path";
  2. import { TID_AUTOMATIONS_OPEN, TID_TASK_NEW_BUTTON } from "@zcode/shared/test-ids";
  3. import { prepareV4ConversationE2E } from "#e2e/helpers/v4-conversation";
  4. describe("桌面侧栏主导航", () => {
  5. before(async () => {
  6. await prepareV4ConversationE2E({ skipProvider: true });
  7. });
  8. it("SNAV01:桌面保留自动化和插件市场入口及导航", async () => {
  9. for (const theme of ["zai-light", "zai-dark"]) {
  10. for (const locale of ["zh-CN", "en-US"]) {
  11. await browser.execute(
  12. (theme, locale) => {
  13. const actions = (
  14. window as typeof window & {
  15. __testActions?: {
  16. setTheme(value: string): void;
  17. setLocale(value: string): void;
  18. };
  19. }
  20. ).__testActions;
  21. if (!actions) throw new Error("缺少界面测试入口");
  22. actions.setTheme(theme);
  23. actions.setLocale(locale);
  24. },
  25. theme,
  26. locale,
  27. );
  28. const navigation = $('[data-testid="sidebar-primary-navigation"]');
  29. await navigation.waitForDisplayed();
  30. const automation = navigation.$(`[data-testid="${TID_AUTOMATIONS_OPEN}"]`);
  31. const plugins = navigation.$('[data-testid="plugin-store-sidebar-open"]');
  32. await automation.waitForDisplayed();
  33. await plugins.waitForDisplayed();
  34. expect(await navigation.$(`[data-testid="${TID_TASK_NEW_BUTTON}"]`).isDisplayed()).toBe(
  35. true,
  36. );
  37. await automation.click();
  38. await browser.waitUntil(
  39. async () => (await automation.getAttribute("aria-pressed")) === "true",
  40. );
  41. await plugins.click();
  42. await browser.waitUntil(
  43. async () => (await plugins.getAttribute("aria-pressed")) === "true",
  44. );
  45. expect(await automation.getAttribute("aria-pressed")).toBe("false");
  46. await browser.saveScreenshot(
  47. join(process.env.ZCODE_E2E_ARTIFACT_DIR!, `sidebar-navigation-${theme}-${locale}.png`),
  48. );
  49. }
  50. }
  51. });
  52. });