Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[i18n] Add tests to @elastic/eui tokens #99613

Closed
wants to merge 2 commits into from

Conversation

afharo
Copy link
Member

@afharo afharo commented May 10, 2021

Summary

Add tests to ensure that the i18n tokens from @elastic/eui and their mapping in Kibana are in sync.

The tests are meant to apply the following checks:

  1. Are we missing any label? Do we have any label that no longer applies?
  2. The labels that require values, are they mapped as functions?
  3. Are the EUI Tokens mapped to core.{EUI Tokens}?
  4. Does the defaultValue match EUI's defString for every token?
  5. Are we using the same values as expected in the props of EuiI18n?

Related issues/PRs

⚠️ Keeping it as draft until #99382 is completed

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@afharo afharo added release_note:skip Skip the PR/issue when compiling release notes v7.14.0 auto-backport Deprecated - use backport:version if exact versions are needed labels May 10, 2021
Comment on lines +21 to +29
/**
* List here those EUI tokens which defaultMessages are intentionally changed in Kibana.
* Looking at the examples in the list, it looks like this is a workaround
* while @elastic/eui fixes the translations on their end.
*/
const INTENTIONALLY_OVERRIDDEN_TRANSLATIONS: EuiToken[] = [
'euiTourStep.closeTour', // "Close tour" makes more sense for consistency, since we have "Skip tour" and "End tour"
'euiTourStepIndicator.ariaLabel', // `@elastic/eui` extracted it as a stringified function
];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed many inconsistencies in Kibana to match @elastic/eui's guidance. But these 2 keys, I actually think they make more sense how Kibana defines them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc'ing @ryankeairns since git blame points to him as the dev that added those two.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential fix for euiTourStepIndicator.ariaLabel elastic/eui#4785

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also created the discuss issue elastic/eui#4787 for euiTourStep.closeTour

defaultMessage: '${count} ${filterCountLabel} filters',
values: { count, filterCountLabel: hasActiveFilters ? 'active' : 'available' },
defaultMessage: '{count} {hasActiveFilters} filters',
values: { count, hasActiveFilters: hasActiveFilters ? 'active' : 'available' },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be doing that 'active' | 'available' text replacement here. They'll show as-is for any other locales.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #99644 to follow that fix.

@afharo
Copy link
Member Author

afharo commented May 26, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

@afharo afharo force-pushed the i18n/add-tests-to-eui-tokens branch from 51a9250 to d0811bc Compare May 26, 2021 11:55
@kibanamachine
Copy link
Contributor

kibanamachine commented May 26, 2021

💔 Build Failed

Failed CI Steps


Test Failures

Kibana Pipeline / jest / Jest Tests.x-pack/plugins/apm/public/components/shared/TransactionActionMenu.TransactionActionMenu component matches the snapshot

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expect(received).toMatchSnapshot()

Snapshot name: `TransactionActionMenu component matches the snapshot 1`

- Snapshot  - 0
+ Received  + 1

@@ -13,10 +13,11 @@
          <span
            class="euiButtonContent euiButtonContent--iconRight euiButton__content"
          >
            <span
              class="euiButtonContent__icon"
+             color="inherit"
              data-euiicon-type="arrowDown"
            />
            <span
              class="euiButton__text"
            >
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.test.tsx:259:23)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Kibana Pipeline / jest / Jest Tests.x-pack/plugins/reporting/public/components.ReportListing Report job listing with some items

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expect(received).toMatchSnapshot()

Snapshot name: `ReportListing Report job listing with some items 1`

- Snapshot  -  16
+ Received  + 144

@@ -215,22 +215,38 @@
                          Object {
                            "width": undefined,
                          }
                        }
                      >
-                       <div
+                       <CellContents
+                         className="euiTableCellContent"
+                         showSortMsg={false}
+                       >
+                         <span
                            className="euiTableCellContent"
                          >
                            <EuiInnerText>
+                             <EuiI18n
+                               default="{innerText}; {description}"
+                               token="euiTableHeaderCell.titleTextWithDesc"
+                               values={
+                                 Object {
+                                   "description": undefined,
+                                   "innerText": "Report",
+                                 }
+                               }
+                             >
                                <span
                                  className="euiTableCellContent__text"
                                  title="Report"
                                >
                                  Report
                                </span>
+                             </EuiI18n>
                            </EuiInnerText>
-                       </div>
+                         </span>
+                       </CellContents>
                      </th>
                    </EuiTableHeaderCell>
                    <EuiTableHeaderCell
                      align="left"
                      data-test-subj="tableHeaderCell_created_at_1"
@@ -244,23 +260,39 @@
                        style={
                          Object {
                            "width": undefined,
                          }
                        }
+                     >
+                       <CellContents
+                         className="euiTableCellContent"
+                         showSortMsg={false}
                        >
-                       <div
+                         <span
                            className="euiTableCellContent"
                          >
                            <EuiInnerText>
