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: close pages after page spec #32832

Merged
merged 1 commit into from
Jul 18, 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
2 changes: 1 addition & 1 deletion apps/meteor/app/e2e/client/rocketchat.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class E2E extends Emitter {
delete this.instancesByRoomId[rid];
}

async persistKeys(
private async persistKeys(
{ public_key, private_key }: KeyPair,
password: string,
{ force }: { force: boolean } = { force: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ test.describe('omnichannel-auto-onhold-chat-closing', () => {
agent = { page, poHomeChannel: new HomeChannel(page) };
});
test.afterAll(async ({ api }) => {
await agent.page.close();

await Promise.all([
api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_auto_close_on_hold_chats_timeout', { value: 3600 }).then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_allow_manual_on_hold', { value: false }).then((res) => expect(res.status()).toBe(200)),
]);

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

test.beforeEach(async ({ page, api }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ test.describe('omnichannel-auto-transfer-unanswered-chat', () => {
});

test.afterAll(async ({ api }) => {
await agent1.page.close();
await agent2.page.close();

await Promise.all([
api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)),
api.delete('/livechat/users/agent/user2').then((res) => expect(res.status()).toBe(200)),
api.post('/settings/Livechat_auto_transfer_chat_timeout', { value: 0 }).then((res) => expect(res.status()).toBe(200)),
]);

await agent1.page.close();
await agent2.page.close();
});

test.beforeEach(async ({ page, api }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ test.describe.serial('omnichannel-changing-room-priority-and-sla', () => {
});

test.afterAll(async ({ api }) => {
let statusCode = (await api.delete(`/livechat/users/agent/${ADMIN_CREDENTIALS.username}`)).status();
await expect(statusCode).toBe(200);

statusCode = (await api.delete(`/livechat/users/manager/${ADMIN_CREDENTIALS.username}`)).status();
await expect(statusCode).toBe(200);

statusCode = (await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' })).status();
await expect(statusCode).toBe(200);

await agent.page.close();

await Promise.all([
api.delete(`/livechat/users/agent/${ADMIN_CREDENTIALS.username}`),
api.delete(`/livechat/users/manager/${ADMIN_CREDENTIALS.username}`),
api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }),
]);
});

test('expect to initiate a new livechat conversation', async ({ page, api }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ test.describe('Omnichannel close inquiry', () => {
agent = { page: auxPage, poHomeOmnichannel: new HomeOmnichannel(auxPage) };
});

test.afterEach(async () => {
await agent.page.close();
});

test.afterAll(async ({ api }) => {
await Promise.all([
await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }).then((res) => expect(res.status()).toBe(200)),
await api.delete('/livechat/users/agent/user1'),
await api.delete('/livechat/users/manager/user1'),
]);
await agent.page.close();
});

test('Receiving a message from visitor', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test.describe('OC - Livechat - Avatar visibility', async () => {
});

test.afterEach(async ({ page }) => {
await poAuxContext.page?.close();
await poAuxContext.page.close();
await page.close();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ test.describe('OC - Livechat - Department Flow', () => {
});

test.afterEach(async ({ page }) => {
await poHomeOmnichannelAgent1?.page?.close();
await poHomeOmnichannelAgent2?.page?.close();
await poHomeOmnichannelAgent1.page.close();
await poHomeOmnichannelAgent2.page.close();
await page.close();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test.describe('OC - Livechat - OC - File Upload', () => {
await api.post('/settings/FileUpload_Enabled', { value: true });
await api.post('/settings/Livechat_fileupload_enabled', { value: true });

await poHomeOmnichannel.page?.close();
await poHomeOmnichannel.page.close();
await agent.delete();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ test.describe('OC - Livechat - Widget logo', async () => {
poLiveChat = new OmnichannelLiveChat(livechatPage, api);
});

test.afterEach(async () => {
await poLiveChat.page.close();
});

test.beforeEach(async ({ page }) => {
poOmnichannelSettings = new OmnichannelSettings(page);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ test.describe('OC - Livechat - Cross Tab Communication', () => {
await pageLivechat2.page.goto('/livechat');
});

test.afterAll(async () => {
await poHomeOmnichannel.page?.close();
await agent.delete();
test.afterEach(async () => {
await pageLivechat1.page.close();
await pageLivechat2.page.close();
});

test.afterAll(async () => {
await poHomeOmnichannel.page.close();
await agent.delete();
});

test('OC - Livechat - Send messages, close chat and start again 2 tabs', async () => {
const firstUser = {
name: `${faker.person.firstName()} ${faker.string.uuid()}}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ test.describe('OC - Livechat - Hide watermark', async () => {
poLiveChat = new OmnichannelLiveChat(livechatPage, api);
});

test.afterEach(async () => {
await poLiveChat.page.close();
});

test.beforeEach(async ({ page }) => {
poOmnichannelSettings = new OmnichannelSettings(page);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ test.describe('OC - Manual Selection', () => {
agentB = await createAuxContext(browser, Users.user1).then(({ page }) => ({ page, poHomeOmnichannel: new HomeOmnichannel(page) }));
});

test.afterEach(async () => {
await agentB.page.close();
});
// Delete all data
test.afterAll(async ({ api }) => {
await Promise.all([
agentB.page.close(),
...agents.map((agent) => agent.delete()),
api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test.describe('OC - Manage Tags', () => {

test.afterAll(async () => {
await department.delete();
await department2.delete();
await agent.delete();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ test.describe('omnichannel-takeChat', () => {

await expect(agent.poHomeChannel.content.btnTakeChat).not.toBeVisible();
await expect(agent.poHomeChannel.content.inputMessage).toBeVisible();

await poLiveChat.closeChat();
});

test('When agent is offline should not take the chat', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ test.describe('OC - Chat transfers [Agent role]', () => {
});

// Make "user-1" online & "user-2" offline so that chat can be automatically routed to "user-1"
test.beforeEach(async () => {
test.beforeAll(async () => {
const [agentA, agentB] = sessions;
await agentA.poHomeOmnichannel.sidenav.switchStatus('online');
await agentB.poHomeOmnichannel.sidenav.switchStatus('offline');
});

// Close sessions
test.afterEach(async () => {
test.afterAll(async () => {
await Promise.all(sessions.map(({ page }) => page.close()));
});

// Start a new chat for each test
test.beforeEach(async ({ api }) => {
test.beforeAll(async ({ api }) => {
conversations = [await createConversation(api)];
});

Expand Down
Loading