Skip to content

Commit 4c356fb

Browse files
prabhjot-msftgithub-actions[bot]anjulgarg
authored
Tests for Upload Progress Bar for files in Sendbox (#1672)
* Resetting branch * minor change * Update composite automation snapshots * Update composite automation snapshots * Update composite automation snapshots * Update composite automation snapshots * Update composite automation snapshots * Update composite automation snapshots * Update composite automation snapshots * Update composite automation snapshots Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Anjul Garg <anjulgarg@live.com>
1 parent b838906 commit 4c356fb

9 files changed

Lines changed: 97 additions & 2 deletions
Loading

packages/react-composites/tests/browser/chat/FileSharing.test.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,88 @@ test.describe('Filesharing SendBox', async () => {
6262
expect(await page.screenshot()).toMatchSnapshot('filesharing-sendbox-filecards.png');
6363
});
6464
});
65+
66+
test.describe('Filesharing ProgressBar', async () => {
67+
test.skip(isTestProfileStableFlavor());
68+
69+
test.beforeEach(async ({ pages, users, serverUrl }) => {
70+
await chatTestSetup({ pages, users, serverUrl });
71+
});
72+
73+
test('is visible if progress is between 0 and 1', async ({ serverUrl, users, page }) => {
74+
await page.goto(
75+
buildUrl(serverUrl, users[0], {
76+
useFileSharing: 'true',
77+
uploadedFiles: JSON.stringify([
78+
{
79+
name: 'SampleFile.pdf',
80+
extension: 'pdf',
81+
url: 'https://sample.com/SampleFile.pdf',
82+
progress: 0.5
83+
},
84+
{
85+
name: 'SampleXlsLoooongName.xlsx',
86+
extension: 'xslx',
87+
url: 'https://sample.com/SampleXls.xlsx',
88+
progress: 0.8
89+
}
90+
])
91+
})
92+
);
93+
await waitForChatCompositeToLoad(page);
94+
await stubMessageTimestamps(page);
95+
expect(await page.screenshot()).toMatchSnapshot('filesharing-progress-bar-visible.png');
96+
});
97+
98+
test('is not visible if progress is 0 or less than 0', async ({ serverUrl, users, page }) => {
99+
await page.goto(
100+
buildUrl(serverUrl, users[0], {
101+
useFileSharing: 'true',
102+
uploadedFiles: JSON.stringify([
103+
{
104+
name: 'SampleFile.pdf',
105+
extension: 'pdf',
106+
url: 'https://sample.com/SampleFile.pdf',
107+
progress: 0
108+
},
109+
{
110+
name: 'SampleXlsLoooongName.xlsx',
111+
extension: 'xslx',
112+
url: 'https://sample.com/SampleXls.xlsx',
113+
progress: -1
114+
}
115+
])
116+
})
117+
);
118+
await waitForChatCompositeToLoad(page);
119+
await stubMessageTimestamps(page);
120+
expect(await page.screenshot()).toMatchSnapshot('filesharing-progress-bar-not-visible-progress-less-than-zero.png');
121+
});
122+
123+
test('is not visible if progress is 1 or greater than 1', async ({ serverUrl, users, page }) => {
124+
await page.goto(
125+
buildUrl(serverUrl, users[0], {
126+
useFileSharing: 'true',
127+
uploadedFiles: JSON.stringify([
128+
{
129+
name: 'SampleFile.pdf',
130+
extension: 'pdf',
131+
url: 'https://sample.com/SampleFile.pdf',
132+
progress: 1
133+
},
134+
{
135+
name: 'SampleXlsLoooongName.xlsx',
136+
extension: 'xslx',
137+
url: 'https://sample.com/SampleXls.xlsx',
138+
progress: 10
139+
}
140+
])
141+
})
142+
);
143+
await waitForChatCompositeToLoad(page);
144+
await stubMessageTimestamps(page);
145+
expect(await page.screenshot()).toMatchSnapshot(
146+
'filesharing-progress-bar-not-visible-progress-greater-than-one.png'
147+
);
148+
});
149+
});
Loading
Loading
Loading
Loading
Loading
Loading

packages/react-composites/tests/browser/chat/app/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
createCompletedFileUpload,
1515
useAzureCommunicationChatAdapter
1616
} from '../../../../src';
17+
// eslint-disable-next-line no-restricted-imports
18+
import { FileUpload } from '../../../../src/composites/ChatComposite/file-sharing';
1719
import { IDS } from '../../common/constants';
1820
import { initializeIconsForUITests, verifyParamExists } from '../../common/testAppUtils';
1921

@@ -56,8 +58,16 @@ function App(): JSX.Element {
5658

5759
React.useEffect(() => {
5860
if (adapter && uploadedFiles.length) {
59-
const files = uploadedFiles.map((file) => createCompletedFileUpload(file));
60-
adapter.registerFileUploads(files);
61+
uploadedFiles.forEach((file) => {
62+
if (file.progress) {
63+
const fileUpload = new FileUpload(new File([], file.name));
64+
adapter.registerFileUploads([fileUpload]);
65+
fileUpload.notifyUploadProgressChanged(file.progress);
66+
} else {
67+
const completedFileUpload = createCompletedFileUpload(file);
68+
adapter.registerFileUploads([completedFileUpload]);
69+
}
70+
});
6171
}
6272
}, [adapter]);
6373

0 commit comments

Comments
 (0)