Skip to content

Commit

Permalink
Add getByTestSubj command (elastic#142591)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbamparop authored and WafaaNasr committed Oct 11, 2022
1 parent 2262d44 commit 4e688c8
Show file tree
Hide file tree
Showing 22 changed files with 144 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ describe('Comparison feature flag', () => {
it('shows the comparison feature enabled in services overview', () => {
cy.visitKibana('/app/apm/services');
cy.get('input[type="checkbox"]#comparison').should('be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('not.be.disabled');
cy.getByTestSubj('comparisonSelect').should('not.be.disabled');
});

it('shows the comparison feature enabled in dependencies overview', () => {
cy.visitKibana('/app/apm/dependencies');
cy.get('input[type="checkbox"]#comparison').should('be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('not.be.disabled');
cy.getByTestSubj('comparisonSelect').should('not.be.disabled');
});

it('shows the comparison feature disabled in service map overview page', () => {
cy.visitKibana('/app/apm/service-map');
cy.get('input[type="checkbox"]#comparison').should('be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('not.be.disabled');
cy.getByTestSubj('comparisonSelect').should('not.be.disabled');
});
});

Expand All @@ -71,7 +71,7 @@ describe('Comparison feature flag', () => {
it('shows the comparison feature disabled in services overview', () => {
cy.visitKibana('/app/apm/services');
cy.get('input[type="checkbox"]#comparison').should('not.be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('be.disabled');
cy.getByTestSubj('comparisonSelect').should('be.disabled');
});

it('shows the comparison feature disabled in dependencies overview page', () => {
Expand All @@ -81,13 +81,13 @@ describe('Comparison feature flag', () => {
cy.visitKibana('/app/apm/dependencies');
cy.wait('@topDependenciesRequest');
cy.get('input[type="checkbox"]#comparison').should('not.be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('be.disabled');
cy.getByTestSubj('comparisonSelect').should('be.disabled');
});

it('shows the comparison feature disabled in service map overview page', () => {
cy.visitKibana('/app/apm/service-map');
cy.get('input[type="checkbox"]#comparison').should('not.be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('be.disabled');
cy.getByTestSubj('comparisonSelect').should('be.disabled');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,19 @@ describe('when navigating to integration page', () => {
cy.visitKibana(integrationsPath);

// open integration policy form
cy.get('[data-test-subj="integration-card:epr:apm:featured').click();
cy.getByTestSubj('integration-card:epr:apm:featured').click();
cy.contains('Elastic APM in Fleet').click();
cy.contains('a', 'APM integration').click();
cy.get('[data-test-subj="addIntegrationPolicyButton"]').click();
cy.getByTestSubj('addIntegrationPolicyButton').click();
});

it('checks validators for required fields', () => {
const requiredFields = policyFormFields.filter((field) => field.required);

requiredFields.map((field) => {
cy.get(`[data-test-subj="${field.selector}"`).clear();
cy.get('[data-test-subj="createPackagePolicySaveButton"').should(
'be.disabled'
);
cy.get(`[data-test-subj="${field.selector}"`).type(field.value);
cy.getByTestSubj(field.selector).clear();
cy.getByTestSubj('createPackagePolicySaveButton').should('be.disabled');
cy.getByTestSubj(field.selector).type(field.value);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ describe('Agent configuration', () => {
'/api/apm/settings/agent-configuration/environments?*'
).as('serviceEnvironmentApi');
cy.contains('Create configuration').click();
cy.get('[data-test-subj="serviceNameComboBox"]')
cy.getByTestSubj('serviceNameComboBox')
.click()
.type('opbeans-node')
.type('{enter}');

cy.contains('opbeans-node').realClick();
cy.wait('@serviceEnvironmentApi');

cy.get('[data-test-subj="serviceEnviromentComboBox"]')
cy.getByTestSubj('serviceEnviromentComboBox')
.click({ force: true })
.type('prod')
.type('{enter}');
Expand All @@ -115,14 +115,11 @@ describe('Agent configuration', () => {
'/api/apm/settings/agent-configuration/environments'
).as('serviceEnvironmentApi');
cy.contains('Create configuration').click();
cy.get('[data-test-subj="serviceNameComboBox"]')
.click()
.type('All')
.type('{enter}');
cy.getByTestSubj('serviceNameComboBox').click().type('All').type('{enter}');
cy.contains('All').realClick();
cy.wait('@serviceEnvironmentApi');

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Custom links', () => {

it('creates custom link', () => {
cy.visitKibana(basePath);
const emptyPrompt = cy.get('[data-test-subj="customLinksEmptyPrompt"]');
const emptyPrompt = cy.getByTestSubj('customLinksEmptyPrompt');
cy.contains('Create custom link').click();
cy.contains('Create link');
cy.contains('Save').should('be.disabled');
Expand All @@ -63,22 +63,22 @@ describe('Custom links', () => {
emptyPrompt.should('not.exist');
cy.contains('foo');
cy.contains('https://foo.com');
cy.get('[data-test-subj="editCustomLink"]').click();
cy.getByTestSubj('editCustomLink').click();
cy.contains('Delete').click();
});

it('clears filter values when field is selected', () => {
cy.visitKibana(basePath);

// wait for empty prompt
cy.get('[data-test-subj="customLinksEmptyPrompt"]').should('be.visible');
cy.getByTestSubj('customLinksEmptyPrompt').should('be.visible');

cy.contains('Create custom link').click();
cy.get('[data-test-subj="filter-0"]').select('service.name');
cy.getByTestSubj('filter-0').select('service.name');
cy.get(
'[data-test-subj="service.name.value"] [data-test-subj="comboBoxSearchInput"]'
).type('foo');
cy.get('[data-test-subj="filter-0"]').select('service.environment');
cy.getByTestSubj('filter-0').select('service.environment');
cy.get(
'[data-test-subj="service.environment.value"] [data-test-subj="comboBoxInput"]'
).should('not.contain', 'foo');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('Storage Explorer', () => {
});

it('renders the storage timeseries chart', () => {
cy.get('[data-test-subj="storageExplorerTimeseriesChart"]');
cy.getByTestSubj('storageExplorerTimeseriesChart');
});

it('has a list of services and environments', () => {
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('Storage Explorer', () => {
it('with the correct environment when changing the environment', () => {
cy.wait(mainAliasNames);

cy.get('[data-test-subj="environmentFilter"]').type('production');
cy.getByTestSubj('environmentFilter').type('production');

cy.contains('button', 'production').click({ force: true });

Expand Down Expand Up @@ -148,7 +148,7 @@ describe('Storage Explorer', () => {
it('with the correct lifecycle phase when changing the lifecycle phase', () => {
cy.wait(mainAliasNames);

cy.get('[data-test-subj="storageExplorerLifecyclePhaseSelect"]').click();
cy.getByTestSubj('storageExplorerLifecyclePhaseSelect').click();
cy.contains('button', 'Warm').click();

cy.expectAPIsToHaveBeenCalledWith({
Expand Down Expand Up @@ -180,13 +180,13 @@ describe('Storage Explorer', () => {
cy.wait(mainAliasNames);
cy.contains('opbeans-node');

cy.get('[data-test-subj="storageDetailsButton_opbeans-node"]').click();
cy.get('[data-test-subj="loadingSpinner"]').should('be.visible');
cy.getByTestSubj('storageDetailsButton_opbeans-node').click();
cy.getByTestSubj('loadingSpinner').should('be.visible');
cy.wait('@storageDetailsRequest');

cy.contains('Service storage details');
cy.get('[data-test-subj="storageExplorerTimeseriesChart"]');
cy.get('[data-test-subj="serviceStorageDetailsTable"]');
cy.getByTestSubj('storageExplorerTimeseriesChart');
cy.getByTestSubj('serviceStorageDetailsTable');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('APM deep links', () => {
});
it('navigates to apm links on search elastic', () => {
cy.visitKibana('/');
cy.get('[data-test-subj="nav-search-input"]').type('APM');
cy.getByTestSubj('nav-search-input').type('APM');
cy.contains('APM');
cy.contains('APM / Services');
cy.contains('APM / Traces');
Expand All @@ -23,17 +23,17 @@ describe('APM deep links', () => {
cy.contains('APM').click({ force: true });
cy.url().should('include', '/apm/services');

cy.get('[data-test-subj="nav-search-input"]').type('APM');
cy.getByTestSubj('nav-search-input').type('APM');
// navigates to services page
cy.contains('APM / Services').click({ force: true });
cy.url().should('include', '/apm/services');

cy.get('[data-test-subj="nav-search-input"]').type('APM');
cy.getByTestSubj('nav-search-input').type('APM');
// navigates to traces page
cy.contains('APM / Traces').click({ force: true });
cy.url().should('include', '/apm/traces');

cy.get('[data-test-subj="nav-search-input"]').type('APM');
cy.getByTestSubj('nav-search-input').type('APM');
// navigates to service maps
cy.contains('APM / Service Map').click({ force: true });
cy.url().should('include', '/apm/service-map');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ describe('Dependencies', () => {
})}`
);

cy.get('[data-test-subj="latencyChart"]');
cy.get('[data-test-subj="throughputChart"]');
cy.get('[data-test-subj="errorRateChart"]');
cy.getByTestSubj('latencyChart');
cy.getByTestSubj('throughputChart');
cy.getByTestSubj('errorRateChart');

cy.contains('opbeans-java').click({ force: true });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ describe('Error details', () => {
it('shows errors distribution chart', () => {
cy.visitKibana(errorDetailsPageHref);
cy.contains('Error group 00000');
cy.get('[data-test-subj="errorDistribution"]').contains('Occurrences');
cy.getByTestSubj('errorDistribution').contains('Occurrences');
});

it('shows top erroneous transactions table', () => {
cy.visitKibana(errorDetailsPageHref);
cy.contains('Top 5 affected transactions');
cy.get('[data-test-subj="topErroneousTransactionsTable"]')
cy.getByTestSubj('topErroneousTransactionsTable')
.contains('a', 'GET /apple 🍎')
.click();
cy.url().should('include', 'opbeans-java/transactions/view');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ describe('Errors page', () => {

it('clicking on type adds a filter in the kuerybar', () => {
cy.visitKibana(javaServiceErrorsPageHref);
cy.get('[data-test-subj="headerFilterKuerybar"]')
cy.getByTestSubj('headerFilterKuerybar')
.invoke('val')
.should('be.empty');
// `force: true` because Cypress says the element is 0x0
cy.contains('exception 0').click({
force: true,
});
cy.get('[data-test-subj="headerFilterKuerybar"]')
cy.getByTestSubj('headerFilterKuerybar')
.its('length')
.should('be.gt', 0);
cy.get('table')
Expand Down Expand Up @@ -158,7 +158,7 @@ describe('Check detailed statistics API with multiple errors', () => {
])
);
});
cy.get('[data-test-subj="pagination-button-1"]').click();
cy.getByTestSubj('pagination-button-1').click();
cy.wait('@errorsDetailedStatistics').then((payload) => {
expect(payload.request.body.groupIds).eql(
JSON.stringify([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('Home page', () => {
cy.contains('Services');
cy.contains('opbeans-rum').click({ force: true });

cy.get('[data-test-subj="headerFilterTransactionType"]').should(
cy.getByTestSubj('headerFilterTransactionType').should(
'have.value',
'page-load'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Service inventory - header filters', () => {
cy.contains('Services');
cy.contains('opbeans-node');
cy.contains('service 1');
cy.get('[data-test-subj="headerFilterKuerybar"]')
cy.getByTestSubj('headerFilterKuerybar')
.type(`service.name: "${specialServiceName}"`)
.type('{enter}');
cy.contains('service 1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('Service inventory', () => {
it('with the correct environment when changing the environment', () => {
cy.wait(mainAliasNames);

cy.get('[data-test-subj="environmentFilter"]').type('production');
cy.getByTestSubj('environmentFilter').type('production');

cy.contains('button', 'production').click();

Expand Down Expand Up @@ -175,7 +175,7 @@ describe('Service inventory', () => {
])
);
});
cy.get('[data-test-subj="pagination-button-1"]').click();
cy.getByTestSubj('pagination-button-1').click();
cy.wait('@detailedStatisticsRequest').then((payload) => {
expect(payload.request.body.serviceNames).eql(
JSON.stringify([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,12 @@ describe('Errors table', () => {

it('clicking on type adds a filter in the kuerybar and navigates to errors page', () => {
cy.visitKibana(serviceOverviewHref);
cy.get('[data-test-subj="headerFilterKuerybar"]')
.invoke('val')
.should('be.empty');
cy.getByTestSubj('headerFilterKuerybar').invoke('val').should('be.empty');
// `force: true` because Cypress says the element is 0x0
cy.contains('Exception').click({
force: true,
});
cy.get('[data-test-subj="headerFilterKuerybar"]')
.its('length')
.should('be.gt', 0);
cy.getByTestSubj('headerFilterKuerybar').its('length').should('be.gt', 0);
cy.get('table').find('td:contains("Exception")').should('have.length', 1);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ describe('Service overview - header filters', () => {
cy.visitKibana(serviceOverviewHref);
cy.contains('opbeans-node');
cy.url().should('not.include', 'transactionType');
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
cy.getByTestSubj('headerFilterTransactionType').should(
'have.value',
'request'
);
cy.get('[data-test-subj="headerFilterTransactionType"]').select('Worker');
cy.getByTestSubj('headerFilterTransactionType').select('Worker');
cy.url().should('include', 'transactionType=Worker');
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
cy.getByTestSubj('headerFilterTransactionType').should(
'have.value',
'Worker'
);
Expand All @@ -94,7 +94,7 @@ describe('Service overview - header filters', () => {
cy.intercept('GET', endpoint).as(name);
});
cy.visitKibana(serviceOverviewHref);
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
cy.getByTestSubj('headerFilterTransactionType').should(
'have.value',
'request'
);
Expand All @@ -104,9 +104,9 @@ describe('Service overview - header filters', () => {
value: 'transactionType=request',
});

cy.get('[data-test-subj="headerFilterTransactionType"]').select('Worker');
cy.getByTestSubj('headerFilterTransactionType').select('Worker');
cy.url().should('include', 'transactionType=Worker');
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
cy.getByTestSubj('headerFilterTransactionType').should(
'have.value',
'Worker'
);
Expand All @@ -129,18 +129,12 @@ describe('Service overview - header filters', () => {
})
);
cy.contains('opbeans-java');
cy.get('[data-test-subj="headerFilterKuerybar"]').type('transaction.n');
cy.getByTestSubj('headerFilterKuerybar').type('transaction.n');
cy.contains('transaction.name');
cy.get('[data-test-subj="suggestionContainer"]')
.find('li')
.first()
.click();
cy.get('[data-test-subj="headerFilterKuerybar"]').type(':');
cy.get('[data-test-subj="suggestionContainer"]')
.find('li')
.first()
.click();
cy.get('[data-test-subj="headerFilterKuerybar"]').type('{enter}');
cy.getByTestSubj('suggestionContainer').find('li').first().click();
cy.getByTestSubj('headerFilterKuerybar').type(':');
cy.getByTestSubj('suggestionContainer').find('li').first().click();
cy.getByTestSubj('headerFilterKuerybar').type('{enter}');
cy.url().should('include', '&kuery=transaction.name');
});
});
Expand Down
Loading

0 comments on commit 4e688c8

Please sign in to comment.