Skip to content

Commit

Permalink
Backport #589 (#592) (#594)
Browse files Browse the repository at this point in the history
* Reduce code conflicts (#589)

* Item count in Content panel

* Constants

* Datastream security message

* Unify the refresh

* Update test snapshot

* Update cypress test



* Update test snap



* Fix cypress workflow

Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
  • Loading branch information
bowenlan-amzn authored Jan 31, 2023
1 parent f85a98d commit 46c848d
Show file tree
Hide file tree
Showing 38 changed files with 302 additions and 621 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches:
- "*"
env:
OPENSEARCH_DASHBOARDS_VERSION: '2.4'
OPENSEARCH_VERSION: '2.4.1-SNAPSHOT'
OPENSEARCH_DASHBOARDS_VERSION: '2.4.1'
OPENSEARCH_VERSION: '2.4.1.0'
jobs:
tests:
name: Run Cypress E2E tests
Expand All @@ -29,11 +29,11 @@ jobs:
with:
path: index-management
repository: opensearch-project/index-management
ref: 'main'
ref: ${{ env.OPENSEARCH_VERSION }}
- name: Run opensearch with plugin
run: |
cd index-management
./gradlew run -Dopensearch.version=${{ env.OPENSEARCH_VERSION }} &
./gradlew run &
sleep 300
# timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done'
- name: Checkout Index Management Dashboards plugin
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/managed_indices_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe("Managed indices", () => {
cy.contains("Changed policy on 1 indices");

// Click back to Managed Indices page by clicking "Managed indices" breadcrumb
cy.contains("Managed indices").click();
cy.contains("Policy managed indices").click();

// Speed up execution of managed index
cy.updateManagedIndexConfigStartTime(SAMPLE_INDEX);
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/policies_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("Policies", () => {
cy.contains("Continue").click({ force: true });

// Wait for input to load and then type in the policy ID
cy.get(`input[placeholder="hot_cold_workflow"]`).type(POLICY_ID, { force: true });
cy.get(`input[placeholder="example_policy"]`).type(POLICY_ID, { force: true });

// Wait for default policy JSON to load
cy.contains("A simple default policy");
Expand Down Expand Up @@ -188,5 +188,5 @@ describe("Policies", () => {
cy.get(`[data-test-subj="viewButton"]`).click({ force: true });
cy.contains(`View JSON of ${POLICY_ID}`);
});
})
});
});
7 changes: 6 additions & 1 deletion public/components/ContentPanel/ContentPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface ContentPanelProps {
horizontalRuleClassName?: string;
actions?: React.ReactNode | React.ReactNode[];
children: React.ReactNode | React.ReactNode[];
itemCount?: number;
}

