Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load in e2e testing strings from en-US.json file #1099

Open
2 tasks done
andrewtavis opened this issue Jan 21, 2025 · 2 comments
Open
2 tasks done

Load in e2e testing strings from en-US.json file #1099

andrewtavis opened this issue Jan 21, 2025 · 2 comments
Assignees
Labels
feature New feature or request help wanted Extra attention is needed

Comments

@andrewtavis
Copy link
Member

Terms

Description

In discussing the new end to end testing setup with @cquinn540 we realized that we do not want to have to change the tests every time that the i18n strings have been changed. In order to mitigate this, we would like all strings used within the end to end tests in the frontend/test-e2e directory to access their strings from the en-US.json file directly.

Contribution

Happy to discuss and work on this with people! Would be a great first issue for someone who has some JavaScript/TypeScript experience 😊

@Abhi-Bohora
Copy link
Contributor

👋 @andrewtavis i have decided to look into this issue. I have thought of working this way:
creating a utility function that look up the key and returns the corresponding value activist\frontend\utils\enUs.ts

import enUs from "../../frontend/i18n/en-US.json";

type I18nKeys = typeof enUs & { [key: string]: string };

export const getI18nString = (key: string) => {
  return (enUs as I18nKeys)[key];
};

And update in the places where necessary for example in this activist\frontend\test-e2e\accessibility\accessible-names.ts

// SPDX-License-Identifier: AGPL-3.0-or-later
import { getI18nString } from "~/utils/enUs";

export const ROADMAP_LINK_NAME = new RegExp(
  getI18nString("components.btn_road_map.aria_label"),
  "i"
);
export const ACTIVIST_LANDING_LINK_NAME = new RegExp(
  getI18nString("components.logo_activist.aria_label"),
  "i"
);

export const SIGN_IN_LINK_NAME = new RegExp(
  getI18nString("_global.sign_in_aria_label"),
  "i"
);
export const SIGN_UP_LINK_NAME = new RegExp(
  getI18nString("_global.sign_up_aria_label"),
  "i"
);

What do you think ? 😊

@andrewtavis
Copy link
Member Author

Looks great to me, @Abhi-Bohora! Feel free to open a PR with the changes for all the e2e files :)

CC @cquinn540 (although seeing you've already seen this 😇)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request help wanted Extra attention is needed
Projects
Status: In Progress
Development

No branches or pull requests

2 participants