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: add eslint-plugin-playwright rules for e2e tests and fix errors #2680

Merged
merged 4 commits into from
Feb 12, 2025
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
6 changes: 6 additions & 0 deletions e2e-tests/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ module.exports = {
rules: {
'no-empty-pattern': ['error', { allowObjectPatternsAsParameters: true }],
},
overrides: [
{
"files": ["admin/tests/**", "desktop/tests/**"],
"extends": "plugin:playwright/recommended"
}
]
};
2 changes: 1 addition & 1 deletion e2e-tests/admin/tests/alias-ent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test.beforeAll(async () => {
await boundaryCli.checkBoundaryCli();
});

test.describe('Aliases (Enterprise)', async () => {
test.describe('Aliases (Enterprise)', () => {
test('Set up alias from target details page @ent @aws @docker', async ({
page,
baseURL,
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/admin/tests/alias.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.beforeAll(async () => {
await boundaryCli.checkBoundaryCli();
});

test.describe('Aliases', async () => {
test.describe('Aliases', () => {
test('Set up alias from target details page @ce @aws @docker', async ({
page,
baseURL,
Expand Down
8 changes: 4 additions & 4 deletions e2e-tests/admin/tests/auth-method-ldap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ test('Set up LDAP auth method @ce @ent @docker', async ({
}
}

expect(
await expect(
hashicc marked this conversation as resolved.
Show resolved Hide resolved
page
.getByRole('cell', { name: ldapAccountName })
.locator('..')
.getByRole('cell')
.nth(fullNameIndex),
).toHaveText(ldapUserName);
expect(
await expect(
page
.getByRole('cell', { name: ldapAccountName })
.locator('..')
Expand Down Expand Up @@ -260,14 +260,14 @@ test('Set up LDAP auth method @ce @ent @docker', async ({
}
}

expect(
await expect(
page
.getByRole('cell', { name: ldapAccountName })
.locator('..')
.getByRole('cell')
.nth(fullNameIndex),
).toHaveText(ldapUserName);
expect(
await expect(
page
.getByRole('cell', { name: ldapAccountName })
.locator('..')
Expand Down
12 changes: 5 additions & 7 deletions e2e-tests/admin/tests/auth-method-oidc-vault.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ test('Set up OIDC auth method @ce @ent @docker @aws', async ({
// View the OIDC account and verify account attributes
await page.getByRole('link', { name: orgName }).click();
await expect(
page
.getByRole('navigation', { name: 'breadcrumbs' })
.getByText(orgName),
page.getByRole('navigation', { name: 'breadcrumbs' }).getByText(orgName),
).toBeVisible();
await page
.getByRole('navigation', { name: 'IAM' })
Expand Down Expand Up @@ -176,14 +174,14 @@ test('Set up OIDC auth method @ce @ent @docker @aws', async ({
}
}

expect(
await expect(
page
.getByRole('cell', { name: userName })
.locator('..')
.getByRole('cell')
.nth(fullNameIndex),
).toHaveText(userName);
expect(
await expect(
page
.getByRole('cell', { name: userName })
.locator('..')
Expand Down Expand Up @@ -218,14 +216,14 @@ test('Set up OIDC auth method @ce @ent @docker @aws', async ({
}
}

expect(
await expect(
page
.getByRole('cell', { name: userName })
.locator('..')
.getByRole('cell')
.nth(fullNameIndex),
).toHaveText(userName);
expect(
await expect(
page
.getByRole('cell', { name: userName })
.locator('..')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test.beforeEach(async ({ page }) => {
await page.goto('/');
});

test.describe('AWS', async () => {
test.describe('AWS', () => {
test('Create an AWS Dynamic Host Catalog and set up Host Sets @ent @aws', async ({
page,
baseURL,
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/admin/tests/dynamic-host-catalog-aws.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test.beforeEach(async ({ page }) => {
await page.goto('/');
});

test.describe('AWS', async () => {
test.describe('AWS', () => {
test('Create an AWS Dynamic Host Catalog and set up Host Sets @ce @aws', async ({
page,
baseURL,
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/admin/tests/login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test('Log in, log out, and then log back in @ce @ent @aws @docker', async ({
).toBeVisible();
});

test.describe('Failure Cases', async () => {
test.describe('Failure Cases', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/admin/tests/worker-tags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,5 @@ test('Worker Tags @ce @ent @aws @docker', async ({ page }) => {
await workersPage.removeTag(newTagKey);
await expect(
page.getByRole('table').getByRole('cell', { name: newTagKey }),
).not.toBeVisible();
).toBeHidden();
});
2 changes: 1 addition & 1 deletion e2e-tests/desktop/tests/authentication.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { expect, test } from '../fixtures/baseTest.js';
import LoginPage from '../pages/loginPage.js';

test.describe('user/password authentication tests', async () => {
test.describe('user/password authentication tests', () => {
test('Authenticates and signs out', async ({
electronPage,
clusterUrl,
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/desktop/tests/credentials.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ test.afterEach(async ({ request }) => {
}
});

test.describe('Credential Panel tests', async () => {
test.describe('Credential Panel tests', () => {
test('Display Vault brokered Credentials and handle special characters', async ({
authedPage,
}) => {
Expand Down
12 changes: 6 additions & 6 deletions e2e-tests/desktop/tests/scope.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ test.afterEach(async ({ request }) => {
}
});

test.describe('Scope tests', async () => {
test.describe('Scope tests', () => {
test('Shows the filtered targets based on selected scope', async ({
authedPage,
}) => {
const headerNavLocator = await authedPage.getByLabel('header-nav');
const headerNavLocator = authedPage.getByLabel('header-nav');
await expect(headerNavLocator).toBeVisible();
await expect(headerNavLocator.locator('summary')).toHaveText('Global');

Expand All @@ -62,7 +62,7 @@ test.describe('Scope tests', async () => {
).toBeVisible();

await headerNavLocator.click();
const orgAHeaderNavLink = await authedPage.getByRole('link', {
const orgAHeaderNavLink = authedPage.getByRole('link', {
name: orgA.name,
});
await orgAHeaderNavLink.click();
Expand All @@ -73,10 +73,10 @@ test.describe('Scope tests', async () => {
).toBeVisible();
await expect(
authedPage.getByRole('link', { name: targetB.name }),
).not.toBeVisible();
).toBeHidden();

await headerNavLocator.click();
const orgBHeaderNavLink = await authedPage.getByRole('link', {
const orgBHeaderNavLink = authedPage.getByRole('link', {
name: orgB.name,
});
await orgBHeaderNavLink.click();
Expand All @@ -87,6 +87,6 @@ test.describe('Scope tests', async () => {
).toBeVisible();
await expect(
authedPage.getByRole('link', { name: targetA.name }),
).not.toBeVisible();
).toBeHidden();
});
});
4 changes: 2 additions & 2 deletions e2e-tests/desktop/tests/sessions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ test.afterEach(async ({ request }) => {
}
});

test.describe('Sessions tests', async () => {
test.describe('Sessions tests', () => {
test('Establishes two different sessions and cancels them', async ({
authedPage,
}) => {
Expand Down Expand Up @@ -135,7 +135,7 @@ test.describe('Sessions tests', async () => {
});
});

test.describe('Filtering sessions tests', async () => {
test.describe('Filtering sessions tests', () => {
test.beforeEach(async ({ authedPage }) => {
// Connect to three targets
await authedPage
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/desktop/tests/settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { expect, test } from '../fixtures/baseTest.js';

test.describe('Settings Page tests', async () => {
test.describe('Settings Page tests', () => {
test.beforeEach(async ({ authedPage }) => {
await authedPage.getByRole('link', { name: 'Settings' }).click();
});
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/desktop/tests/targets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ test.afterEach(async ({ request }) => {
}
});

test.describe('Targets tests', async () => {
test.describe('Targets tests', () => {
test('Connects to a tcp target with one host', async ({ authedPage }) => {
await authedPage.getByRole('link', { name: targetWithHost.name }).click();
await authedPage.getByRole('button', { name: 'Connect' }).click();
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-playwright": "^2.2.0",
"nanoid": "^5.0.9",
"prettier": "^3.0.0"
},
Expand Down
Loading
Loading