Skip to content

Commit

Permalink
Merge 2.5 changes to 2.x (#537) (#557)
Browse files Browse the repository at this point in the history
* Feature/common 2.5 (#519)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Feature/index management 2.5 (#520)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* fix: detail of data stream

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Temp/template management 2.5 (#523)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: fix template error

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Temp/alias management 2.5 (#524)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Feature/unittest fix 2.5 (#525)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Merge/index operation reindex (#526)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* enable fullwidth for JSON editor (#479)

* enable fullwidth for JSON editor

Signed-off-by: Hailong Cui <[email protected]>

* update width of import settings & mappings

Signed-off-by: Hailong Cui <[email protected]>

* wording change

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: Hailong Cui <[email protected]>

* advanced settings

Signed-off-by: Hailong Cui <[email protected]>

* fix integration test

Signed-off-by: Hailong Cui <[email protected]>

* wording change

Signed-off-by: Hailong Cui <[email protected]>

* filter system index and alias from destination

Signed-off-by: Hailong Cui <[email protected]>

* fix code merge issue

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: suzhou <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Co-authored-by: suzhou <[email protected]>

* Add shrink index page (#530)

* Add shrink index page

Signed-off-by: Binlong Gao <[email protected]>

* Fix bug for shrink & close operation

Signed-off-by: Binlong Gao <[email protected]>

Signed-off-by: Binlong Gao <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update wording

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: change flyout to modal

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: enable global template warning

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* Merge/index operation (#534)

* Feature/common 2.5 (#519)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Feature/index management 2.5 (#520)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* fix: detail of data stream

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Temp/template management 2.5 (#523)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: fix template error

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Temp/alias management 2.5 (#524)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Feature/unittest fix 2.5 (#525)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Merge/index operation reindex (#526)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* enable fullwidth for JSON editor (#479)

* enable fullwidth for JSON editor

Signed-off-by: Hailong Cui <[email protected]>

* update width of import settings & mappings

Signed-off-by: Hailong Cui <[email protected]>

* wording change

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: Hailong Cui <[email protected]>

* advanced settings

Signed-off-by: Hailong Cui <[email protected]>

* fix integration test

Signed-off-by: Hailong Cui <[email protected]>

* wording change

Signed-off-by: Hailong Cui <[email protected]>

* filter system index and alias from destination

Signed-off-by: Hailong Cui <[email protected]>

* fix code merge issue

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: suzhou <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Co-authored-by: suzhou <[email protected]>

* Add split index operation

Signed-off-by: Xuesong Luo <[email protected]>

* Add split index operation

Signed-off-by: Xuesong Luo <[email protected]>

Signed-off-by: suzhou <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Xuesong Luo <[email protected]>
Co-authored-by: suzhou <[email protected]>
Co-authored-by: Hailong-amzn <[email protected]>

* Merge/index operation (#535)

* Feature/common 2.5 (#519)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Feature/index management 2.5 (#520)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* fix: detail of data stream

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Temp/template management 2.5 (#523)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: fix template error

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Temp/alias management 2.5 (#524)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Feature/unittest fix 2.5 (#525)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* Merge/index operation reindex (#526)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

Signed-off-by: suzhou <[email protected]>

* enable fullwidth for JSON editor (#479)

* enable fullwidth for JSON editor

Signed-off-by: Hailong Cui <[email protected]>

* update width of import settings & mappings

Signed-off-by: Hailong Cui <[email protected]>

* wording change

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: Hailong Cui <[email protected]>

* advanced settings

Signed-off-by: Hailong Cui <[email protected]>

* fix integration test

Signed-off-by: Hailong Cui <[email protected]>

* wording change

Signed-off-by: Hailong Cui <[email protected]>

* filter system index and alias from destination

Signed-off-by: Hailong Cui <[email protected]>

* fix code merge issue

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: suzhou <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Co-authored-by: suzhou <[email protected]>

* Add split index operation

Signed-off-by: Xuesong Luo <[email protected]>

* Add split index operation

Signed-off-by: Xuesong Luo <[email protected]>

* Return if exception is thrown when calling backend API

Signed-off-by: Xuesong Luo <[email protected]>

* Remove replica props that's not taking effect.

Signed-off-by: Xuesong Luo <[email protected]>

Signed-off-by: suzhou <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Xuesong Luo <[email protected]>
Co-authored-by: suzhou <[email protected]>
Co-authored-by: Hailong-amzn <[email protected]>

* feat: rearrange main.tsx

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: add difference

Signed-off-by: suzhou <[email protected]>

* feat: add timeout

Signed-off-by: suzhou <[email protected]>

* feat: add timeout

Signed-off-by: suzhou <[email protected]>

* feat: add timeout to 60000 for macos has the timeout issue

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: add unsaved check logic

Signed-off-by: suzhou <[email protected]>

* feat: change timeout to 24h

Signed-off-by: suzhou <[email protected]>

* feat: remove warning

Signed-off-by: suzhou <[email protected]>

* feat: enable parse message for mapping_parsing_exception

Signed-off-by: suzhou <[email protected]>

* feat: update wording

Signed-off-by: suzhou <[email protected]>

* feat: rewording

Signed-off-by: suzhou <[email protected]>

* feat: update snapshot

Signed-off-by: suzhou <[email protected]>

* feat: optimize with new type of parsing error

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update alias empty content

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update alias modal header style

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: update e2e test

Signed-off-by: suzhou <[email protected]>

* Minor wording change after review (#544)

Signed-off-by: Xuesong Luo <[email protected]>

Signed-off-by: Xuesong Luo <[email protected]>

* feat: use correct version of doc

Signed-off-by: suzhou <[email protected]>

* feat: update typo

Signed-off-by: suzhou <[email protected]>

* feat: update snapshot

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* feat: add destType for reindex notification toast

Signed-off-by: suzhou <[email protected]>

* support reindex unique documents (#546)

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: Hailong Cui <[email protected]>

* feat: update patterns for template name

Signed-off-by: suzhou <[email protected]>

* feat: update validation

Signed-off-by: suzhou <[email protected]>

* feat: add validation for alias select

Signed-off-by: suzhou <[email protected]>

* feat: update test

Signed-off-by: suzhou <[email protected]>

* feat: add force in E2E test

Signed-off-by: suzhou <[email protected]>

* toast link support data stream and alias (#551)

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: Hailong Cui <[email protected]>

* fix: index detail for data streams index

Signed-off-by: suzhou <[email protected]>

* feat: add error wrapper

Signed-off-by: suzhou <[email protected]>

* feat: change to multiple select

Signed-off-by: suzhou <[email protected]>

* feat: expand width

Signed-off-by: suzhou <[email protected]>

* feat: update

Signed-off-by: suzhou <[email protected]>

* Change some wording in shrink index page (#553)

Signed-off-by: gaobinlong <[email protected]>

Signed-off-by: gaobinlong <[email protected]>

* reindex page wording change (#554)

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: Hailong Cui <[email protected]>

* feat: add comment on Better* component

Signed-off-by: suzhou <[email protected]>

* refractor: job handler

Signed-off-by: suzhou <[email protected]>

* feat: remove useless functions

Signed-off-by: suzhou <[email protected]>

* refractor: move functions to helpers.ts

Signed-off-by: suzhou <[email protected]>

* refractor: move types to interfaces.ts

Signed-off-by: suzhou <[email protected]>

* feat: remove duplicate div

Signed-off-by: suzhou <[email protected]>

* feat: use fragment

Signed-off-by: suzhou <[email protected]>

* feat: use cannot

Signed-off-by: suzhou <[email protected]>

* refractor: split TemplateDetail into multiple files

Signed-off-by: suzhou <[email protected]>

* feat: update timeout

Signed-off-by: suzhou <[email protected]>

* feat: move some constant lines to constant.tsx

Signed-off-by: suzhou <[email protected]>

* Remove unused TODO (#555)

Signed-off-by: Hailong Cui <[email protected]>

Signed-off-by: Hailong Cui <[email protected]>

* fix: catch error and do not jump in split page

Signed-off-by: suzhou <[email protected]>

* Add a space before the learn more link in shrink index page (#556)

Signed-off-by: gaobinlong <[email protected]>

Signed-off-by: suzhou <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Binlong Gao <[email protected]>
Signed-off-by: Xuesong Luo <[email protected]>
Signed-off-by: gaobinlong <[email protected]>
Co-authored-by: Hailong-amzn <[email protected]>
Co-authored-by: Binlong Gao <[email protected]>
Co-authored-by: xluo-aws <[email protected]>
(cherry picked from commit f860818)

Co-authored-by: suzhou <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and SuZhou-Joe authored Jan 10, 2023
1 parent d3d8e6f commit 3d51152
Show file tree
Hide file tree
Showing 302 changed files with 29,909 additions and 476 deletions.
119 changes: 119 additions & 0 deletions cypress/integration/aliases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { PLUGIN_NAME } from "../support/constants";

const SAMPLE_INDEX_PREFIX = "index-for-alias-test";
const SAMPLE_ALIAS_PREFIX = "alias-for-test";
const CREATE_ALIAS = "create-alias";
const EDIT_INDEX = "index-edit-index-for-alias-test";

describe("Aliases", () => {
before(() => {
// Set welcome screen tracking to false
localStorage.setItem("home:welcome:show", "false");
cy.deleteAllIndices();
for (let i = 0; i < 11; i++) {
cy.createIndex(`${SAMPLE_INDEX_PREFIX}-${i}`, null);
}
cy.createIndex(EDIT_INDEX, null);
for (let i = 0; i < 30; i++) {
cy.addAlias(`${SAMPLE_ALIAS_PREFIX}-${i}`, `${SAMPLE_INDEX_PREFIX}-${i % 11}`);
}
cy.removeAlias(`${SAMPLE_ALIAS_PREFIX}-0`);
cy.addAlias(`${SAMPLE_ALIAS_PREFIX}-0`, `${SAMPLE_INDEX_PREFIX}-*`);
});

beforeEach(() => {
// Visit ISM OSD
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/aliases`);

// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
cy.contains("Rows per page", { timeout: 60000 });
});

describe("can be searched / sorted / paginated", () => {
it("successfully", () => {
cy.get('[data-test-subj="pagination-button-1"]').should("exist");
cy.get('[placeholder="Search..."]').type("alias-for-test-0{enter}");
cy.contains("alias-for-test-0");
cy.get(".euiTableRow").should("have.length", 1);
cy.get('[data-test-subj="comboBoxSearchInput"]').type("closed{enter}");

cy.contains("There are no aliases matching your applied filters. Reset your filters to view your aliases.");
});
});

describe("shows more modal", () => {
it("successfully", () => {
cy.get('[placeholder="Search..."]').type("alias-for-test-0{enter}");
cy.contains("alias-for-test-0");
cy.get(".euiTableRow").should("have.length", 1);
cy.get('.euiTableRowCell [data-test-subj="8 more"]')
.click()
.get('[data-test-subj="indices-table"] .euiTableRow')
.should("have.length", 10);
});
});

describe("can create a alias with wildcard and specific name", () => {
it("successfully", () => {
cy.get('[data-test-subj="Create AliasButton"]').click();
cy.get('[data-test-subj="form-name-alias"]').type(CREATE_ALIAS);
cy.get('[data-test-subj="form-name-indexArray"] [data-test-subj="comboBoxSearchInput"]').type(
`${EDIT_INDEX}{enter}${SAMPLE_INDEX_PREFIX}-*{enter}`
);
cy.get(".euiModalFooter .euiButton--fill").click({ force: true }).get('[data-test-subj="9 more"]').should("exist");
});
});

describe("can edit / delete a alias", () => {
it("successfully", () => {
cy.get('[placeholder="Search..."]').type(`${SAMPLE_ALIAS_PREFIX}-0{enter}`);
cy.contains(`${SAMPLE_ALIAS_PREFIX}-0`);
cy.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="editAction"]')
.should("be.disabled")
.get(`#_selection_column_${SAMPLE_ALIAS_PREFIX}-0-checkbox`)
.click()
.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="editAction"]')
.click()
.get('[data-test-subj="form-name-indexArray"] [data-test-subj="comboBoxInput"]')
.click()
.type(`${EDIT_INDEX}{enter}`)
.get(`[title="${SAMPLE_INDEX_PREFIX}-0"] button`)
.click()
.get(`[title="${SAMPLE_INDEX_PREFIX}-1"] button`)
.click()
.get(".euiModalFooter .euiButton--fill")
.click({ force: true })
.end();

cy.get('[data-test-subj="7 more"]').should("exist");

cy.get('[data-test-subj="moreAction"] button').click().get('[data-test-subj="deleteAction"]').click();
// The confirm button should be disabled
cy.get('[data-test-subj="deleteConfirmButton"]').should("be.disabled");
// type delete
cy.wait(500).get('[data-test-subj="deleteInput"]').type("delete");
cy.get('[data-test-subj="deleteConfirmButton"]').should("not.be.disabled");
// click to delete
cy.get('[data-test-subj="deleteConfirmButton"]').click();
// the alias should not exist
cy.wait(500);
cy.get(`#_selection_column_${SAMPLE_ALIAS_PREFIX}-0-checkbox`).should("not.exist");
});
});

after(() => {
cy.deleteAllIndices();
for (let i = 0; i < 30; i++) {
cy.removeAlias(`${SAMPLE_ALIAS_PREFIX}-${i}`);
}
cy.removeAlias(CREATE_ALIAS);
});
});
257 changes: 257 additions & 0 deletions cypress/integration/create_index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { PLUGIN_NAME } from "../support/constants";

const SAMPLE_INDEX = "index-specific-index";

describe("Create Index", () => {
before(() => {
// Set welcome screen tracking to false
localStorage.setItem("home:welcome:show", "false");
cy.deleteAllIndices();
cy.deleteTemplate("index-common-template");
cy.deleteTemplate("index-specific-template");
cy.createIndexTemplate("index-common-template", {
index_patterns: ["index-*"],
template: {
aliases: {
alias_for_common_1: {},
alias_for_common_2: {},
},
settings: {
number_of_shards: 2,
number_of_replicas: 1,
},
},
});
cy.createIndexTemplate("index-specific-template", {
index_patterns: ["index-specific-*"],
priority: 1,
template: {
aliases: {
alias_for_specific_1: {},
},
settings: {
number_of_shards: 3,
number_of_replicas: 2,
},
mappings: {
properties: {
text: {
type: "text",
},
},
},
},
});
});

describe("can be created and updated", () => {
beforeEach(() => {
// Visit ISM OSD
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/indices`);
cy.contains("Rows per page", { timeout: 60000 });
});

it("Create a index successfully", () => {
// enter create page
cy.get('[data-test-subj="Create IndexButton"]').click();
cy.contains("Create index");

// type field name
cy.get('[placeholder="Specify a name for the new index."]').type(SAMPLE_INDEX).blur();

cy.wait(1000);

cy.get('[data-test-subj="comboBoxSearchInput"]').get('[title="alias_for_specific_1"]').should("exist");

cy.get('[data-test-subj="comboBoxSearchInput"]').type("some_test_alias{enter}");

cy.get('[data-test-subj="editorTypeJsonEditor"]').click().end();

cy.get('[data-test-subj="mappingsJsonEditorFormRow"] [data-test-subj="jsonEditor-valueDisplay"]').should(($editor) => {
expect(JSON.parse($editor.val())).to.deep.equal({
properties: {
text: {
type: "text",
},
},
});
});

cy.get('[data-test-subj="mappingsJsonEditorFormRow"] .ace_text-input')
.focus()
.clear({ force: true })
.type(
JSON.stringify({
properties: {
text: {
type: "text",
},
},
dynamic: true,
}),
{ parseSpecialCharSequences: false, force: true }
)
.end()
.wait(1000)
.get('[data-test-subj="editorTypeVisualEditor"]')
.click()
.end();

// add a field
cy.get('[data-test-subj="createIndexAddFieldButton"]').click().end();
cy.get('[data-test-subj="mapping-visual-editor-1-field-name"]').type("text_mappings");

// click create
cy.get('[data-test-subj="createIndexCreateButton"]').click({ force: true });

// The index should exist
cy.get(`#_selection_column_${SAMPLE_INDEX}-checkbox`).should("have.exist");

// check the index detail
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/create-index/${SAMPLE_INDEX}`);

// index name and alias should exist
cy.get(`[title="${SAMPLE_INDEX}"]`)
.should("have.exist")
.end()
.get('[title="some_test_alias"]')
.should("have.exist")
.end()
.get('[data-test-subj="mapping-visual-editor-0-field-type"]')
.should("have.attr", "title", "text")
.end()
.get('[data-test-subj="mapping-visual-editor-1-field-name"]')
.should("have.attr", "title", "text_mappings")
.end()
.get('[data-test-subj="editorTypeJsonEditor"]')
.click()
.end()
.get('[data-test-subj="mappingsJsonEditorFormRow"] [data-test-subj="jsonEditor-valueDisplay"]')
.should(($editor) => {
expect(JSON.parse($editor.val())).to.deep.equal({
dynamic: "true",
properties: {},
});
});
});

it("Update alias successfully", () => {
cy.get(`[data-test-subj="viewIndexDetailButton-${SAMPLE_INDEX}"]`).click().get("#indexDetailModalAlias").click();

// add a alias and remove the exist alias
cy.get('[data-test-subj="comboBoxSearchInput"]')
.type("some_new_test_alias{enter}")
.end()
.get('[title="some_test_alias"] .euiBadge__iconButton')
.click()
.end()
.get('[data-test-subj="createIndexCreateButton"]')
.click({ force: true })
.end();

cy.get('[title="some_test_alias"]').should("not.exist").end().get('[title="some_new_test_alias"]').should("exist").end();
});

it("Update settings successfully", () => {
cy.get(`[data-test-subj="viewIndexDetailButton-${SAMPLE_INDEX}"]`).click().get("#indexDetailModalSettings").click();

cy.get('[aria-controls="accordionForCreateIndexSettings"]')
.click()
.end()
.get(".ace_text-input")
.focus()
.clear({ force: true })
.type('{ "index.blocks.write": true, "index.number_of_shards": 2, "index.number_of_replicas": 3 }', {
parseSpecialCharSequences: false,
force: true,
})
.blur();

cy.get('[data-test-subj="createIndexCreateButton"]').click({ force: true });

cy.contains(`Can't update non dynamic settings`).should("exist");

cy.get(".ace_text-input")
.focus()
.clear({ force: true })
.type('{ "index.blocks.write": true, "index.number_of_shards": "3" }', { parseSpecialCharSequences: false, force: true })
.end()
.wait(1000)
.get('[placeholder="The number of replica shards each primary shard should have."]')
.clear()
.type(2)
.end();

cy.get('[data-test-subj="createIndexCreateButton"]').click({ force: true });

cy.wait(1000).get('[data-test-subj="form-name-index.number_of_replicas"] input').should("have.value", "2");
});

it("Update mappings successfully", () => {
cy.get(`[data-test-subj="viewIndexDetailButton-${SAMPLE_INDEX}"]`).click().get("#indexDetailModalMappings").click();

cy.get('[data-test-subj="createIndexAddFieldButton"]')
.click()
.end()
.get('[data-test-subj="mapping-visual-editor-2-field-name"]')
.type("text_mappings_2")
.end()
.get('[data-test-subj="createIndexCreateButton"]')
.click({ force: true });

cy.get('[data-test-subj="mapping-visual-editor-2-field-type"]').should("have.attr", "title", "text").end();

cy.get('[data-test-subj="editorTypeJsonEditor"]')
.click()
.end()
.get(".ace_text-input")
.focus()
.clear({ force: true })
.type('{ "dynamic": true }', { parseSpecialCharSequences: false, force: true })
.blur()
.end()
.wait(1000)
.get('[data-test-subj="createIndexCreateButton"]')
.click({ force: true });

cy.wait(1000)
.get('[data-test-subj="editorTypeJsonEditor"]')
.click()
.end()
.get('[data-test-subj="previousMappingsJsonButton"]')
.click()
.end()
.get('[data-test-subj="previousMappingsJsonModal"] [data-test-subj="jsonEditor-valueDisplay"]')
.should(
"have.text",
JSON.stringify(
{
dynamic: "true",
properties: {
text: {
type: "text",
},
text_mappings: {
type: "text",
},
text_mappings_2: {
type: "text",
},
},
},
null,
2
)
);
});
});

after(() => {
cy.deleteTemplate("index-common-template");
cy.deleteTemplate("index-specific-template");
});
});
Loading

0 comments on commit 3d51152

Please sign in to comment.