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: improve some e2e selectors #27936

Merged
merged 9 commits into from
Feb 3, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 0 additions & 15 deletions apps/meteor/tests/e2e/config/global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ export default async function (): Promise<void> {

await page.waitForTimeout(1000);

if (page.url().includes('setup-wizard')) {
await page.locator('[name="organizationName"]').type('any_name');
await page.locator('[name="organizationType"]').click();
await page.locator('.rcx-options .rcx-option:first-child >> text="Community"').click();
await page.locator('[name="organizationIndustry"]').click();
await page.locator('.rcx-options .rcx-option:first-child >> text="Aerospace & Defense"').click();
await page.locator('[name="organizationSize"]').click();
await page.locator('.rcx-options .rcx-option:first-child >> text="1-10 people"').click();
await page.locator('[name="country"]').click();
await page.locator('.rcx-options .rcx-option:first-child >> text="Afghanistan"').click();
await page.locator('.rcx-button--primary.rcx-button >> text="Next"').click();
await page.locator('a.rcx-box.rcx-box--full >> text="Continue as standalone"').click();
await page.locator('.rcx-button--primary.rcx-button >> text="Confirm"').click();
}

await page.context().storageState({ path: `admin-session.json` });

await browser.close();
Expand Down
45 changes: 41 additions & 4 deletions apps/meteor/tests/e2e/fixtures/inject-initial-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,47 @@ export default async function injectInitialData() {
),
);

await connection
.db()
.collection('rocketchat_settings')
.updateOne({ _id: 'API_Enable_Rate_Limiter_Dev' }, { $set: { value: false } });
await Promise.all(
[
{
_id: 'API_Enable_Rate_Limiter_Dev',
value: false,
},
{
_id: 'Show_Setup_Wizard',
value: 'completed',
},
{
_id: 'Country',
value: 'brazil',
},
{
_id: 'Organization_Type',
value: 'community',
},
{
_id: 'Industry',
value: 'aerospaceDefense',
},
{
_id: 'Size',
value: 0,
},
{
_id: 'Organization_Name',
value: 'any_name',
},
{
_id: 'API_Enable_Rate_Limiter_Dev',
value: false,
},
].map((setting) =>
connection
.db()
.collection('rocketchat_settings')
.updateOne({ _id: setting._id }, { $set: { value: setting.value } }),
),
);

return { usersFixtures };
}
4 changes: 2 additions & 2 deletions apps/meteor/tests/e2e/message-mentions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test.describe.serial('message-mentions', () => {
await poHomeChannel.sidenav.openChat('general');
await poHomeChannel.content.inputMessage.type('@');

await expect(poHomeChannel.content.messagePopUpItems.locator('strong >> text=all')).toBeVisible();
await expect(poHomeChannel.content.messagePopUpItems.locator('strong >> text=here')).toBeVisible();
await expect(poHomeChannel.content.messagePopUpItems.locator('strong >> text="all"')).toBeVisible();
await expect(poHomeChannel.content.messagePopUpItems.locator('strong >> text="here"')).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class HomeContent {
}

get resumeOnHoldOmnichannelChatButton(): Locator {
return this.page.locator('button.rcx-button--primary >> text=Resume');
return this.page.locator('button.rcx-button--primary >> text="Resume"');
}

get btnOnHold(): Locator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export class HomeFlextabChannels {
}

get btnAdd(): Locator {
return this.page.locator('#modal-root button:has-text("Add")');
return this.page.locator('role=dialog >> role=group >> role=button[name=Add]');
}
}
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/page-objects/home-team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export class HomeTeam {
}

get btnTeamCreate(): Locator {
return this.page.locator('#modal-root button:has-text("Create")');
return this.page.locator('role=dialog >> role=group >> role=button[name=Create]');
}
}
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/page-objects/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export class Utils {
}

get btnModalConfirmDelete() {
return this.page.locator('.rcx-modal >> button >> text=Delete');
return this.page.locator('.rcx-modal >> button >> text="Delete"');
}
}
4 changes: 2 additions & 2 deletions apps/meteor/tests/e2e/settings-account-profile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test.describe.serial('settings-account-profile', () => {
await poAccountProfile.inputToken.type(token);
await poAccountProfile.btnTokensAdd.click();
await expect(poAccountProfile.tokenAddedModal).toBeVisible();
await page.locator('button:has-text("Ok")').click();
await page.locator('role=button[name=Ok]').click();
});

await test.step('expect not allow add new personal token with same name', async () => {
Expand All @@ -64,7 +64,7 @@ test.describe.serial('settings-account-profile', () => {
await poAccountProfile.tokenInTable(token).locator('button >> nth=0').click();
await poAccountProfile.btnRegenerateTokenModal.click();
await expect(poAccountProfile.tokenAddedModal).toBeVisible();
await page.locator('button:has-text("Ok")').click();
await page.locator('role=button[name=Ok]').click();
});

await test.step('expect delete personal token', async () => {
Expand Down