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

8904 - FileuploadAdvanced beforefileupload #8987

Merged
merged 6 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion app/views/components/fileupload-advanced/example-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
value: 'fileupload-advanced-automation-id'
}
]
})
}).on('beforefileupload', (args) => {
console.log(args);
});
});
</script>
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v4.99.0 Features

- `[Datagrid]` Added `scrollRowIntoView`. ([NG#1761](https://github.com/infor-design/enterprise-ng/issues/1761))
- `[FileuploadAdvanced]` Added beforefileupload event in handleFileUpload method. ([#8904](https://github.com/infor-design/enterprise/issues/8904))
- `[Listview]` Added compact layout in listview. ([#8959](https://github.com/infor-design/enterprise/issues/8959))
- `[Module Tabs]` Updated tab colors. ([#8831](https://github.com/infor-design/enterprise/issues/8831))
- `[Notification]` Added a callback function setting to be called when the notification is closed. ([#8767](https://github.com/infor-design/enterprise/issues/8767))
Expand Down
2 changes: 2 additions & 0 deletions src/components/fileupload-advanced/fileupload-advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ FileUploadAdvanced.prototype = {
return;
}

this.element.triggerHandler('beforefileupload', [files]);

const s = this.settings;

// Clear previous errors in general area
Expand Down
79 changes: 51 additions & 28 deletions tests/fileupload-advanced/fileupload-advanced.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,68 @@ import { expect } from '@playwright/test';
import { test } from '../base-fixture';

test.describe('FileuploadAdvanced tests', () => {
const url = '/components/fileupload-advanced/example-index.html';
test.describe('FileuploadAdvanced example tests', () => {
const url = '/components/fileupload-advanced/example-index.html';

test.beforeEach(async ({ page }) => {
await page.goto(url);
});
test.beforeEach(async ({ page }) => {
await page.goto(url);
});

test.describe('general page checks', () => {
test('should have a title', async ({ page }) => {
await expect(page).toHaveTitle('IDS Enterprise');
test.describe('general page checks', () => {
test('should have a title', async ({ page }) => {
await expect(page).toHaveTitle('IDS Enterprise');
});
});
});

test.describe('accessibility tests', () => {
test('should pass an Axe scan', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
const accessibilityScanResults = await new AxeBuilder({ page })
.disableRules(['meta-viewport'])
.exclude('[disabled]')
.analyze();
expect(accessibilityScanResults.violations).toEqual([]);
test.describe('accessibility tests', () => {
test('should pass an Axe scan', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
const accessibilityScanResults = await new AxeBuilder({ page })
.disableRules(['meta-viewport'])
.exclude('[disabled]')
.analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});
});
});

test.describe('snapshot tests', () => {
test('should match innerHTML snapshot', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
const html = await page.evaluate(() => {
const elem = document.querySelector('.fileupload-advanced');
return elem?.outerHTML;
test.describe('snapshot tests', () => {
test('should match innerHTML snapshot', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
const html = await page.evaluate(() => {
const elem = document.querySelector('.fileupload-advanced');
return elem?.outerHTML;
});
await expect(html).toMatchSnapshot('fileupload-advanced-html');
});

test('should match the visual snapshot in percy', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
await percySnapshot(page, 'fileupload-advanced-light');
});
await expect(html).toMatchSnapshot('fileupload-advanced-html');
});

test('should match the visual snapshot in percy', async ({ page, browserName }) => {
if (browserName !== 'chromium') return;
await percySnapshot(page, 'fileupload-advanced-light');
test.describe('functionality tests', () => {
});
});

test.describe('functionality tests', () => {
test.describe('fileuploadadvanced tests', () => {
const url = '/components/fileupload-advanced/example-index.html';

test.beforeEach(async ({ page }) => {
await page.goto(url);
});

test.describe('open fileupload tests', () => {
test('value should have a file', async ({ page }) => {
const input = page.locator('.hyperlink');

await expect(input).toBeVisible();

await input.setInputFiles('./app/www/images/35.jpg');

await expect(page.locator('.drop-area + .container')).toBeVisible();
await expect(page.locator('.drop-area + .container')).toHaveClass('container');
});
});
});
});
Loading