Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/staging' into feature-magic-links
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarvarela committed Dec 11, 2024
2 parents 45305db + 97c647f commit 5cee07b
Show file tree
Hide file tree
Showing 20 changed files with 7,822 additions and 7,819 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/realm-empty-env.yml

This file was deleted.

8 changes: 7 additions & 1 deletion site/gatsby-site/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ cloudinary.config({ cloud_name: config.cloudinary.cloudName });

const adapter = require('gatsby-adapter-netlify').default;

let googleTrackingIds = [];

if (process.env.SITE_URL === config.gatsby.siteUrl) {
googleTrackingIds.push(config.gatsby.gaTrackingId);
}

const plugins = [
'layout',
{
Expand Down Expand Up @@ -65,7 +71,7 @@ const plugins = [
{
resolve: `gatsby-plugin-google-gtag`,
options: {
trackingIds: [config.gatsby.gaTrackingId],
trackingIds: googleTrackingIds,
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions site/gatsby-site/i18n/locales/es/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"Incidents involved as both Developer and Deployer": "Incidentes involucrados como desarrollador e implementador",
"Incidents Harmed By": "Afectado por Incidentes",
"Alleged: <2></2> developed and deployed an AI system, which harmed <6></6>.": "Presunto: un sistema de IA desarrollado e implementado por <2></2>, perjudicó a <6></6>.",
"The AI implicated system is": "El sistema de IA implicado es",
"The AI implicated systems are": "Los sistemas de IA implicados son",
"Implicated AI system:": "Sistema de IA implicado:",
"Implicated AI systems:": "Sistemas de IA implicados:",
"Alleged: <1></1> developed an AI system deployed by <4></4>, which harmed <6></6>.": "Presunto: un sistema de IA desarrollado por <1></1> e implementado por <4></4>, perjudicó a <6></6>.",
"Entities involved in AI Incidents": "^Entities involved in AI Incidents",
"{{count}} Incident responses": "{{count}} respuestas de incidentes",
Expand Down
4 changes: 2 additions & 2 deletions site/gatsby-site/i18n/locales/fr/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"Back to Entity: {{name}}": "Retour à l'entité: {{name}}",
"Entity updated successfully.": "Entité mise à jour avec succès.",
"Error updating Entity.": "Erreur lors de la mise à jour de l'entité.",
"The AI implicated system is": "Le système d'IA impliqué est",
"The AI implicated systems are": "Les systèmes d'IA impliqués sont"
"Implicated AI system:": "Système de l'IA impliqué:",
"Implicated AI systems:": "Systèmes de l'IA impliqués:"
}
4 changes: 2 additions & 2 deletions site/gatsby-site/i18n/locales/ja/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"Back to Entity: {{name}}": "組織に戻る: {{name}}",
"Entity updated successfully.": "組織が正常に更新されました。",
"Error updating Entity.": "組織の更新中にエラーが発生しました。",
"The AI implicated system is": "関連するAIシステムは です",
"The AI implicated systems are": "関連するAIシステムは です"
"Implicated AI system:": "AI関連システム:",
"Implicated AI systems:": "AI関連システム:"
}
2 changes: 2 additions & 0 deletions site/gatsby-site/playwright/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type ConfigType = {
AVAILABLE_LANGUAGES?: string;
NEXTAUTH_URL?: string;
NEXTAUTH_SECRET?: string;
SITE_URL?: string;
};

const config: ConfigType = {
Expand All @@ -14,6 +15,7 @@ const config: ConfigType = {
AVAILABLE_LANGUAGES: process.env.GATSBY_AVAILABLE_LANGUAGES ?? '',
NEXTAUTH_URL: process.env.NEXTAUTH_URL!,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET!,
SITE_URL: process.env.SITE_URL ?? '',
}

Object.keys(config).forEach((key) => {
Expand Down
2 changes: 1 addition & 1 deletion site/gatsby-site/playwright/e2e-full/cite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ test.describe('Cite pages', () => {
test('Should show proper entities card text', async ({ page }) => {
await page.goto('/cite/3/');
await expect(page.locator('[data-cy="alleged-entities"]')).toHaveText(
'Alleged: Kronos developed an AI system deployed by Starbucks, which harmed Starbucks Employees.The AI implicated system is Entity 1.'
'Alleged: Kronos developed an AI system deployed by Starbucks, which harmed Starbucks Employees.Implicated AI system: Entity 1'
);
});

Expand Down
2 changes: 1 addition & 1 deletion site/gatsby-site/playwright/e2e-full/dynamicCite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test.describe('Dynamic Cite pages', () => {
await expect(page.getByText(`Kronos’s scheduling algorithm and its use by Starbucks managers allegedly negatively impacted financial and scheduling stability for Starbucks employees, which disadvantaged wage workers.`)).toBeVisible();

await expect(page.locator('[data-cy="alleged-entities"]')).toHaveText(
'Alleged: Kronos developed an AI system deployed by Starbucks, which harmed Starbucks Employees.The AI implicated system is Entity 1.'
'Alleged: Kronos developed an AI system deployed by Starbucks, which harmed Starbucks Employees.Implicated AI system: Entity 1'
);

await expect(page.locator('[data-cy="citation"]').getByText("Report Count", { exact: true }).locator('xpath=following-sibling::div[1]')).toHaveText('2');
Expand Down
17 changes: 13 additions & 4 deletions site/gatsby-site/playwright/e2e-full/translationBadge.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test';
import { test } from '../utils';
import { mockAlgolia, test } from '../utils';

test.describe('Translation Badges', () => {
test('Should be visible on blog post', async ({ page }) => {
Expand All @@ -15,9 +15,18 @@ test.describe('Translation Badges', () => {
await expect(page.locator('a', { hasText: 'Ver Original' })).not.toBeVisible();
});

test('Should be visible on the discover app', async ({ page, skipOnEmptyEnvironment }) => {
await page.goto('/es/apps/discover?display=details&incident_id=1&page=1&source_domain=today.com');
await expect(page.locator('[data-cy="5d34b8c29ced494f010ed45c"]').locator('[data-cy="translation-badge"]').getByText('Traducido por IA')).toBeVisible();
test('Should be visible on the discover app if the item has a translation available', async ({ page, skipOnEmptyEnvironment }) => {
await mockAlgolia(page);

await page.goto('/es/apps/discover');
await expect(page.locator('[data-cy="6243a9eedf8b4b62d982817e"]').locator('[data-cy="translation-badge"]').getByText('Traducido por IA')).toBeVisible();
});

test('Should not be visible on the discover app if the item does not have a translation available', async ({ page, skipOnEmptyEnvironment }) => {
await mockAlgolia(page);

await page.goto('/es/apps/discover');
await expect(page.locator('[data-cy="5d34b8c29ced494f010ed470"]').locator('[data-cy="translation-badge"]').getByText('Traducido por IA')).not.toBeVisible();
});

test('Should be visible on an report card on the citation page if it was translated', async ({ page, skipOnEmptyEnvironment }) => {
Expand Down
40 changes: 40 additions & 0 deletions site/gatsby-site/playwright/e2e/unit/gtag.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { expect } from '@playwright/test';
import config from '../../../config';
import { test } from '../../utils';

const googleTrackingId = config.gatsby.gaTrackingId;

test.describe('Google Analytics Tracking', () => {
test('Should track gtag only on production', async ({ page, runOnlyInProduction }) => {
await page.goto('/');

const hasGoogleTracking = await page.locator(`script[src*="https://www.googletagmanager.com/gtag/js?id=${googleTrackingId}"]`).count();

expect(hasGoogleTracking).toBeGreaterThan(0);

const [trackingRequest] = await Promise.all([
page.waitForRequest((request) => request.url().includes(`https://www.google-analytics.com`) && request.method() === 'POST'),

]);

expect(trackingRequest).toBeTruthy();
});


test('Should not track gtag outside production', async ({ page, runAnywhereExceptProduction }) => {
await page.goto('/');

const hasGoogleTracking = await page.locator(`script[src*="https://www.googletagmanager.com/gtag/js?id=${googleTrackingId}"]`).count();
expect(hasGoogleTracking).toBe(0);

let trackingRequestMade = false;
page.on('request', (request) => {
if (request.url().includes(`https://www.google-analytics.com`) && request.method() === 'POST') {
trackingRequestMade = true;
}
});

await page.reload();
expect(trackingRequestMade).toBe(false);
});
});
Loading

0 comments on commit 5cee07b

Please sign in to comment.