Skip to content

Commit

Permalink
Fix incident table display date
Browse files Browse the repository at this point in the history
  • Loading branch information
clari182 committed Aug 28, 2024
1 parent a88baba commit 37eb9f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions site/gatsby-site/playwright/e2e-full/apps/incidents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,13 @@ test.describe('Incidents App', () => {
const rowLocator = page.locator('[data-cy="row"]').first();
const firstIncident = incidents[0];

await expect(rowLocator.locator('[data-cy="cell"]')).toHaveCount(7, {timeout: 10000});
await expect(rowLocator.locator('[data-cy="cell"]')).toHaveCount(7, { timeout: 10000 });

await expect(rowLocator.locator('[data-cy="cell"]').nth(0)).toHaveText(`Incident ${firstIncident.incident_id}`);
await expect(rowLocator.locator('[data-cy="cell"]').nth(1)).toHaveText(firstIncident.title);
await expect(rowLocator.locator('[data-cy="cell"]').nth(2)).toHaveText(firstIncident.description);

// TODO: fix this, it's returning a one day off date
// await expect(rowLocator.locator('[data-cy="cell"]').nth(3)).toHaveText(firstIncident.date);
await expect(rowLocator.locator('[data-cy="cell"]').nth(3)).toHaveText(firstIncident.date);

await expect(rowLocator.locator('[data-cy="cell"]').nth(4)).toHaveText(firstIncident.AllegedDeployerOfAISystem.map((i: any) => i.name).join(', '));
await expect(rowLocator.locator('[data-cy="cell"]').nth(5)).toHaveText(firstIncident.AllegedDeveloperOfAISystem.map((i: any) => i.name).join(', '));
Expand Down
2 changes: 1 addition & 1 deletion site/gatsby-site/src/components/ui/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export function SelectColumnFilter({
}

export function formatDateField(date) {
const dateObj = new Date(date);
const dateObj = new Date(`${date}T00:00:00`); // Fix date to avoid timezone issues

if (dateObj instanceof Date && !isNaN(dateObj)) {
return <>{format(new Date(dateObj), 'yyyy-MM-dd')}</>;
Expand Down

0 comments on commit 37eb9f7

Please sign in to comment.