Merge pull request #2424 from automatisch/tests-improvements-for-windows-os

test: improvements for windows os execution
This commit is contained in:
Ali BARIN
2025-04-01 14:11:09 +02:00
committed by GitHub
4 changed files with 103 additions and 71 deletions

View File

@@ -40,7 +40,12 @@ export class AdminApplicationSettingsPage extends AuthenticatedPage {
}
async saveSettings() {
await this.saveButton.click();
await Promise.all([
this.page.waitForResponse(
(resp) => resp.url().includes('/config') && resp.status() === 200
),
this.saveButton.click(),
]);
}
async expectOnlyOneSuccessSnackbarToBeVisible() {

View File

@@ -126,7 +126,7 @@ test.describe('Admin Applications', () => {
.getByRole('option')
.filter({ hasText: 'Unnamed' });
await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect.poll(() => existingConnection.count()).toBeGreaterThan(0);
await expect(newConnectionOption).toBeEnabled();
await expect(newConnectionOption).toHaveCount(1);
await expect(newOAuthConnectionOption).toHaveCount(0);
@@ -197,7 +197,7 @@ test.describe('Admin Applications', () => {
.getByRole('option')
.filter({ hasText: 'Unnamed' });
await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect.poll(() => existingConnection.count()).toBeGreaterThan(0);
await expect(newConnectionOption).toHaveCount(0);
await expect(newOAuthConnectionOption).toBeEnabled();
await expect(newOAuthConnectionOption).toHaveCount(1);
@@ -266,7 +266,7 @@ test.describe('Admin Applications', () => {
.getByRole('option')
.filter({ hasText: 'Unnamed' });
await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect.poll(() => existingConnection.count()).toBeGreaterThan(0);
await expect(newConnectionOption).toHaveCount(1);
await expect(newOAuthConnectionOption).toBeEnabled();
await expect(newOAuthConnectionOption).toHaveCount(1);
@@ -331,7 +331,7 @@ test.describe('Admin Applications', () => {
.getByRole('option')
.filter({ hasText: 'Unnamed' });
await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect.poll(() => existingConnection.count()).toBeGreaterThan(0);
await expect(newConnectionOption).toHaveCount(0);
await expect(newOAuthConnectionOption).toHaveCount(0);
});
@@ -402,7 +402,7 @@ test.describe('Admin Applications', () => {
.locator('.MuiAutocomplete-noOptions')
.filter({ hasText: 'No options' });
await expect(await existingConnection.count()).toBeGreaterThan(0);
await expect.poll(() => existingConnection.count()).toBeGreaterThan(0);
await expect(noConnectionsOption).toHaveCount(0);
await expect(newConnectionOption).toHaveCount(0);
await expect(newOAuthConnectionOption).toHaveCount(0);

View File

@@ -88,7 +88,6 @@ test.describe('User management page', () => {
adminCreateUserPage.seed(9100);
const testUser = adminCreateUserPage.generateUser();
await test.step('Create the test user', async () => {
await adminUsersPage.navigateTo();
await adminUsersPage.createUserButton.click();
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
await adminCreateUserPage.emailInput.fill(testUser.email);
@@ -174,7 +173,6 @@ test.describe('User management page', () => {
const user1 = adminCreateUserPage.generateUser();
const user2 = adminCreateUserPage.generateUser();
await test.step('Create the first user', async () => {
await adminUsersPage.navigateTo();
await adminUsersPage.createUserButton.click();
await adminCreateUserPage.fullNameInput.fill(user1.fullName);
await adminCreateUserPage.emailInput.fill(user1.email);

View File

@@ -3,82 +3,111 @@ const { pgPool } = require('../../fixtures/postgres-config');
const { DateTime } = require('luxon');
publicTest.describe('Accept invitation page', () => {
publicTest('should not be able to set the password if token is empty', async ({ acceptInvitationPage }) => {
await acceptInvitationPage.open('');
await acceptInvitationPage.excpectSubmitButtonToBeDisabled();
await acceptInvitationPage.fillPasswordField('something');
await acceptInvitationPage.excpectSubmitButtonToBeDisabled();
});
publicTest(
'should not be able to set the password if token is empty',
async ({ acceptInvitationPage }) => {
await acceptInvitationPage.open('');
await acceptInvitationPage.excpectSubmitButtonToBeDisabled();
await acceptInvitationPage.fillPasswordField('something');
await acceptInvitationPage.excpectSubmitButtonToBeDisabled();
}
);
publicTest('should not be able to set the password if token is not in db', async ({ acceptInvitationPage }) => {
await acceptInvitationPage.open('abc');
await acceptInvitationPage.acceptInvitation('something');
await acceptInvitationPage.expectAlertToBeVisible();
});
publicTest(
'should not be able to set the password if token is not in db',
async ({ acceptInvitationPage }) => {
await acceptInvitationPage.open('abc');
await acceptInvitationPage.acceptInvitation('something');
await acceptInvitationPage.expectAlertToBeVisible();
}
);
publicTest.describe('Accept invitation page - users', () => {
const expiredTokenDate = DateTime.now().minus({ days: 3 }).toISO();
const expiredTokenDate = DateTime.now().minus({ days: 4 }).toISO();
const token = (Math.random() + 1).toString(36).substring(2);
publicTest('should not be able to set the password if token is expired', async ({ acceptInvitationPage, adminCreateUserPage }) => {
adminCreateUserPage.seed(Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER));
const user = adminCreateUserPage.generateUser();
publicTest(
'should not be able to set the password if token is expired',
async ({ acceptInvitationPage, adminCreateUserPage }) => {
adminCreateUserPage.seed(
Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)
);
const user = adminCreateUserPage.generateUser();
const queryRole = {
text: 'SELECT * FROM roles WHERE name = $1',
values: ['Admin']
};
try {
const queryRoleIdResult = await pgPool.query(queryRole);
expect(queryRoleIdResult.rowCount).toEqual(1);
const insertUser = {
text: 'INSERT INTO users (email, full_name, role_id, status, invitation_token, invitation_token_sent_at) VALUES ($1, $2, $3, $4, $5, $6)',
values: [user.email, user.fullName, queryRoleIdResult.rows[0].id, 'invited', token, expiredTokenDate],
const queryRole = {
text: 'SELECT * FROM roles WHERE name = $1',
values: ['Admin'],
};
const insertUserResult = await pgPool.query(insertUser);
expect(insertUserResult.rowCount).toBe(1);
expect(insertUserResult.command).toBe('INSERT');
} catch (err) {
console.error(err.message);
throw err;
try {
const queryRoleIdResult = await pgPool.query(queryRole);
expect(queryRoleIdResult.rowCount).toEqual(1);
const insertUser = {
text: 'INSERT INTO users (email, full_name, role_id, status, invitation_token, invitation_token_sent_at) VALUES ($1, $2, $3, $4, $5, $6)',
values: [
user.email,
user.fullName,
queryRoleIdResult.rows[0].id,
'invited',
token,
expiredTokenDate,
],
};
const insertUserResult = await pgPool.query(insertUser);
expect(insertUserResult.rowCount).toBe(1);
expect(insertUserResult.command).toBe('INSERT');
} catch (err) {
console.error(err.message);
throw err;
}
await acceptInvitationPage.open(token);
await acceptInvitationPage.acceptInvitation('something');
await acceptInvitationPage.expectAlertToBeVisible();
}
await acceptInvitationPage.open(token);
await acceptInvitationPage.acceptInvitation('something');
await acceptInvitationPage.expectAlertToBeVisible();
});
);
publicTest('should not be able to accept invitation if user was soft deleted', async ({ acceptInvitationPage, adminCreateUserPage }) => {
const dateNow = DateTime.now().toISO();
const user = adminCreateUserPage.generateUser();
publicTest(
'should not be able to accept invitation if user was soft deleted',
async ({ acceptInvitationPage, adminCreateUserPage }) => {
const dateNow = DateTime.now().toISO();
const user = adminCreateUserPage.generateUser();
const queryRole = {
text: 'SELECT * FROM roles WHERE name = $1',
values: ['Admin']
};
try {
const queryRoleIdResult = await pgPool.query(queryRole);
expect(queryRoleIdResult.rowCount).toEqual(1);
const insertUser = {
text: 'INSERT INTO users (email, full_name, deleted_at, role_id, status, invitation_token, invitation_token_sent_at) VALUES ($1, $2, $3, $4, $5, $6, $7)',
values: [user.email, user.fullName, dateNow, queryRoleIdResult.rows[0].id, 'invited', token, dateNow],
const queryRole = {
text: 'SELECT * FROM roles WHERE name = $1',
values: ['Admin'],
};
const insertUserResult = await pgPool.query(insertUser);
expect(insertUserResult.rowCount).toBe(1);
expect(insertUserResult.command).toBe('INSERT');
} catch (err) {
console.error(err.message);
throw err;
}
try {
const queryRoleIdResult = await pgPool.query(queryRole);
expect(queryRoleIdResult.rowCount).toEqual(1);
await acceptInvitationPage.open(token);
await acceptInvitationPage.acceptInvitation('something');
await acceptInvitationPage.expectAlertToBeVisible();
});
const insertUser = {
text: 'INSERT INTO users (email, full_name, deleted_at, role_id, status, invitation_token, invitation_token_sent_at) VALUES ($1, $2, $3, $4, $5, $6, $7)',
values: [
user.email,
user.fullName,
dateNow,
queryRoleIdResult.rows[0].id,
'invited',
token,
dateNow,
],
};
const insertUserResult = await pgPool.query(insertUser);
expect(insertUserResult.rowCount).toBe(1);
expect(insertUserResult.command).toBe('INSERT');
} catch (err) {
console.error(err.message);
throw err;
}
await acceptInvitationPage.open(token);
await acceptInvitationPage.acceptInvitation('something');
await acceptInvitationPage.expectAlertToBeVisible();
}
);
});
});