test: adapt tests to OAuth client rename

This commit is contained in:
Jakub P.
2024-12-19 20:19:28 +01:00
parent 8d5287d51e
commit d675fd6e69
4 changed files with 50 additions and 49 deletions

View File

@@ -2,14 +2,14 @@ import { expect } from '@playwright/test';
const { AuthenticatedPage } = require('../authenticated-page'); const { AuthenticatedPage } = require('../authenticated-page');
export class AdminApplicationAuthClientsPage extends AuthenticatedPage { export class AdminApplicationOAuthClientsPage extends AuthenticatedPage {
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
constructor(page) { constructor(page) {
super(page); super(page);
this.authClientsTab = this.page.getByTestId('auth-clients-tab'); this.authClientsTab = this.page.getByTestId('oauth-clients-tab');
this.saveButton = this.page.getByTestId('submitButton'); this.saveButton = this.page.getByTestId('submitButton');
this.successSnackbar = this.page.getByTestId( this.successSnackbar = this.page.getByTestId(
'snackbar-save-admin-apps-settings-success' 'snackbar-save-admin-apps-settings-success'

View File

@@ -8,7 +8,9 @@ const { AdminEditRolePage } = require('./edit-role-page');
const { AdminApplicationsPage } = require('./applications-page'); const { AdminApplicationsPage } = require('./applications-page');
const { AdminApplicationSettingsPage } = require('./application-settings-page'); const { AdminApplicationSettingsPage } = require('./application-settings-page');
const { AdminApplicationAuthClientsPage } = require('./application-auth-clients-page'); const {
AdminApplicationOAuthClientsPage,
} = require('./application-oauth-clients-page');
export const adminFixtures = { export const adminFixtures = {
adminUsersPage: async ({ page }, use) => { adminUsersPage: async ({ page }, use) => {
@@ -35,8 +37,7 @@ export const adminFixtures = {
adminApplicationSettingsPage: async ({ page }, use) => { adminApplicationSettingsPage: async ({ page }, use) => {
await use(new AdminApplicationSettingsPage(page)); await use(new AdminApplicationSettingsPage(page));
}, },
adminApplicationAuthClientsPage: async ({ page }, use) => { adminApplicationOAuthClientsPage: async ({ page }, use) => {
await use(new AdminApplicationAuthClientsPage(page)); await use(new AdminApplicationOAuthClientsPage(page));
} },
}; };

View File

@@ -71,7 +71,7 @@ test.describe('Admin Applications', () => {
test('should allow only custom connections', async ({ test('should allow only custom connections', async ({
adminApplicationsPage, adminApplicationsPage,
adminApplicationSettingsPage, adminApplicationSettingsPage,
adminApplicationAuthClientsPage, adminApplicationOAuthClientsPage,
flowEditorPage, flowEditorPage,
page, page,
}) => { }) => {
@@ -95,9 +95,9 @@ test.describe('Admin Applications', () => {
adminApplicationSettingsPage.disableConnectionsSwitch adminApplicationSettingsPage.disableConnectionsSwitch
).not.toBeChecked(); ).not.toBeChecked();
await adminApplicationAuthClientsPage.openAuthClientsTab(); await adminApplicationOAuthClientsPage.openAuthClientsTab();
await expect( await expect(
adminApplicationAuthClientsPage.createFirstAuthClientButton adminApplicationOAuthClientsPage.createFirstAuthClientButton
).toHaveCount(1); ).toHaveCount(1);
await page.goto('/'); await page.goto('/');
@@ -117,9 +117,9 @@ test.describe('Admin Applications', () => {
const newConnectionOption = page const newConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add new connection' }); .filter({ hasText: 'Add new connection' });
const newSharedConnectionOption = page const newOAuthConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add new connection with auth client' }); .filter({ hasText: 'Add connection with OAuth client' });
const existingConnection = page const existingConnection = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Unnamed' }); .filter({ hasText: 'Unnamed' });
@@ -127,13 +127,13 @@ test.describe('Admin Applications', () => {
await expect(await existingConnection.count()).toBeGreaterThan(0); await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect(newConnectionOption).toBeEnabled(); await expect(newConnectionOption).toBeEnabled();
await expect(newConnectionOption).toHaveCount(1); await expect(newConnectionOption).toHaveCount(1);
await expect(newSharedConnectionOption).toHaveCount(0); await expect(newOAuthConnectionOption).toHaveCount(0);
}); });
test('should allow only predefined connections and existing custom', async ({ test('should allow only predefined connections and existing custom', async ({
adminApplicationsPage, adminApplicationsPage,
adminApplicationSettingsPage, adminApplicationSettingsPage,
adminApplicationAuthClientsPage, adminApplicationOAuthClientsPage,
flowEditorPage, flowEditorPage,
page, page,
}) => { }) => {
@@ -153,8 +153,8 @@ test.describe('Admin Applications', () => {
await adminApplicationSettingsPage.saveSettings(); await adminApplicationSettingsPage.saveSettings();
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible(); await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
await adminApplicationAuthClientsPage.openAuthClientsTab(); await adminApplicationOAuthClientsPage.openAuthClientsTab();
await adminApplicationAuthClientsPage.openFirstAuthClientCreateForm(); await adminApplicationOAuthClientsPage.openFirstAuthClientCreateForm();
const authClientForm = page.getByTestId('auth-client-form'); const authClientForm = page.getByTestId('auth-client-form');
await authClientForm.locator(page.getByTestId('switch')).check(); await authClientForm.locator(page.getByTestId('switch')).check();
await authClientForm await authClientForm
@@ -166,8 +166,8 @@ test.describe('Admin Applications', () => {
await authClientForm await authClientForm
.locator(page.locator('[name="clientSecret"]')) .locator(page.locator('[name="clientSecret"]'))
.fill('spotifyClientSecret'); .fill('spotifyClientSecret');
await adminApplicationAuthClientsPage.submitAuthClientForm(); await adminApplicationOAuthClientsPage.submitAuthClientForm();
await adminApplicationAuthClientsPage.authClientShouldBeVisible( await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
'spotifyAuthClient' 'spotifyAuthClient'
); );
@@ -187,23 +187,23 @@ test.describe('Admin Applications', () => {
const newConnectionOption = page const newConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add new connection' }); .filter({ hasText: 'Add new connection' });
const newSharedConnectionOption = page const newOAuthConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add connection with auth client' }); .filter({ hasText: 'Add connection with OAuth client' });
const existingConnection = page const existingConnection = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Unnamed' }); .filter({ hasText: 'Unnamed' });
await expect(await existingConnection.count()).toBeGreaterThan(0); await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect(newConnectionOption).toHaveCount(0); await expect(newConnectionOption).toHaveCount(0);
await expect(newSharedConnectionOption).toBeEnabled(); await expect(newOAuthConnectionOption).toBeEnabled();
await expect(newSharedConnectionOption).toHaveCount(1); await expect(newOAuthConnectionOption).toHaveCount(1);
}); });
test('should allow all connections', async ({ test('should allow all connections', async ({
adminApplicationsPage, adminApplicationsPage,
adminApplicationSettingsPage, adminApplicationSettingsPage,
adminApplicationAuthClientsPage, adminApplicationOAuthClientsPage,
flowEditorPage, flowEditorPage,
page, page,
}) => { }) => {
@@ -219,8 +219,8 @@ test.describe('Admin Applications', () => {
adminApplicationSettingsPage.disableConnectionsSwitch adminApplicationSettingsPage.disableConnectionsSwitch
).not.toBeChecked(); ).not.toBeChecked();
await adminApplicationAuthClientsPage.openAuthClientsTab(); await adminApplicationOAuthClientsPage.openAuthClientsTab();
await adminApplicationAuthClientsPage.openFirstAuthClientCreateForm(); await adminApplicationOAuthClientsPage.openFirstAuthClientCreateForm();
const authClientForm = page.getByTestId('auth-client-form'); const authClientForm = page.getByTestId('auth-client-form');
await authClientForm.locator(page.getByTestId('switch')).check(); await authClientForm.locator(page.getByTestId('switch')).check();
await authClientForm await authClientForm
@@ -232,8 +232,8 @@ test.describe('Admin Applications', () => {
await authClientForm await authClientForm
.locator(page.locator('[name="clientSecret"]')) .locator(page.locator('[name="clientSecret"]'))
.fill('redditClientSecret'); .fill('redditClientSecret');
await adminApplicationAuthClientsPage.submitAuthClientForm(); await adminApplicationOAuthClientsPage.submitAuthClientForm();
await adminApplicationAuthClientsPage.authClientShouldBeVisible( await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
'redditAuthClient' 'redditAuthClient'
); );
@@ -253,23 +253,23 @@ test.describe('Admin Applications', () => {
const newConnectionOption = page const newConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add new connection' }); .filter({ hasText: 'Add new connection' });
const newSharedConnectionOption = page const newOAuthConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add connection with auth client' }); .filter({ hasText: 'Add connection with OAuth client' });
const existingConnection = page const existingConnection = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Unnamed' }); .filter({ hasText: 'Unnamed' });
await expect(await existingConnection.count()).toBeGreaterThan(0); await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect(newConnectionOption).toHaveCount(1); await expect(newConnectionOption).toHaveCount(1);
await expect(newSharedConnectionOption).toBeEnabled(); await expect(newOAuthConnectionOption).toBeEnabled();
await expect(newSharedConnectionOption).toHaveCount(1); await expect(newOAuthConnectionOption).toHaveCount(1);
}); });
test('should not allow new connections but existing custom', async ({ test('should not allow new connections but existing custom', async ({
adminApplicationsPage, adminApplicationsPage,
adminApplicationSettingsPage, adminApplicationSettingsPage,
adminApplicationAuthClientsPage, adminApplicationOAuthClientsPage,
flowEditorPage, flowEditorPage,
page, page,
}) => { }) => {
@@ -282,8 +282,8 @@ test.describe('Admin Applications', () => {
await adminApplicationSettingsPage.saveSettings(); await adminApplicationSettingsPage.saveSettings();
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible(); await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
await adminApplicationAuthClientsPage.openAuthClientsTab(); await adminApplicationOAuthClientsPage.openAuthClientsTab();
await adminApplicationAuthClientsPage.openFirstAuthClientCreateForm(); await adminApplicationOAuthClientsPage.openFirstAuthClientCreateForm();
const authClientForm = page.getByTestId('auth-client-form'); const authClientForm = page.getByTestId('auth-client-form');
await authClientForm.locator(page.getByTestId('switch')).check(); await authClientForm.locator(page.getByTestId('switch')).check();
@@ -296,8 +296,8 @@ test.describe('Admin Applications', () => {
await authClientForm await authClientForm
.locator(page.locator('[name="clientSecret"]')) .locator(page.locator('[name="clientSecret"]'))
.fill('clickupClientSecret'); .fill('clickupClientSecret');
await adminApplicationAuthClientsPage.submitAuthClientForm(); await adminApplicationOAuthClientsPage.submitAuthClientForm();
await adminApplicationAuthClientsPage.authClientShouldBeVisible( await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
'clickupAuthClient' 'clickupAuthClient'
); );
@@ -317,22 +317,22 @@ test.describe('Admin Applications', () => {
const newConnectionOption = page const newConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add new connection' }); .filter({ hasText: 'Add new connection' });
const newSharedConnectionOption = page const newOAuthConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add connection with auth client' }); .filter({ hasText: 'Add connection with OAuth client' });
const existingConnection = page const existingConnection = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Unnamed' }); .filter({ hasText: 'Unnamed' });
await expect(await existingConnection.count()).toBeGreaterThan(0); await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect(newConnectionOption).toHaveCount(0); await expect(newConnectionOption).toHaveCount(0);
await expect(newSharedConnectionOption).toHaveCount(0); await expect(newOAuthConnectionOption).toHaveCount(0);
}); });
test('should not allow new connections but existing custom even if predefined auth clients are enabled', async ({ test('should not allow new connections but existing custom even if predefined OAuth clients are enabled', async ({
adminApplicationsPage, adminApplicationsPage,
adminApplicationSettingsPage, adminApplicationSettingsPage,
adminApplicationAuthClientsPage, adminApplicationOAuthClientsPage,
flowEditorPage, flowEditorPage,
page, page,
}) => { }) => {
@@ -348,8 +348,8 @@ test.describe('Admin Applications', () => {
await adminApplicationSettingsPage.saveSettings(); await adminApplicationSettingsPage.saveSettings();
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible(); await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
await adminApplicationAuthClientsPage.openAuthClientsTab(); await adminApplicationOAuthClientsPage.openAuthClientsTab();
await adminApplicationAuthClientsPage.openFirstAuthClientCreateForm(); await adminApplicationOAuthClientsPage.openFirstAuthClientCreateForm();
const authClientForm = page.getByTestId('auth-client-form'); const authClientForm = page.getByTestId('auth-client-form');
await authClientForm.locator(page.getByTestId('switch')).check(); await authClientForm.locator(page.getByTestId('switch')).check();
@@ -362,8 +362,8 @@ test.describe('Admin Applications', () => {
await authClientForm await authClientForm
.locator(page.locator('[name="clientSecret"]')) .locator(page.locator('[name="clientSecret"]'))
.fill('mailchimpClientSecret'); .fill('mailchimpClientSecret');
await adminApplicationAuthClientsPage.submitAuthClientForm(); await adminApplicationOAuthClientsPage.submitAuthClientForm();
await adminApplicationAuthClientsPage.authClientShouldBeVisible( await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
'mailchimpAuthClient' 'mailchimpAuthClient'
); );
@@ -387,9 +387,9 @@ test.describe('Admin Applications', () => {
const newConnectionOption = page const newConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add new connection' }); .filter({ hasText: 'Add new connection' });
const newSharedConnectionOption = page const newOAuthConnectionOption = page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'Add new shared connection' }); .filter({ hasText: 'Add connection with OAuth client' });
const noConnectionsOption = page const noConnectionsOption = page
.locator('.MuiAutocomplete-noOptions') .locator('.MuiAutocomplete-noOptions')
.filter({ hasText: 'No options' }); .filter({ hasText: 'No options' });
@@ -397,6 +397,6 @@ test.describe('Admin Applications', () => {
await expect(await existingConnection.count()).toBeGreaterThan(0); await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect(noConnectionsOption).toHaveCount(0); await expect(noConnectionsOption).toHaveCount(0);
await expect(newConnectionOption).toHaveCount(0); await expect(newConnectionOption).toHaveCount(0);
await expect(newSharedConnectionOption).toHaveCount(0); await expect(newOAuthConnectionOption).toHaveCount(0);
}); });
}); });

View File

@@ -55,7 +55,7 @@ test.describe('Apps page', () => {
test('goes to app page to create a connection', async ({ test('goes to app page to create a connection', async ({
applicationsPage, applicationsPage,
}) => { }) => {
// loading app, app config, app auth clients take time // loading app, app config, app oauth clients take time
test.setTimeout(60000); test.setTimeout(60000);
await applicationsPage.page.getByTestId('app-list-item').first().click(); await applicationsPage.page.getByTestId('app-list-item').first().click();