+                             <EuiI18n
+                               default="{innerText}; {description}"
+                               token="euiTableHeaderCell.titleTextWithDesc"
+                               values={
+                                 Object {
+                                   "description": undefined,
+                                   "innerText": "Created at",
+                                 }
+                               }
+                             >
                                <span
                                  className="euiTableCellContent__text"
                                  title="Created at"
                                >
                                  Created at
                                </span>
+                             </EuiI18n>
                            </EuiInnerText>
-                       </div>
+                         </span>
+                       </CellContents>
                      </th>
                    </EuiTableHeaderCell>
                    <EuiTableHeaderCell
                      align="left"
                      data-test-subj="tableHeaderCell_status_2"
@@ -274,23 +306,39 @@
                        style={
                          Object {
                            "width": undefined,
                          }
                        }
+                     >
+                       <CellContents
+                         className="euiTableCellContent"
+                         showSortMsg={false}
                        >
-                       <div
+                         <span
                            className="euiTableCellContent"
                          >
                            <EuiInnerText>
+                             <EuiI18n
+                               default="{innerText}; {description}"
+                               token="euiTableHeaderCell.titleTextWithDesc"
+                               values={
+                                 Object {
+                                   "description": undefined,
+                                   "innerText": "Status",
+                                 }
+                               }
+                             >
                                <span
                                  className="euiTableCellContent__text"
                                  title="Status"
                                >
                                  Status
                                </span>
+                             </EuiI18n>
                            </EuiInnerText>
-                       </div>
+                         </span>
+                       </CellContents>
                      </th>
                    </EuiTableHeaderCell>
                    <EuiTableHeaderCell
                      align="right"
                      key="_actions_h_3"
@@ -303,22 +351,38 @@
                          Object {
                            "width": undefined,
                          }
                        }
                      >
-                       <div
+                       <CellContents
                          className="euiTableCellContent euiTableCellContent--alignRight"
+                         showSortMsg={false}
                        >
+                         <span
+                           className="euiTableCellContent euiTableCellContent--alignRight"
+                         >
                            <EuiInnerText>
+                             <EuiI18n
+                               default="{innerText}; {description}"
+                               token="euiTableHeaderCell.titleTextWithDesc"
+                               values={
+                                 Object {
+                                   "description": undefined,
+                                   "innerText": "Actions",
+                                 }
+                               }
+                             >
                                <span
                                  className="euiTableCellContent__text"
                                  title="Actions"
                                >
                                  Actions
                                </span>
+                             </EuiI18n>
                            </EuiInnerText>
-                       </div>
+                         </span>
+                       </CellContents>
                      </th>
                    </EuiTableHeaderCell>
                  </tr>
                </thead>
              </EuiTableHeader>
@@ -524,23 +588,39 @@
                      style={
                        Object {
                          "width": undefined,
                        }
                      }
+                   >
+                     <CellContents
+                       className="euiTableCellContent"
+                       showSortMsg={false}
                      >
-                     <div
+                       <span
                          className="euiTableCellContent"
                        >
                          <EuiInnerText>
+                           <EuiI18n
+                             default="{innerText}; {description}"
+                             token="euiTableHeaderCell.titleTextWithDesc"
+                             values={
+                               Object {
+                                 "description": undefined,
+                                 "innerText": "Report",
+                               }
+                             }
+                           >
                              <span
                                className="euiTableCellContent__text"
                                title="Report"
                              >
                                Report
                              </span>
+                           </EuiI18n>
                          </EuiInnerText>
-                     </div>
+                       </span>
+                     </CellContents>
                    </th>
                  </EuiTableHeaderCell>
                  <EuiTableHeaderCell
                    align="left"
                    data-test-subj="tableHeaderCell_created_at_1"
@@ -555,22 +635,38 @@
                        Object {
                          "width": undefined,
                        }
                      }
                    >
-                     <div
+                     <CellContents
                        className="euiTableCellContent"
+                       showSortMsg={false}
                      >
+                       <span
+                         className="euiTableCellContent"
+                       >
                          <EuiInnerText>
+                           <EuiI18n
+                             default="{innerText}; {description}"
+                             token="euiTableHeaderCell.titleTextWithDesc"
+                             values={
+                               Object {
+                                 "description": undefined,
+                                 "innerText": "Created at",
+                               }
+                             }
+                           >
                              <span
                                className="euiTableCellContent__text"
                                title="Created at"
                              >
                                Created at
                              </span>
+                           </EuiI18n>
                          </EuiInnerText>
-                     </div>
+                       </span>
+                     </CellContents>
                    </th>
                  </EuiTableHeaderCell>
                  <EuiTableHeaderCell
                    align="left"
                    data-test-subj="tableHeaderCell_status_2"
@@ -585,22 +681,38 @@
                        Object {
                          "width": undefined,
                        }
                      }
                    >
-                     <div
+                     <CellContents
                        className="euiTableCellContent"
