From b880717724b4e70242d88bfca6abf04a4fcc0849 Mon Sep 17 00:00:00 2001 From: YiniXu9506 Date: Tue, 18 Jan 2022 19:45:13 +0800 Subject: [PATCH 01/41] test: add use database filter and search function --- .../integration/slow_query/list.spec.js | 118 ++++++++++++++++-- ui/lib/apps/SlowQuery/pages/List/index.tsx | 8 +- 2 files changed, 114 insertions(+), 12 deletions(-) diff --git a/ui/cypress/integration/slow_query/list.spec.js b/ui/cypress/integration/slow_query/list.spec.js index 4674e5c414..2545ce58b2 100644 --- a/ui/cypress/integration/slow_query/list.spec.js +++ b/ui/cypress/integration/slow_query/list.spec.js @@ -1,6 +1,7 @@ // Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0. import dayjs from 'dayjs' +import { describe } from 'mocha' describe('SlowQuery list page', () => { before(() => { @@ -225,18 +226,113 @@ describe('SlowQuery list page', () => { it('Show all databases', () => { cy.request(options).as('databases') + let databaseList - cy.get('@databases').then((response) => { - const databaseList = response.body - cy.get('[data-e2e=base_select_input]') - .click() - .then(() => { - cy.get('[data-e2e=multi_select_options_label]').should( - 'have.length', - databaseList.length - ) - }) - }) + cy.get('@databases') + .then((response) => { + databaseList = response.body + cy.get('[data-e2e=base_select_input]') + .click() + .then(() => { + cy.get('[data-e2e=multi_select_options_label]').should( + 'have.length', + databaseList.length + ) + }) + }) + .then(() => { + // check configs after reload + cy.get('[data-e2e=multi_select_options_label]').should( + 'have.length', + databaseList.length + ) + console.log('databaseList', databaseList) + }) + }) + + it('Run workload without use database', () => { + let queryData = { + query: 'SELECT sleep(0.5);', + database: '', + } + cy.task('queryDB', { ...queryData }) + + cy.reload() + // global and use database queries will be listed + cy.get('[data-automation-key=query]').should('has.length', 3) + + cy.get('[data-e2e=base_select_input]') + .click() + .then(() => { + cy.get('.ms-DetailsHeader-checkTooltip') + .click() + .then(() => { + // global query will not be listed + cy.get('[data-automation-key=query]').should('has.length', 2) + }) + }) + }) + }) + + describe('Search function', () => { + it('Default search text', () => { + cy.get('[data-e2e=slow_query_search]').should('be.empty') + }) + + it('Search item with space', () => { + cy.get('[data-e2e=slow_query_search]') + .type(' select sleep\\(1\\) {enter}') + .then(() => { + cy.get('[data-automation-key=query]').should('has.length', 1) + }) + + // clear search text + cy.get('[data-e2e=slow_query_search]') + .clear() + .type('{enter}') + .then(() => { + cy.get('[data-automation-key=query]').should('has.length', 3) + }) + }) + + it('Type search without pressing enter then reload', () => { + cy.get('[data-e2e=slow_query_search]').type(' select sleep\\(1\\)') + + cy.reload() + cy.get('[data-automation-key=query]').should('has.length', 3) + }) + }) + + describe('Slow query list limitation', () => { + it('Default limit', () => { + cy.get('[data-e2e=slow_query_limit_select]').contains('100') + }) + + const limitOptions = ['100', '200', '500', '1000'] + + it('Check limit options', () => { + cy.get('[data-e2e=slow_query_limit_select]') + .click() + .then(() => { + cy.get('[data-e2e=slow_query_limit_option]') + .should('have.length', 4) + .each(($option, $idx) => { + cy.wrap($option).contains(limitOptions[$idx]) + }) + }) + }) + + it('Check config remembered', () => { + cy.get('[data-e2e=slow_query_limit_select]') + .click() + .then(() => { + cy.get('[data-e2e=slow_query_limit_option]') + .eq(1) + .click() + .then(() => { + cy.get('[data-automation-key=query]').should('has.length', 3) + }) + }) }) }) }) diff --git a/ui/lib/apps/SlowQuery/pages/List/index.tsx b/ui/lib/apps/SlowQuery/pages/List/index.tsx index 44c40c22e8..af7e6817c4 100644 --- a/ui/lib/apps/SlowQuery/pages/List/index.tsx +++ b/ui/lib/apps/SlowQuery/pages/List/index.tsx @@ -129,14 +129,20 @@ function List() { onSearch={(searchText) => setQueryOptions({ ...queryOptions, searchText }) } + data-e2e="slow_query_search" /> + diff --git a/ui/lib/apps/SlowQuery/components/SlowQueriesTable.tsx b/ui/lib/apps/SlowQuery/components/SlowQueriesTable.tsx index 00cf0e9e21..9e819603bc 100644 --- a/ui/lib/apps/SlowQuery/components/SlowQueriesTable.tsx +++ b/ui/lib/apps/SlowQuery/components/SlowQueriesTable.tsx @@ -53,6 +53,7 @@ function SlowQueriesTable({ controller, ...restProps }: Props) { onRowClicked={handleRowClick} clickedRowIndex={getClickedItemIndex()} getKey={getKey} + data-e2e="detail_tabs_slow_query" /> ) } diff --git a/ui/lib/apps/Statement/pages/Detail/PlanDetailTabs.tsx b/ui/lib/apps/Statement/pages/Detail/PlanDetailTabs.tsx index e9379db1ed..bea192a4f9 100644 --- a/ui/lib/apps/Statement/pages/Detail/PlanDetailTabs.tsx +++ b/ui/lib/apps/Statement/pages/Detail/PlanDetailTabs.tsx @@ -36,6 +36,7 @@ export default function DetailTabs({ columns={columns} items={items} extendLastColumn + data-e2e="statement_pages_detail_tabs_basic" /> ) }, @@ -52,6 +53,7 @@ export default function DetailTabs({ columns={columns} items={items} extendLastColumn + data-e2e="statement_pages_detail_tabs_time" /> ) }, @@ -70,6 +72,7 @@ export default function DetailTabs({ columns={columns} items={items} extendLastColumn + data-e2e="statement_pages_detail_tabs_copr" /> ) }, @@ -86,6 +89,7 @@ export default function DetailTabs({ columns={columns} items={items} extendLastColumn + data-e2e="statement_pages_detail_tabs_txn" /> ) }, diff --git a/ui/lib/apps/Statement/pages/Detail/index.tsx b/ui/lib/apps/Statement/pages/Detail/index.tsx index 484fa76f68..7045036eb6 100644 --- a/ui/lib/apps/Statement/pages/Detail/index.tsx +++ b/ui/lib/apps/Statement/pages/Detail/index.tsx @@ -168,6 +168,7 @@ function DetailPage() { style={{ display: plans && plans.length > 1 ? 'block' : 'none', }} + data-e2e="statement_multiple_execution_plans" > - diff --git a/ui/lib/components/Bar/Bar.tsx b/ui/lib/components/Bar/Bar.tsx index e51922190c..b7338205f7 100644 --- a/ui/lib/components/Bar/Bar.tsx +++ b/ui/lib/components/Bar/Bar.tsx @@ -70,11 +70,7 @@ function Bar({ return (
{children && ( -
+
{children}
)}