diff --git a/.changeset/gorgeous-pugs-deliver.md b/.changeset/gorgeous-pugs-deliver.md new file mode 100644 index 0000000000..82820baa67 --- /dev/null +++ b/.changeset/gorgeous-pugs-deliver.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Set the default TZ (Timezone) env for the test command to be UTC so any date related tests are consistent across timezones. diff --git a/.changeset/wicked-jars-move.md b/.changeset/wicked-jars-move.md new file mode 100644 index 0000000000..d2e9bc5446 --- /dev/null +++ b/.changeset/wicked-jars-move.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-cloudbuild': patch +--- + +- Swaps over the plugin CloudBuild from using MomentJS to using Luxon for date formatting. +- Fixes some React warnings generated by nested
elements.
diff --git a/packages/cli/src/commands/testCommand.ts b/packages/cli/src/commands/testCommand.ts
index d885e1aec9..24a4e06f9e 100644
--- a/packages/cli/src/commands/testCommand.ts
+++ b/packages/cli/src/commands/testCommand.ts
@@ -63,6 +63,13 @@ export default async (cmd: Command) => {
(process.env as any).NODE_ENV = 'test';
}
+ // This is to have a consistent timezone for when running tests that involve checking
+ // the formatting of date/times.
+ // https://stackoverflow.com/questions/56261381/how-do-i-set-a-timezone-in-my-jest-config
+ if (!process.env.TZ) {
+ process.env.TZ = 'UTC';
+ }
+
// eslint-disable-next-line jest/no-jest-import
await require('jest').run(args);
};
diff --git a/plugins/cloudbuild/package.json b/plugins/cloudbuild/package.json
index d45542a082..6ae81ba6e4 100644
--- a/plugins/cloudbuild/package.json
+++ b/plugins/cloudbuild/package.json
@@ -38,7 +38,7 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.45",
- "moment": "^2.27.0",
+ "luxon": "^2.0.2",
"qs": "^6.9.4",
"react": "^16.13.1",
"react-dom": "^16.13.1",
diff --git a/plugins/cloudbuild/src/components/WorkflowRunsTable/WorkflowRunsTable.test.tsx b/plugins/cloudbuild/src/components/WorkflowRunsTable/WorkflowRunsTable.test.tsx
new file mode 100644
index 0000000000..ac28c5bedf
--- /dev/null
+++ b/plugins/cloudbuild/src/components/WorkflowRunsTable/WorkflowRunsTable.test.tsx
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2020 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { renderInTestApp } from '@backstage/test-utils';
+import React from 'react';
+import { WorkflowRunsTableView } from './WorkflowRunsTable';
+import { WorkflowRun } from '../useWorkflowRuns';
+
+describe(' {row.id?.substring(0, 8)} {row.substitutions?.BRANCH_NAME} {row.substitutions?.SHORT_SHA} {moment(row.createTime).format('DD-MM-YYYY hh:mm:ss')}