+                       showSortMsg={false}
                      >
+                       <span
+                         className="euiTableCellContent"
+                       >
                          <EuiInnerText>
+                           <EuiI18n
+                             default="{innerText}; {description}"
+                             token="euiTableHeaderCell.titleTextWithDesc"
+                             values={
+                               Object {
+                                 "description": undefined,
+                                 "innerText": "Status",
+                               }
+                             }
+                           >
                              <span
                                className="euiTableCellContent__text"
                                title="Status"
                              >
                                Status
                              </span>
+                           </EuiI18n>
                          </EuiInnerText>
-                     </div>
+                       </span>
+                     </CellContents>
                    </th>
                  </EuiTableHeaderCell>
                  <EuiTableHeaderCell
                    align="right"
                    key="_actions_h_3"
@@ -613,22 +725,38 @@
                        Object {
                          "width": undefined,
                        }
                      }
                    >
-                     <div
+                     <CellContents
                        className="euiTableCellContent euiTableCellContent--alignRight"
+                       showSortMsg={false}
                      >
+                       <span
+                         className="euiTableCellContent euiTableCellContent--alignRight"
+                       >
                          <EuiInnerText>
+                           <EuiI18n
+                             default="{innerText}; {description}"
+                             token="euiTableHeaderCell.titleTextWithDesc"
+                             values={
+                               Object {
+                                 "description": undefined,
+                                 "innerText": "Actions",
+                               }
+                             }
+                           >
                              <span
                                className="euiTableCellContent__text"
                                title="Actions"
                              >
                                Actions
                              </span>
+                           </EuiI18n>
                          </EuiInnerText>
-                     </div>
+                       </span>
+                     </CellContents>
                    </th>
                  </EuiTableHeaderCell>
                </tr>
              </thead>
            </EuiTableHeader>
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/reporting/public/components/report_listing.test.tsx:79:19)
    at Promise.then.completed (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:276:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:216:10)
    at _callCircusTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:212:40)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at _runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:149:3)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:63:9)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:57:9)
    at run (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:176:21)
    at jestAdapter (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:109:19)
    at runTestInternal (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:380:16)
    at runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:472:34)
    at Object.worker (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/testWorker.js:133:12)

Kibana Pipeline / jest / Jest Tests.x-pack/plugins/index_lifecycle_management/__jest__.extend index management ilm summary extension should return extension when index has lifecycle error

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expect(received).toMatchSnapshot()

Snapshot name: `extend index management ilm summary extension should return extension when index has lifecycle error 1`

- Snapshot  - 0
+ Received  + 3

@@ -190,16 +190,18 @@
          className="euiCallOutHeader"
        >
          <EuiIcon
            aria-hidden="true"
            className="euiCallOutHeader__icon"
+           color="inherit"
            size="m"
            type="cross"
          >
            <span
              aria-hidden="true"
              className="euiCallOutHeader__icon"
+             color="inherit"
              data-euiicon-type="cross"
              size="m"
            />
          </EuiIcon>
          <span
@@ -268,10 +270,11 @@
                      type="button"
                    >
                      <EuiButtonContent
                        className="euiButtonEmpty__content"
                        iconSide="left"
+                       iconSize="m"
                        textProps={
                          Object {
                            "className": "euiButtonEmpty__text",
                          }
                        }
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/index_lifecycle_management/__jest__/extend_index_management.test.tsx:264:24)
    at Promise.then.completed (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:276:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:216:10)
    at _callCircusTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:212:40)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at _runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:149:3)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:63:9)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:57:9)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:57:9)
    at run (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:176:21)
    at jestAdapter (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:109:19)
    at runTestInternal (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:380:16)
    at runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:472:34)
    at Object.worker (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/testWorker.js:133:12)

and 133 more failures, only showing the first 3.

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 6.9MB 6.9MB +124.0B
visTypeTimeseries 1.7MB 1.7MB +80.0B
total +204.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 408.0KB 408.4KB +347.0B
kbnUiSharedDeps-css 501.7KB 503.3KB +1.6KB
kbnUiSharedDeps-elastic 3.3MB 3.0MB -274.3KB
kbnUiSharedDeps-js 6.7MB 5.9MB -824.9KB
total -1.1MB

History

  • 💔 Build #125037 failed 51a9250ee54b0c26459173f42e6fb0f05935f6c3
  • 💔 Build #124988 failed 368ba176296ce032948abe964d5767b75e54d9cb

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@Bamieh Bamieh self-assigned this Jun 2, 2021
@spalger spalger added v7.15.0 and removed v7.14.0 labels Jun 30, 2021
@Bamieh
Copy link
Member

Bamieh commented Jul 21, 2021

Closing in favor of #106377

@Bamieh Bamieh closed this Jul 21, 2021
@afharo afharo deleted the i18n/add-tests-to-eui-tokens branch August 2, 2021 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Project:i18n release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EUI labels not translating
5 participants