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

test(livechat): Fix OC - Livechat New Chat Triggers - After Registration flaky test #32309

Merged
merged 9 commits into from
Jul 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ test.describe('OC - Livechat New Chat Triggers - After Registration', () => {
triggersName = faker.string.uuid();
triggerMessage = 'This is a trigger message after guest registration';

const requests = await Promise.all([
await Promise.all([
api.post('/livechat/users/agent', { username: 'user1' }),
api.post('/livechat/users/manager', { username: 'user1' }),
]);

requests.every((e) => expect(e.status()).toBe(200));

const { page } = await createAuxContext(browser, Users.user1, '/omnichannel/triggers');
agent = { page, poHomeOmnichannel: new HomeOmnichannel(page) };
await page.emulateMedia({ reducedMotion: 'reduce' });
Expand All @@ -45,17 +43,18 @@ test.describe('OC - Livechat New Chat Triggers - After Registration', () => {

await Promise.all(ids.map((id) => api.delete(`/livechat/triggers/${id}`)));

await Promise.all([
api.delete('/livechat/users/agent/user1'),
api.delete('/livechat/users/manager/user1'),
api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: false }),
]);
await Promise.all([api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1')]);

await agent.page.close();
await poLiveChat.page.close();
});

test.afterAll(async ({ api }) => {
await api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: false });
});

test.describe('OC - Livechat New Chat Triggers - After Registration', async () => {
await test('expect trigger message after registration', async () => {
test('expect trigger message after registration', async () => {
await poLiveChat.page.goto('/livechat');
await poLiveChat.sendMessageAndCloseChat(newVisitor);

Expand Down Expand Up @@ -102,7 +101,7 @@ test.describe('OC - Livechat New Chat Triggers - After Registration', () => {
await api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: true });
});

await test('expect trigger message after registration', async () => {
test('expect trigger message after registration', async () => {
await poLiveChat.page.goto('/livechat');
await poLiveChat.sendMessageAndCloseChat(newVisitor);

Expand Down
Loading