mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refactoring dock tab download logs tests (#6149)
* Separate 'download visible' and 'download all' tests Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Add disabled prop to DownloadLogsDropdown Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Test for dropdown if no logs available in the tab Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Fix linter Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Remove unused code statement Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Update snapshots Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
032e6d968c
commit
0fe3242030
@ -1,6 +1,856 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`download logs options in pod logs dock tab when opening pod logs renders 1`] = `
|
||||
exports[`download logs options in logs dock tab opening pod logs when logs available renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
class="Notifications flex column align-flex-end"
|
||||
/>
|
||||
<div
|
||||
class="mainLayout"
|
||||
style="--sidebar-width: 200px;"
|
||||
>
|
||||
<div
|
||||
class="sidebar"
|
||||
>
|
||||
<div
|
||||
class="flex flex-col"
|
||||
data-testid="cluster-sidebar"
|
||||
>
|
||||
<div
|
||||
class="SidebarCluster"
|
||||
>
|
||||
<div
|
||||
class="Avatar rounded loadingAvatar"
|
||||
style="width: 40px; height: 40px;"
|
||||
>
|
||||
??
|
||||
</div>
|
||||
<div
|
||||
class="loadingClusterName"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="sidebarNav sidebar-active-status"
|
||||
>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="true"
|
||||
data-testid="sidebar-item-workloads"
|
||||
>
|
||||
<a
|
||||
aria-current="page"
|
||||
class="navItem active"
|
||||
data-testid="sidebar-item-link-for-workloads"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon svg focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
/>
|
||||
</i>
|
||||
<span>
|
||||
Workloads
|
||||
</span>
|
||||
<i
|
||||
class="Icon expandIcon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-config"
|
||||
>
|
||||
<a
|
||||
class="navItem"
|
||||
data-testid="sidebar-item-link-for-config"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="list"
|
||||
>
|
||||
list
|
||||
</span>
|
||||
</i>
|
||||
<span>
|
||||
Config
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-network"
|
||||
>
|
||||
<a
|
||||
class="navItem"
|
||||
data-testid="sidebar-item-link-for-network"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="device_hub"
|
||||
>
|
||||
device_hub
|
||||
</span>
|
||||
</i>
|
||||
<span>
|
||||
Network
|
||||
</span>
|
||||
<i
|
||||
class="Icon expandIcon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-storage"
|
||||
>
|
||||
<a
|
||||
class="navItem"
|
||||
data-testid="sidebar-item-link-for-storage"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="storage"
|
||||
>
|
||||
storage
|
||||
</span>
|
||||
</i>
|
||||
<span>
|
||||
Storage
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-helm"
|
||||
>
|
||||
<a
|
||||
class="navItem"
|
||||
data-testid="sidebar-item-link-for-helm"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon svg focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
/>
|
||||
</i>
|
||||
<span>
|
||||
Helm
|
||||
</span>
|
||||
<i
|
||||
class="Icon expandIcon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-user-management"
|
||||
>
|
||||
<a
|
||||
class="navItem"
|
||||
data-testid="sidebar-item-link-for-user-management"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="security"
|
||||
>
|
||||
security
|
||||
</span>
|
||||
</i>
|
||||
<span>
|
||||
Access Control
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-custom-resources"
|
||||
>
|
||||
<a
|
||||
class="navItem"
|
||||
data-testid="sidebar-item-link-for-custom-resources"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="extension"
|
||||
>
|
||||
extension
|
||||
</span>
|
||||
</i>
|
||||
<span>
|
||||
Custom Resources
|
||||
</span>
|
||||
<i
|
||||
class="Icon expandIcon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ResizingAnchor horizontal trailing"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="contents"
|
||||
>
|
||||
<div
|
||||
class="TabLayout"
|
||||
data-testid="tab-layout"
|
||||
>
|
||||
<div
|
||||
class="Tabs center scrollable"
|
||||
>
|
||||
<div
|
||||
class="Tab flex gaps align-center active"
|
||||
data-is-active-test="true"
|
||||
data-testid="tab-link-for-overview"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="label"
|
||||
>
|
||||
Overview
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<main>
|
||||
<div
|
||||
class="WorkloadsOverview flex column gaps"
|
||||
data-testid="page-for-workloads-overview"
|
||||
>
|
||||
<div
|
||||
class="header flex gaps align-center"
|
||||
>
|
||||
<h5
|
||||
class="box grow"
|
||||
>
|
||||
Overview
|
||||
</h5>
|
||||
<div
|
||||
class="NamespaceSelectFilterParent"
|
||||
data-testid="namespace-select-filter"
|
||||
>
|
||||
<div
|
||||
class="Select theme-dark NamespaceSelect NamespaceSelectFilter css-b62m3t-container"
|
||||
>
|
||||
<span
|
||||
class="css-1f43avz-a11yText-A11yText"
|
||||
id="react-select-overview-namespace-select-filter-input-live-region"
|
||||
/>
|
||||
<span
|
||||
aria-atomic="false"
|
||||
aria-live="polite"
|
||||
aria-relevant="additions text"
|
||||
class="css-1f43avz-a11yText-A11yText"
|
||||
/>
|
||||
<div
|
||||
class="Select__control css-1s2u09g-control"
|
||||
>
|
||||
<div
|
||||
class="Select__value-container Select__value-container--is-multi css-319lph-ValueContainer"
|
||||
>
|
||||
<div
|
||||
class="Select__placeholder css-14el2xx-placeholder"
|
||||
id="react-select-overview-namespace-select-filter-input-placeholder"
|
||||
>
|
||||
All namespaces
|
||||
</div>
|
||||
<div
|
||||
class="Select__input-container css-6j8wv5-Input"
|
||||
data-value=""
|
||||
>
|
||||
<input
|
||||
aria-autocomplete="list"
|
||||
aria-describedby="react-select-overview-namespace-select-filter-input-placeholder"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
autocapitalize="none"
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
class="Select__input"
|
||||
id="overview-namespace-select-filter-input"
|
||||
role="combobox"
|
||||
spellcheck="false"
|
||||
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
|
||||
tabindex="0"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
|
||||
>
|
||||
<span
|
||||
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
|
||||
/>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="css-tj5bde-Svg"
|
||||
focusable="false"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
width="20"
|
||||
>
|
||||
<path
|
||||
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="OverviewStatuses"
|
||||
>
|
||||
<div
|
||||
class="workloads"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="footer"
|
||||
>
|
||||
<div
|
||||
class="Dock isOpen"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div
|
||||
class="ResizingAnchor vertical leading"
|
||||
/>
|
||||
<div
|
||||
class="tabs-container flex align-center"
|
||||
>
|
||||
<div
|
||||
class="dockTabs"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
class="Tabs tabs"
|
||||
>
|
||||
<div
|
||||
class="Tab flex gaps align-center DockTab active"
|
||||
data-testid="dock-tab-for-log-tab-some-irrelevant-random-id"
|
||||
id="tab-log-tab-some-irrelevant-random-id"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable small"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="subject"
|
||||
>
|
||||
subject
|
||||
</span>
|
||||
</i>
|
||||
<div
|
||||
class="label"
|
||||
>
|
||||
<div
|
||||
class="flex align-center"
|
||||
>
|
||||
<span
|
||||
class="title"
|
||||
>
|
||||
Pod dockerExporter
|
||||
</span>
|
||||
<div
|
||||
class="close"
|
||||
>
|
||||
<i
|
||||
class="Icon material interactive focusable small"
|
||||
tabindex="0"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="close"
|
||||
>
|
||||
close
|
||||
</span>
|
||||
</i>
|
||||
<div>
|
||||
Close ⌘+W
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="toolbar flex gaps align-center box grow"
|
||||
>
|
||||
<div
|
||||
class="dock-menu box grow"
|
||||
>
|
||||
<i
|
||||
class="Icon new-dock-tab material interactive focusable"
|
||||
id="menu-actions-for-dock"
|
||||
tabindex="0"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="add"
|
||||
>
|
||||
add
|
||||
</span>
|
||||
</i>
|
||||
<div>
|
||||
New tab
|
||||
</div>
|
||||
</div>
|
||||
<i
|
||||
class="Icon material interactive focusable"
|
||||
tabindex="0"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="fullscreen"
|
||||
>
|
||||
fullscreen
|
||||
</span>
|
||||
</i>
|
||||
<div>
|
||||
Fit to window
|
||||
</div>
|
||||
<i
|
||||
class="Icon material interactive focusable"
|
||||
tabindex="0"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
<div>
|
||||
Minimize
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="tab-content pod-logs"
|
||||
data-testid="dock-tab-content-for-log-tab-some-irrelevant-random-id"
|
||||
style="flex-basis: 300px;"
|
||||
>
|
||||
<div
|
||||
class="PodLogs flex column"
|
||||
>
|
||||
<div
|
||||
class="InfoPanel flex gaps align-center"
|
||||
>
|
||||
<div
|
||||
class="controls"
|
||||
>
|
||||
<div
|
||||
class="flex gaps"
|
||||
>
|
||||
<div
|
||||
class="LogResourceSelector flex gaps align-center"
|
||||
>
|
||||
<span>
|
||||
Namespace
|
||||
</span>
|
||||
|
||||
<div
|
||||
class="badge"
|
||||
data-testid="namespace-badge"
|
||||
>
|
||||
default
|
||||
</div>
|
||||
<span>
|
||||
Pod
|
||||
</span>
|
||||
<div
|
||||
class="Select theme-dark pod-selector css-b62m3t-container"
|
||||
>
|
||||
<span
|
||||
class="css-1f43avz-a11yText-A11yText"
|
||||
id="react-select-4-live-region"
|
||||
/>
|
||||
<span
|
||||
aria-atomic="false"
|
||||
aria-live="polite"
|
||||
aria-relevant="additions text"
|
||||
class="css-1f43avz-a11yText-A11yText"
|
||||
/>
|
||||
<div
|
||||
class="Select__control css-1s2u09g-control"
|
||||
>
|
||||
<div
|
||||
class="Select__value-container Select__value-container--has-value css-319lph-ValueContainer"
|
||||
>
|
||||
<div
|
||||
class="Select__single-value css-qc6sy-singleValue"
|
||||
>
|
||||
dockerExporter
|
||||
</div>
|
||||
<div
|
||||
class="Select__input-container css-6j8wv5-Input"
|
||||
data-value=""
|
||||
>
|
||||
<input
|
||||
aria-autocomplete="list"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
autocapitalize="none"
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
class="Select__input"
|
||||
id="react-select-4-input"
|
||||
role="combobox"
|
||||
spellcheck="false"
|
||||
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
|
||||
tabindex="0"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
|
||||
>
|
||||
<span
|
||||
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
|
||||
/>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="css-tj5bde-Svg"
|
||||
focusable="false"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
width="20"
|
||||
>
|
||||
<path
|
||||
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span>
|
||||
Container
|
||||
</span>
|
||||
<div
|
||||
class="Select theme-dark container-selector css-b62m3t-container"
|
||||
>
|
||||
<span
|
||||
class="css-1f43avz-a11yText-A11yText"
|
||||
id="react-select-container-selector-input-live-region"
|
||||
/>
|
||||
<span
|
||||
aria-atomic="false"
|
||||
aria-live="polite"
|
||||
aria-relevant="additions text"
|
||||
class="css-1f43avz-a11yText-A11yText"
|
||||
/>
|
||||
<div
|
||||
class="Select__control css-1s2u09g-control"
|
||||
>
|
||||
<div
|
||||
class="Select__value-container Select__value-container--has-value css-319lph-ValueContainer"
|
||||
>
|
||||
<div
|
||||
class="Select__single-value css-qc6sy-singleValue"
|
||||
>
|
||||
docker-exporter
|
||||
</div>
|
||||
<div
|
||||
class="Select__input-container css-6j8wv5-Input"
|
||||
data-value=""
|
||||
>
|
||||
<input
|
||||
aria-autocomplete="list"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
autocapitalize="none"
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
class="Select__input"
|
||||
id="container-selector-input"
|
||||
role="combobox"
|
||||
spellcheck="false"
|
||||
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
|
||||
tabindex="0"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
|
||||
>
|
||||
<span
|
||||
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
|
||||
/>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="css-tj5bde-Svg"
|
||||
focusable="false"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
width="20"
|
||||
>
|
||||
<path
|
||||
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="LogSearch flex box grow justify-flex-end gaps align-center"
|
||||
>
|
||||
<div
|
||||
class="Input SearchInput focused"
|
||||
>
|
||||
<label
|
||||
class="input-area flex gaps align-center"
|
||||
id=""
|
||||
>
|
||||
<input
|
||||
class="input box grow"
|
||||
placeholder="Search..."
|
||||
spellcheck="false"
|
||||
value=""
|
||||
/>
|
||||
<i
|
||||
class="Icon material focusable small"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="search"
|
||||
>
|
||||
search
|
||||
</span>
|
||||
</i>
|
||||
</label>
|
||||
<div
|
||||
class="input-info flex gaps"
|
||||
/>
|
||||
</div>
|
||||
<i
|
||||
class="Icon material interactive disabled focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_up"
|
||||
>
|
||||
keyboard_arrow_up
|
||||
</span>
|
||||
</i>
|
||||
<div>
|
||||
Previous
|
||||
</div>
|
||||
<i
|
||||
class="Icon material interactive disabled focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
<div>
|
||||
Next
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="LogList flex"
|
||||
>
|
||||
<div
|
||||
class="VirtualList box grow"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
class="list"
|
||||
style="position: relative; height: 420000px; width: 100%; overflow: auto; will-change: transform; direction: ltr;"
|
||||
>
|
||||
<div
|
||||
style="height: 18px; width: 100%;"
|
||||
>
|
||||
<div
|
||||
class="LogRow"
|
||||
style="position: absolute; left: 0px; top: 0px; height: 18px; width: 100%;"
|
||||
>
|
||||
<span>
|
||||
some-logs
|
||||
</span>
|
||||
<br />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="controls"
|
||||
data-testid="log-controls"
|
||||
>
|
||||
<div>
|
||||
<span>
|
||||
Logs from
|
||||
|
||||
<b>
|
||||
Invalid Date
|
||||
</b>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="flex gaps align-center"
|
||||
>
|
||||
<label
|
||||
class="Checkbox flex align-center show-timestamps"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
/>
|
||||
<i
|
||||
class="box flex align-center"
|
||||
/>
|
||||
<span
|
||||
class="label"
|
||||
>
|
||||
Show timestamps
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
class="Checkbox flex align-center show-previous checked"
|
||||
>
|
||||
<input
|
||||
checked=""
|
||||
type="checkbox"
|
||||
/>
|
||||
<i
|
||||
class="box flex align-center"
|
||||
/>
|
||||
<span
|
||||
class="label"
|
||||
>
|
||||
Show previous terminated container
|
||||
</span>
|
||||
</label>
|
||||
<div>
|
||||
<div
|
||||
id="download-logs-dropdown"
|
||||
>
|
||||
<button
|
||||
class="dropdown"
|
||||
data-testid="download-logs-dropdown"
|
||||
>
|
||||
Download
|
||||
<i
|
||||
class="Icon material focusable smallest"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="arrow_drop_down"
|
||||
>
|
||||
arrow_drop_down
|
||||
</span>
|
||||
</i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`download logs options in logs dock tab opening pod logs when logs not available renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -743,46 +1593,17 @@ exports[`download logs options in pod logs dock tab when opening pod logs render
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="LogList flex"
|
||||
class="LogList flex box grow align-center justify-center"
|
||||
>
|
||||
<div
|
||||
class="VirtualList box grow"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
class="list"
|
||||
style="position: relative; height: 420000px; width: 100%; overflow: auto; will-change: transform; direction: ltr;"
|
||||
>
|
||||
<div
|
||||
style="height: 18px; width: 100%;"
|
||||
>
|
||||
<div
|
||||
class="LogRow"
|
||||
style="position: absolute; left: 0px; top: 0px; height: 18px; width: 100%;"
|
||||
>
|
||||
<span>
|
||||
some-logs
|
||||
</span>
|
||||
<br />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
There are no logs available for container
|
||||
|
||||
docker-exporter
|
||||
</div>
|
||||
<div
|
||||
class="controls"
|
||||
data-testid="log-controls"
|
||||
>
|
||||
<div>
|
||||
<span>
|
||||
Logs from
|
||||
|
||||
<b>
|
||||
Invalid Date
|
||||
</b>
|
||||
</span>
|
||||
</div>
|
||||
<div />
|
||||
<div
|
||||
class="flex gaps align-center"
|
||||
>
|
||||
@ -824,6 +1645,7 @@ exports[`download logs options in pod logs dock tab when opening pod logs render
|
||||
<button
|
||||
class="dropdown"
|
||||
data-testid="download-logs-dropdown"
|
||||
disabled=""
|
||||
>
|
||||
Download
|
||||
<i
|
||||
|
||||
@ -25,14 +25,26 @@ import reloadLogsInjectable from "../../renderer/components/dock/logs/reload-log
|
||||
import setLogTabDataInjectable from "../../renderer/components/dock/logs/set-log-tab-data.injectable";
|
||||
import stopLoadingLogsInjectable from "../../renderer/components/dock/logs/stop-loading-logs.injectable";
|
||||
import { dockerPod } from "../../renderer/components/dock/logs/__test__/pod.mock";
|
||||
import showErrorNotificationInjectable from "../../renderer/components/notifications/show-error-notification.injectable";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import type { Container } from "../../common/k8s-api/endpoints";
|
||||
|
||||
describe("download logs options in pod logs dock tab", () => {
|
||||
describe("download logs options in logs dock tab", () => {
|
||||
let windowDi: DiContainer;
|
||||
let rendered: RenderResult;
|
||||
let builder: ApplicationBuilder;
|
||||
let openSaveFileDialogMock: jest.MockedFunction<() => void>;
|
||||
let callForLogsMock: jest.MockedFunction<CallForLogs>;
|
||||
let getLogsMock: jest.Mock;
|
||||
let getSplittedLogsMock: jest.Mock;
|
||||
let showErrorNotificationMock: jest.Mock;
|
||||
const logs = new Map([["timestamp", "some-logs"]]);
|
||||
const pod = dockerPod;
|
||||
|
||||
const container: Container = {
|
||||
name: "docker-exporter",
|
||||
image: "docker.io/prom/node-exporter:v1.0.0-rc.0",
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
const selectedPod = dockerPod;
|
||||
@ -42,14 +54,16 @@ describe("download logs options in pod logs dock tab", () => {
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
callForLogsMock = jest.fn();
|
||||
getLogsMock = jest.fn();
|
||||
getSplittedLogsMock = jest.fn();
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(callForLogsInjectable, () => callForLogsMock);
|
||||
|
||||
// Overriding internals of logsViewModelInjectable
|
||||
windowDi.override(getLogsInjectable, () => () => ["some-logs"]);
|
||||
windowDi.override(getLogsWithoutTimestampsInjectable, () => () => ["some-logs"]);
|
||||
windowDi.override(getTimestampSplitLogsInjectable, () => () => [...logs]);
|
||||
windowDi.override(getLogsInjectable, () => getLogsMock);
|
||||
windowDi.override(getLogsWithoutTimestampsInjectable, () => getLogsMock);
|
||||
windowDi.override(getTimestampSplitLogsInjectable, () => getSplittedLogsMock);
|
||||
windowDi.override(reloadLogsInjectable, () => jest.fn());
|
||||
windowDi.override(getLogTabDataInjectable, () => () => ({
|
||||
selectedPodId: selectedPod.getId(),
|
||||
@ -75,58 +89,76 @@ describe("download logs options in pod logs dock tab", () => {
|
||||
|
||||
openSaveFileDialogMock = jest.fn();
|
||||
windowDi.override(openSaveFileDialogInjectable, () => openSaveFileDialogMock);
|
||||
|
||||
showErrorNotificationMock = jest.fn();
|
||||
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when opening pod logs", () => {
|
||||
describe("opening pod logs", () => {
|
||||
beforeEach(async () => {
|
||||
rendered = await builder.render();
|
||||
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
const pod = dockerPod;
|
||||
const createLogsTab = windowDi.inject(createPodLogsTabInjectable);
|
||||
const container: Container = {
|
||||
name: "docker-exporter",
|
||||
image: "docker.io/prom/node-exporter:v1.0.0-rc.0",
|
||||
imagePullPolicy: "Always",
|
||||
};
|
||||
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const dockStore = windowDi.inject(dockStoreInjectable);
|
||||
|
||||
dockStore.closeTab("terminal");
|
||||
});
|
||||
|
||||
createLogsTab({
|
||||
selectedPod: pod,
|
||||
selectedContainer: container,
|
||||
describe("when logs not available", () => {
|
||||
beforeEach(async () => {
|
||||
const createLogsTab = windowDi.inject(createPodLogsTabInjectable);
|
||||
|
||||
getLogsMock.mockReturnValue([]);
|
||||
getSplittedLogsMock.mockReturnValue([]);
|
||||
|
||||
createLogsTab({
|
||||
selectedPod: pod,
|
||||
selectedContainer: container,
|
||||
});
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("dropdown being disabled", () => {
|
||||
const downloadButton = rendered.getByTestId("download-logs-dropdown");
|
||||
|
||||
expect(downloadButton).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("contains download dropdown button", () => {
|
||||
expect(rendered.getByTestId("download-logs-dropdown")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe("when clicking on button", () => {
|
||||
beforeEach(() => {
|
||||
const button = rendered.getByTestId("download-logs-dropdown");
|
||||
|
||||
act(() => button.click());
|
||||
describe("when logs available", () => {
|
||||
beforeEach(async () => {
|
||||
const createLogsTab = windowDi.inject(createPodLogsTabInjectable);
|
||||
|
||||
getLogsMock.mockReturnValue(["some-logs"]);
|
||||
getSplittedLogsMock.mockReturnValue([...logs]);
|
||||
|
||||
createLogsTab({
|
||||
selectedPod: pod,
|
||||
selectedContainer: container,
|
||||
});
|
||||
});
|
||||
|
||||
it("shows download visible logs menu item", () => {
|
||||
expect(rendered.getByTestId("download-visible-logs")).toBeInTheDocument();
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows download all logs menu item", () => {
|
||||
expect(rendered.getByTestId("download-all-logs")).toBeInTheDocument();
|
||||
it("contains download dropdown button", () => {
|
||||
expect(rendered.getByTestId("download-logs-dropdown")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe("when call for logs resolves with logs", () => {
|
||||
it("dropdown is enabled", () => {
|
||||
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
|
||||
});
|
||||
|
||||
describe("when clicking on dropdown", () => {
|
||||
beforeEach(() => {
|
||||
callForLogsMock.mockResolvedValue("all-logs");
|
||||
const button = rendered.getByTestId("download-logs-dropdown");
|
||||
|
||||
act(() => button.click());
|
||||
});
|
||||
|
||||
describe("when selected 'download visible logs'", () => {
|
||||
@ -141,122 +173,106 @@ describe("download logs options in pod logs dock tab", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("when selected 'download all logs'", () => {
|
||||
describe("when call for all logs resolves with logs", () => {
|
||||
beforeEach(async () => {
|
||||
await act(async () => {
|
||||
const button = rendered.getByTestId("download-all-logs");
|
||||
callForLogsMock.mockResolvedValue("all-logs");
|
||||
});
|
||||
|
||||
button.click();
|
||||
describe("when selected 'download all logs'", () => {
|
||||
beforeEach(async () => {
|
||||
await act(async () => {
|
||||
const button = rendered.getByTestId("download-all-logs");
|
||||
|
||||
button.click();
|
||||
});
|
||||
});
|
||||
|
||||
it("logs have been called with query", () => {
|
||||
expect(callForLogsMock).toHaveBeenCalledWith(
|
||||
{ name: "dockerExporter", namespace: "default" },
|
||||
{ "previous": true, "timestamps": false },
|
||||
);
|
||||
});
|
||||
|
||||
it("shows save dialog with proper attributes", async () => {
|
||||
expect(openSaveFileDialogMock).toHaveBeenCalledWith("dockerExporter.log", "all-logs", "text/plain");
|
||||
});
|
||||
|
||||
it("doesn't block download dropdown for interaction after click", async () => {
|
||||
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
|
||||
});
|
||||
});
|
||||
|
||||
it("logs have been called with query", () => {
|
||||
expect(callForLogsMock).toHaveBeenCalledWith(
|
||||
{ name: "dockerExporter", namespace: "default" },
|
||||
{ "previous": true, "timestamps": false },
|
||||
);
|
||||
});
|
||||
|
||||
it("shows save dialog with proper attributes", async () => {
|
||||
expect(openSaveFileDialogMock).toHaveBeenCalledWith("dockerExporter.log", "all-logs", "text/plain");
|
||||
});
|
||||
|
||||
it("doesn't block download dropdown for interaction after click", async () => {
|
||||
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
|
||||
});
|
||||
});
|
||||
|
||||
describe("blocking user interaction after menu item click", () => {
|
||||
it("block download dropdown for interaction when selected 'download all logs'", async () => {
|
||||
const downloadMenuItem = rendered.getByTestId("download-all-logs");
|
||||
|
||||
act(() => downloadMenuItem.click());
|
||||
|
||||
await waitFor(() => {
|
||||
expect(rendered.getByTestId("download-logs-dropdown")).toHaveAttribute("disabled");
|
||||
describe("blocking user interaction after menu item click", () => {
|
||||
it("block download dropdown for interaction when selected 'download all logs'", async () => {
|
||||
const downloadMenuItem = rendered.getByTestId("download-all-logs");
|
||||
|
||||
act(() => downloadMenuItem.click());
|
||||
|
||||
await waitFor(() => {
|
||||
expect(rendered.getByTestId("download-logs-dropdown")).toHaveAttribute("disabled");
|
||||
});
|
||||
});
|
||||
|
||||
it("doesn't block dropdown for interaction when selected 'download visible logs'", () => {
|
||||
const downloadMenuItem = rendered.getByTestId("download-visible-logs");
|
||||
|
||||
act(() => downloadMenuItem.click());
|
||||
|
||||
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("doesn't block dropdown for interaction when selected 'download visible logs'", () => {
|
||||
const downloadMenuItem = rendered.getByTestId("download-visible-logs");
|
||||
describe("when call for logs resolves with no logs", () => {
|
||||
beforeEach(async () => {
|
||||
callForLogsMock.mockResolvedValue("");
|
||||
});
|
||||
|
||||
act(() => downloadMenuItem.click());
|
||||
describe("when selected 'download all logs'", () => {
|
||||
beforeEach(async () => {
|
||||
await act(async () => {
|
||||
const button = rendered.getByTestId("download-all-logs");
|
||||
|
||||
button.click();
|
||||
});
|
||||
});
|
||||
|
||||
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
|
||||
it("doesn't show save dialog", () => {
|
||||
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("shows error notification", () => {
|
||||
expect(showErrorNotificationMock).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when call for logs resolves with no logs", () => {
|
||||
beforeEach(() => {
|
||||
callForLogsMock.mockResolvedValue("");
|
||||
});
|
||||
|
||||
describe("when selected 'download visible logs'", () => {
|
||||
describe("when call for logs rejects", () => {
|
||||
beforeEach(() => {
|
||||
const button = rendered.getByTestId("download-visible-logs");
|
||||
|
||||
button.click();
|
||||
callForLogsMock.mockRejectedValue("error");
|
||||
});
|
||||
|
||||
it("shows save dialog with proper attributes", () => {
|
||||
expect(openSaveFileDialogMock).toHaveBeenCalledWith("dockerExporter.log", "some-logs", "text/plain");
|
||||
});
|
||||
});
|
||||
|
||||
describe("when selected 'download all logs'", () => {
|
||||
beforeEach(async () => {
|
||||
await act(async () => {
|
||||
const button = rendered.getByTestId("download-all-logs");
|
||||
|
||||
button.click();
|
||||
|
||||
describe("when selected 'download all logs'", () => {
|
||||
beforeEach(async () => {
|
||||
await act(async () => {
|
||||
const button = rendered.getByTestId("download-all-logs");
|
||||
|
||||
button.click();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("doesn't show save dialog", async () => {
|
||||
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when call for logs rejects", () => {
|
||||
beforeEach(() => {
|
||||
callForLogsMock.mockRejectedValue("error");
|
||||
});
|
||||
|
||||
describe("when selected 'download visible logs'", () => {
|
||||
beforeEach(async () => {
|
||||
await act(async () => {
|
||||
const button = rendered.getByTestId("download-visible-logs");
|
||||
|
||||
button.click();
|
||||
|
||||
it("logs have been called", () => {
|
||||
expect(callForLogsMock).toHaveBeenCalledWith(
|
||||
{ name: "dockerExporter", namespace: "default" },
|
||||
{ "previous": true, "timestamps": false },
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("shows save dialog with proper attributes", () => {
|
||||
expect(openSaveFileDialogMock).toHaveBeenCalledWith("dockerExporter.log", "some-logs", "text/plain");
|
||||
});
|
||||
});
|
||||
|
||||
describe("when selected 'download all logs'", () => {
|
||||
beforeEach(async () => {
|
||||
await act(async () => {
|
||||
const button = rendered.getByTestId("download-all-logs");
|
||||
|
||||
button.click();
|
||||
|
||||
it("doesn't show save dialog", async () => {
|
||||
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it("logs have been called", () => {
|
||||
expect(callForLogsMock).toHaveBeenCalledWith(
|
||||
{ name: "dockerExporter", namespace: "default" },
|
||||
{ "previous": true, "timestamps": false },
|
||||
);
|
||||
});
|
||||
|
||||
it("doesn't show save dialog", async () => {
|
||||
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -63,6 +63,7 @@ export const LogControls = observer(({ model }: LogControlsProps) => {
|
||||
/>
|
||||
|
||||
<DownloadLogsDropdown
|
||||
disabled={logs.length === 0}
|
||||
downloadVisibleLogs={model.downloadLogs}
|
||||
downloadAllLogs={model.downloadAllLogs}
|
||||
/>
|
||||
|
||||
@ -7,6 +7,7 @@ import type { PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
||||
import type { ResourceDescriptor } from "../../../../common/k8s-api/kube-api";
|
||||
import loggerInjectable from "../../../../common/logger.injectable";
|
||||
import openSaveFileDialogInjectable from "../../../utils/save-file.injectable";
|
||||
import showErrorNotificationInjectable from "../../notifications/show-error-notification.injectable";
|
||||
import callForLogsInjectable from "./call-for-logs.injectable";
|
||||
|
||||
const downloadAllLogsInjectable = getInjectable({
|
||||
@ -16,7 +17,8 @@ const downloadAllLogsInjectable = getInjectable({
|
||||
const callForLogs = di.inject(callForLogsInjectable);
|
||||
const openSaveFileDialog = di.inject(openSaveFileDialogInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
|
||||
const showErrorNotification = di.inject(showErrorNotificationInjectable);
|
||||
|
||||
return async (params: ResourceDescriptor, query: PodLogsQuery) => {
|
||||
const logs = await callForLogs(params, query).catch(error => {
|
||||
logger.error("Can't download logs: ", error);
|
||||
@ -24,6 +26,8 @@ const downloadAllLogsInjectable = getInjectable({
|
||||
|
||||
if (logs) {
|
||||
openSaveFileDialog(`${params.name}.log`, logs, "text/plain");
|
||||
} else {
|
||||
showErrorNotification("No logs to download");
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
@ -13,9 +13,10 @@ import { Dropdown } from "../../dropdown/dropdown";
|
||||
interface DownloadLogsDropdownProps {
|
||||
downloadVisibleLogs: () => void;
|
||||
downloadAllLogs: () => Promise<void> | undefined;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function DownloadLogsDropdown({ downloadAllLogs, downloadVisibleLogs }: DownloadLogsDropdownProps) {
|
||||
export function DownloadLogsDropdown({ downloadAllLogs, downloadVisibleLogs, disabled }: DownloadLogsDropdownProps) {
|
||||
const [waiting, setWaiting] = useState(false);
|
||||
|
||||
const downloadAll = async () => {
|
||||
@ -35,7 +36,7 @@ export function DownloadLogsDropdown({ downloadAllLogs, downloadVisibleLogs }: D
|
||||
<button
|
||||
data-testid="download-logs-dropdown"
|
||||
className={styles.dropdown}
|
||||
disabled={waiting}
|
||||
disabled={waiting || disabled}
|
||||
>
|
||||
Download
|
||||
<Icon material="arrow_drop_down" smallest/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user