const renderSubTitleText = (subTitleText: string | JSX.Element): JSX.Element | null => {
Expand All @@ -38,13 +39,17 @@ const ContentPanel: React.SFC<ContentPanelProps> = ({
horizontalRuleClassName = "",
actions,
children,
itemCount = 0,
}) => (
<EuiPanel style={{ paddingLeft: "0px", paddingRight: "0px", ...panelStyles }}>
<EuiFlexGroup style={{ padding: "0px 10px" }} justifyContent="spaceBetween" alignItems="flexStart">
<EuiFlexItem>
{typeof title === "string" ? (
<EuiTitle size={titleSize}>
<h3>{title}</h3>
<h3>
{title}
<span className="panel-header-count"> {itemCount > 0 ? `(${itemCount})` : null} </span>
</h3>
</EuiTitle>
) : (
title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<ContentPanel /> spec renders the component 1`] = `
class="euiTitle euiTitle--large"
>
Testing
<span
class="panel-header-count"
>
</span>
</h3>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<ChangeManagedIndices /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Choose managed indices
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<NewPolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Choose new policy
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ exports[`<ChangePolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Choose managed indices
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down Expand Up @@ -221,6 +227,12 @@ exports[`<ChangePolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Choose new policy
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ConfigurePolicy = ({ isEdit, policyId, policyIdError, onChange }: Configur
isInvalid={!!policyIdError}
error={policyIdError}
>
<EuiFieldText isInvalid={!!policyIdError} placeholder="hot_cold_workflow" readOnly={isEdit} value={policyId} onChange={onChange} />
<EuiFieldText isInvalid={!!policyIdError} placeholder="example_policy" readOnly={isEdit} value={policyId} onChange={onChange} />
</EuiFormRow>
</div>
</ContentPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<ConfigurePolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Name policy
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down Expand Up @@ -66,7 +72,7 @@ exports[`<ConfigurePolicy /> spec renders the component 1`] = `
aria-describedby="some_html_id-help-0"
class="euiFieldText"
id="some_html_id"
placeholder="hot_cold_workflow"
placeholder="example_policy"
type="text"
value="some_id"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<DefinePolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Define policy
<span
class="panel-header-count"
>
</span>
</h3>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("<CreatePolicy /> spec", () => {

await waitFor(() => getByDisplayValue("some_id"));

expect(getByPlaceholderText("hot_cold_workflow")).toHaveAttribute("readonly");
expect(getByPlaceholderText("example_policy")).toHaveAttribute("readonly");
});

it("shows error for policyId input when clicking create", async () => {
Expand All @@ -127,9 +127,9 @@ describe("<CreatePolicy /> spec", () => {

expect(queryByText("Required")).not.toBeNull();

fireEvent.focus(getByPlaceholderText("hot_cold_workflow"));
userEvent.type(getByPlaceholderText("hot_cold_workflow"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("hot_cold_workflow"));
fireEvent.focus(getByPlaceholderText("example_policy"));
userEvent.type(getByPlaceholderText("example_policy"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("example_policy"));

expect(queryByText("Required")).toBeNull();
});
Expand All @@ -138,9 +138,9 @@ describe("<CreatePolicy /> spec", () => {
browserServicesMock.policyService.putPolicy = jest.fn().mockResolvedValue({ ok: true, response: { _id: "some_policy_id" } });
const { getByText, getByTestId, getByPlaceholderText } = renderCreatePolicyWithRouter();

fireEvent.focus(getByPlaceholderText("hot_cold_workflow"));
userEvent.type(getByPlaceholderText("hot_cold_workflow"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("hot_cold_workflow"));
fireEvent.focus(getByPlaceholderText("example_policy"));
userEvent.type(getByPlaceholderText("example_policy"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("example_policy"));

userEvent.click(getByTestId("createPolicyCreateButton"));

Expand All @@ -152,9 +152,9 @@ describe("<CreatePolicy /> spec", () => {
browserServicesMock.policyService.putPolicy = jest.fn().mockResolvedValue({ ok: false, error: "bad policy" });
const { getByText, getByTestId, getByPlaceholderText } = renderCreatePolicyWithRouter();

fireEvent.focus(getByPlaceholderText("hot_cold_workflow"));
userEvent.type(getByPlaceholderText("hot_cold_workflow"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("hot_cold_workflow"));
fireEvent.focus(getByPlaceholderText("example_policy"));
userEvent.type(getByPlaceholderText("example_policy"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("example_policy"));

userEvent.click(getByTestId("createPolicyCreateButton"));

Expand All @@ -165,9 +165,9 @@ describe("<CreatePolicy /> spec", () => {
browserServicesMock.policyService.putPolicy = jest.fn().mockRejectedValue(new Error("this is an error"));
const { getByText, getByTestId, getByPlaceholderText } = renderCreatePolicyWithRouter();

fireEvent.focus(getByPlaceholderText("hot_cold_workflow"));
userEvent.type(getByPlaceholderText("hot_cold_workflow"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("hot_cold_workflow"));
fireEvent.focus(getByPlaceholderText("example_policy"));
userEvent.type(getByPlaceholderText("example_policy"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("example_policy"));

userEvent.click(getByTestId("createPolicyCreateButton"));

Expand Down
Loading

0 comments on commit 46c848d

Please sign in to comment.