• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / fx-private-relay / 63ad679c-7c70-4935-8fd6-bc0176e80b72

15 Dec 2023 07:08PM CUT coverage: 73.514%. Remained the same
63ad679c-7c70-4935-8fd6-bc0176e80b72

push

circleci

jwhitlock
Use branch database with production tests

Previously, migrations tests were run with production code, branch
requirements, and branch migrations. Now they run with production
requirements, so that third-party migrations are tested as well.

This uses pytest --reuse-db to create a test database with the branch's
migrations, and then a pip install with the production code. This more
closely emulates the mixed environment during a deploy.

1962 of 2913 branches covered (0.0%)

Branch coverage included in aggregate %.

6273 of 8289 relevant lines covered (75.68%)

19.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/frontend/src/components/waitlist/CountryPicker.tsx
1
import { SelectHTMLAttributes, useEffect, useState } from "react";
×
2
import { getLocale } from "../../functions/getLocale";
×
3
import { useL10n } from "../../hooks/l10n";
×
4

5
type LocaleDisplayNames = Record<string, string>;
6
type Territories = {
7
  main: Record<
8
    string,
9
    {
10
      localeDisplayNames: {
11
        territories: LocaleDisplayNames;
12
      };
13
    }
14
  >;
15
};
16
export type Props = SelectHTMLAttributes<HTMLSelectElement>;
17
export const CountryPicker = (props: Props) => {
×
18
  const l10n = useL10n();
×
19
  const currentLocale = getLocale(l10n);
×
20
  const [localeDisplayNames, setLocaleDisplayNames] =
21
    useState<LocaleDisplayNames>();
×
22

23
  useEffect(() => {
×
24
    importTerritories(currentLocale).then((localeDisplayNames) => {
×
25
      setLocaleDisplayNames(localeDisplayNames);
×
26
    });
27
  }, [currentLocale]);
28

29
  const options = Object.entries(localeDisplayNames ?? {})
×
30
    // cldr-localenames-modern also includes names of continents,
31
    // whose territory codes consist of numbers.
32
    // (See e.g. node_modules/cldr-localenames-modern/main/en/territories.json.)
33
    // Since we're only interested in countries, filter those out:
34
    .filter(
35
      ([code]) =>
36
        !["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].some((nr) =>
×
37
          code.includes(nr),
×
38
        ),
39
    )
40
    .sort(([_codeA, nameA], [_codeB, nameB]) => nameA.localeCompare(nameB))
×
41
    .map(([code, name]) => (
42
      <option key={code} value={code}>
×
43
        {name}
44
      </option>
45
    ));
46

47
  return <select {...props}>{options}</select>;
48
};
49

50
async function importTerritories(locale: string): Promise<LocaleDisplayNames> {
51
  try {
×
52
    const territories: Territories = await import(
×
53
      `cldr-localenames-modern/main/${locale}/territories.json`
×
54
    );
55
    return territories.main[locale].localeDisplayNames.territories;
×
56
  } catch (_e) {
57
    try {
×
58
      // cldr-localenames-modern doesn't include suffixed locale codes for
59
      // locales in their main territory (i.e. it only has `es`, not `es-ES`, or
60
      // `nl` but not `nl-NL`, or `sv` but not `sv-SE`), so try loading a
61
      // truncated version if the full version was not found:
62
      const truncatedLocale = locale.split("-")[0];
×
63
      const territories: Territories = await import(
×
64
        `cldr-localenames-modern/main/${truncatedLocale}/territories.json`
×
65
      );
66
      return territories.main[truncatedLocale].localeDisplayNames.territories;
×
67
    } catch (_e) {
68
      const territoriesEn = await import(
×
69
        "cldr-localenames-modern/main/en/territories.json"
70
      );
71
      return territoriesEn.main.en.localeDisplayNames.territories;
×
72
    }
73
  }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc