Properly check the required 'action' property

Should also be a blueprint for doing the same in other elements.

Change-Id: I45574c2dfdeb593d89e90f4f70405a8bfff70550
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-tab.ts b/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
index 1abe631..61f8bd1 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
@@ -32,6 +32,7 @@
   ActionTriggeredEvent,
   fireActionTriggered,
 } from '../../services/checks/checks-util';
+import {checkRequiredProperty} from '../../utils/common-util';
 
 /**
  * The "Checks" tab on the Gerrit change page. Gets its data from plugins that
@@ -154,6 +155,11 @@
   @property()
   action!: Action;
 
+  connectedCallback() {
+    super.connectedCallback();
+    checkRequiredProperty(this.action, 'action');
+  }
+
   render() {
     return html`
       <gr-button link class="action" @click="${this.handleClick}"
diff --git a/polygerrit-ui/app/utils/common-util.ts b/polygerrit-ui/app/utils/common-util.ts
index f95105d..2246251 100644
--- a/polygerrit-ui/app/utils/common-util.ts
+++ b/polygerrit-ui/app/utils/common-util.ts
@@ -69,6 +69,18 @@
 /**
  * Throws an error if the property is not defined.
  */
+export function checkRequiredProperty<T>(
+  property: T,
+  propertyName: string
+): asserts property is NonNullable<T> {
+  if (property === undefined || property === null) {
+    throw new Error(`Required property '${propertyName}' not set.`);
+  }
+}
+
+/**
+ * Throws an error if the property is not defined.
+ */
 export function assertIsDefined<T>(
   val: T,
   variableName = 'variable'