Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Updates integ tests for compatibility with webdriver upgrade #154

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/e2e/common/table/table-property-filtering-tests.ts
Original file line number Diff line number Diff line change
@@ -73,7 +73,8 @@ export default (setupTest: { (testFn: { (page: TablePropertyFilteringPageObject)
'Allows free-text filtering',
setupTest(async page => {
await page.focusFilter();
await page.search(['bbb', 'Enter']);
await page.search('bbb');
await page.keys(['Enter']);
await expect(page.getFilterText()).resolves.toBe('');
await expect(page.countTokens()).resolves.toBe(1);
})
4 changes: 1 addition & 3 deletions test/e2e/page/s3-page-object.ts
Original file line number Diff line number Diff line change
@@ -22,10 +22,8 @@ export default class S3PageObject extends BaseExamplePage {
return this.getOptionalText(wrapper.findFormField().findError().toSelector());
}

async setUriInputValue(value: string | string[]) {
async setUriInputValue(value: string) {
await this.setValue(s3ResourceSelector.findInContext().findUriInput().findNativeInput().toSelector(), value);
// click somewhere to blur the input and trigger validation
await this.click(wrapper.findHeader().toSelector());
}

getUriInputValue() {
2 changes: 1 addition & 1 deletion test/e2e/page/table-property-filtering-page-object.ts
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ export default class TablePropertyFilteringPageObject extends TablePageObject {
await this.waitUntilLoaded();
}

async search(text: string | string[]) {
async search(text: string) {
await this.setValue(filterInput, text);
await this.waitUntilPropertyFilterLoaded();
}
10 changes: 9 additions & 1 deletion test/e2e/s3-common.test.ts
Original file line number Diff line number Diff line change
@@ -20,11 +20,19 @@ import S3PageObject from './page/s3-page-object';
setupTest(async page => {
await expect(page.getErrorText()).resolves.toEqual(null);
await expect(page.getViewHref()).resolves.toEqual(null);

await page.setUriInputValue('not-a-uri');
// click somewhere to blur the input and trigger validation
await page.click(createWrapper().findHeader().toSelector());
await expect(page.getErrorText()).resolves.toContain('The path must begin with s3://');
await expect(page.getViewHref()).resolves.toEqual(null);
await page.setUriInputValue(['Escape']); // clear the input first

// clear the input first
await page.setUriInputValue('');
await page.keys(['Escape']);
await page.setUriInputValue('s3://bucket-enim/neutrino-8ms.sim');
// click somewhere to blur the input and trigger validation
await page.click(createWrapper().findHeader().toSelector());
await expect(page.getErrorText()).resolves.toEqual(null);
await expect(page.getViewHref()).resolves.toEqual('https://amazons3.demo.s3-resource-selector/test/1');
})
5 changes: 5 additions & 0 deletions test/e2e/s3-read.test.ts
Original file line number Diff line number Diff line change
@@ -81,9 +81,12 @@ describe('S3 Resource Selector - Read mode', () => {
'shows alert about non-existing objects',
setupTest(async page => {
await page.setUriInputValue('s3://totally/fictional');
// click somewhere to blur the input and trigger validation
await page.click(createWrapper().findHeader().toSelector());
await expect(page.getAlertText()).resolves.toEqual(
'Resource "s3://totally/fictional" cannot be found: "totally" bucket doesn\'t exist'
);

await page.click(s3ResourceSelector.findAlertSlot().findAlert().findDismissButton().toSelector());
await expect(page.getAlertText()).resolves.toEqual(null);
})
@@ -93,6 +96,8 @@ describe('S3 Resource Selector - Read mode', () => {
'shows alert about missing versions',
setupTest(async page => {
await page.setUriInputValue('s3://bucket-officia/particle-1ns.sim');
// click somewhere to blur the input and trigger validation
await page.click(createWrapper().findHeader().toSelector());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we're copying the same comment and the statement it in multiple places, how about just making a function out of it?

async function waitForValidation() {
      // click somewhere to blur the input and trigger validation
      await page.click(createWrapper().findHeader().toSelector());
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That click to the header is only needed to trigger a blue on the input for the validation to appear. It can as well be a click on another element or pressing Tab. The comment is needed to explain that it is not the click itself that matters but the blur. I am hesitating to create a function for it because: 1) it is hard to come up with a clear enough name, the "wait for validation" is not correct; 2) it makes an assumption that the header exists which might not be true for some new page if we want to reuse the function in there.

Copy link
Contributor

@orangevolon orangevolon Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can come up with a proper name for the function, the name of the function could be a very good replacement for the comment that we have repeated several times. That being said, if it's not applicable in this context then let's go with the comment 👍

await expect(page.getAlertText()).resolves.toContain(
'You might not have permissions to retrieve object versions.'
);
12 changes: 8 additions & 4 deletions test/e2e/table-saved-filters.test.ts
Original file line number Diff line number Diff line change
@@ -50,7 +50,8 @@ describe('Table - Saved Filters', () => {

// Add a new free text filter
await page.focusFilter();
await page.search(['bbb', 'Enter']);
await page.search('bbb');
await page.keys(['Enter']);

await expect(page.countTokens()).resolves.toBe(3);
await expect(page.getSelectedFilterSet()).resolves.toBe('Active web distributions (unsaved)');
@@ -66,7 +67,8 @@ describe('Table - Saved Filters', () => {

// Add a new free text filter
await page.focusFilter();
await page.search(['bbb', 'Enter']);
await page.search('bbb');
await page.keys(['Enter']);

await expect(page.countTokens()).resolves.toBe(2);
await expect(page.getSelectedFilterSet()).resolves.toBe('Distributions with buckets (unsaved)');
@@ -88,7 +90,8 @@ describe('Table - Saved Filters', () => {

// Add a new free text filter
await page.focusFilter();
await page.search(['bbb', 'Enter']);
await page.search('bbb');
await page.keys(['Enter']);

// Save as new filter
await page.openSaveFilterModal();
@@ -109,7 +112,8 @@ describe('Table - Saved Filters', () => {

// Add a new free text filter
await page.focusFilter();
await page.search(['bbb', 'Enter']);
await page.search('bbb');
await page.keys(['Enter']);

await expect(page.getSelectedFilterSet()).resolves.toBe('Active web distributions (unsaved)');


Unchanged files with check annotations Beta

return () => {
rendered = false;
};
}, []);

Check warning on line 19 in src/pages/commons/use-async-data.js

GitHub Actions / build

React Hook useEffect has a missing dependency: 'loadCallback'. Either include it or remove the dependency array. If 'loadCallback' changes too often, find the parent component that defines it and wrap that definition in useCallback
return [items, loading];
}
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
import React, { useState } from 'react';

Check warning on line 3 in src/pages/configurable-dashboard/components/page-banner.tsx

GitHub Actions / build

'React' is defined but never used
import Alert from '@cloudscape-design/components/alert';

Check warning on line 4 in src/pages/configurable-dashboard/components/page-banner.tsx

GitHub Actions / build

'Alert' is defined but never used
import { ExternalLink } from '../../commons';

Check warning on line 5 in src/pages/configurable-dashboard/components/page-banner.tsx

GitHub Actions / build

'ExternalLink' is defined but never used
export function PageBanner() {
const [visible, setVisible] = useState(true);

Check warning on line 8 in src/pages/configurable-dashboard/components/page-banner.tsx

GitHub Actions / build

'setVisible' is assigned a value but never used
if (!visible) {
return null;
}
useEffect(() => {
const isDirty = JSON.stringify(data) !== JSON.stringify(defaultData);
updateDirty(isDirty);
}, [data]);

Check warning on line 114 in src/pages/form/components/form-content.jsx

GitHub Actions / build

React Hook useEffect has a missing dependency: 'updateDirty'. Either include it or remove the dependency array. If 'updateDirty' changes too often, find the parent component that defines it and wrap that definition in useCallback
return (
<BaseFormContent
useEffect(() => {
const isDirty = JSON.stringify(data) !== JSON.stringify(defaultData);
updateDirty(isDirty);
}, [data]);

Check warning on line 126 in src/pages/form/components/form.jsx

GitHub Actions / build

React Hook useEffect has a missing dependency: 'updateDirty'. Either include it or remove the dependency array. If 'updateDirty' changes too often, find the parent component that defines it and wrap that definition in useCallback
return (
<BaseForm
// SPDX-License-Identifier: MIT-0
import React, { useState } from 'react';
import Flashbar, { FlashbarProps } from '@cloudscape-design/components/flashbar';
import Link from '@cloudscape-design/components/link';

Check warning on line 5 in src/pages/non-console/notifications.tsx

GitHub Actions / build

'Link' is defined but never used
import { useDisclaimerFlashbarItem } from '../commons/disclaimer-flashbar-item';
function useNotifications() {
}
};
window.FakeServer.fetchDistributions(params, callback);
}, [

Check warning on line 44 in src/pages/server-side-table/hooks.js

GitHub Actions / build

React Hook useEffect has a missing dependency: 'totalCount'. Either include it or remove the dependency array
pageSize,
sortingDescending,
sortingColumn,
import { useCollection } from '@cloudscape-design/collection-hooks';
import {
ButtonDropdown,
FormField,

Check warning on line 8 in src/pages/table-saved-filters/index.jsx

GitHub Actions / build

'FormField' is defined but never used
Flashbar,
Pagination,
PropertyFilter,