Skip to content

Commit

Permalink
Merge branch 'staging' into feature/entity-entity-relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
clari182 committed Dec 13, 2024
2 parents 3371b85 + 05b7f1c commit b7c5498
Show file tree
Hide file tree
Showing 20 changed files with 7,863 additions and 29 deletions.
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: 3 additions & 1 deletion site/gatsby-site/i18n/locales/fr/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@
"Add or remove relationships to other entities": "Ajouter ou supprimer des relations avec d'autres entités",
"Loading related entities...": "Chargement des entités associées...",
"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"
"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: 3 additions & 1 deletion site/gatsby-site/i18n/locales/ja/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
"Add or remove relationships to other entities": "他の組織との関係を追加または削除",
"Loading related entities...": "関連する組繹を読み込み中...",
"The AI implicated system is": "関連するAIシステムは です",
"The AI implicated systems are": "関連する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 @@ -4,13 +4,15 @@ type ConfigType = {
IS_EMPTY_ENVIRONMENT: string;
AVAILABLE_LANGUAGES?: string;
[key: string]: string;
SITE_URL?: string;
};

const config: ConfigType = {
E2E_ADMIN_PASSWORD: process.env.E2E_ADMIN_PASSWORD!,
E2E_ADMIN_USERNAME: process.env.E2E_ADMIN_USERNAME!,
IS_EMPTY_ENVIRONMENT: process.env.IS_EMPTY_ENVIRONMENT ?? '',
AVAILABLE_LANGUAGES: process.env.GATSBY_AVAILABLE_LANGUAGES ?? '',
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 @@ -452,7 +452,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
6 changes: 4 additions & 2 deletions site/gatsby-site/playwright/e2e/blog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ test.describe('Blog', () => {
await page.setViewportSize({ width: 1280, height: 1000 });
await page.goto('/blog/the-first-taxonomy-of-ai-incidents');

await expect(page.locator('[data-cy="outline"]')).toBeVisible();
const outlineItems = page.locator('[data-cy="outline"] > li');
await expect(outlineItems).toHaveCount(5);

Expand All @@ -87,8 +88,9 @@ test.describe('Blog', () => {
await page.setViewportSize({ width: 1280, height: 1000 });
await page.goto('/es/blog/multilingual-incident-reporting');

const outlineItemsCount = await page.locator('[data-cy="outline"] > li').count();
await expect(outlineItemsCount).toBeGreaterThanOrEqual(3);
await expect(page.locator('[data-cy="outline"]')).toBeVisible();
const outlineItems = page.locator('[data-cy="outline"] > li');
await expect(outlineItems).toHaveCount(4);

await expect(page.locator('[data-cy="outline"]:has-text("¿Como funciona?")')).toBeVisible();
await expect(page.locator('[data-cy="outline"]:has-text("Llamado a la acción")')).toBeVisible();
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 b7c5498

Please sign in to comment.