test: add accept invitation invalid token tests
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// @ts-check
|
||||
const { test, expect } = require('../../fixtures/index');
|
||||
|
||||
test.describe('Apps page', () => {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
// @ts-check
|
||||
const { publicTest, test, expect } = require('../../fixtures/index');
|
||||
const { publicTest, expect } = require('../../fixtures/index');
|
||||
|
||||
publicTest.describe('Login page', () => {
|
||||
publicTest('shows login form', async ({ loginPage }) => {
|
||||
|
@@ -1,8 +1,7 @@
|
||||
// @ts-check
|
||||
const { test, expect } = require('../../fixtures/index');
|
||||
|
||||
test.describe('Connections page', () => {
|
||||
test.beforeEach(async ({ page, connectionsPage }) => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.getByTestId('apps-page-drawer-link').click();
|
||||
await page.goto('/app/ntfy/connections');
|
||||
});
|
||||
|
@@ -1,4 +1,3 @@
|
||||
// @ts-check
|
||||
const { test, expect } = require('../../fixtures/index');
|
||||
|
||||
// no execution data exists in an empty account
|
||||
|
@@ -1,8 +1,7 @@
|
||||
// @ts-check
|
||||
const { test, expect } = require('../../fixtures/index');
|
||||
|
||||
test.describe('Executions page', () => {
|
||||
test.beforeEach(async ({ page, executionsPage }) => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.getByTestId('executions-page-drawer-link').click();
|
||||
});
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
// @ts-check
|
||||
const { test, expect } = require('../../fixtures/index');
|
||||
|
||||
test('Ensure creating a new flow works', async ({ page }) => {
|
||||
|
@@ -1,4 +1,3 @@
|
||||
// @ts-check
|
||||
const { test, expect } = require('../../fixtures/index');
|
||||
|
||||
test.describe('User interface page', () => {
|
||||
|
62
packages/e2e-tests/tests/user-invitation/invitation.spec.js
Normal file
62
packages/e2e-tests/tests/user-invitation/invitation.spec.js
Normal file
@@ -0,0 +1,62 @@
|
||||
const { AdminCreateUserPage } = require('../../fixtures/admin/create-user-page');
|
||||
const { publicTest, expect } = require('../../fixtures/index');
|
||||
const { client } = require('../../fixtures/postgres-client-config');
|
||||
const { DateTime } = require('luxon');
|
||||
|
||||
publicTest.describe('Accept invitation page', () => {
|
||||
publicTest.beforeAll(async () => {
|
||||
await client.connect();
|
||||
});
|
||||
|
||||
publicTest.afterAll(async () => {
|
||||
await client.end();
|
||||
});
|
||||
|
||||
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 expired', async ({ acceptInvitationPage, page }) => {
|
||||
const expiredTokenDate = DateTime.now().minus({days: 3}).toISO();
|
||||
const expiredToken = (Math.random() + 1).toString(36).substring(2);
|
||||
|
||||
const adminCreateUserPage = new AdminCreateUserPage(page);
|
||||
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 client.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', expiredToken, expiredTokenDate],
|
||||
};
|
||||
|
||||
const insertUserResult = await client.query(insertUser);
|
||||
expect(insertUserResult.rowCount).toBe(1);
|
||||
expect(insertUserResult.command).toBe('INSERT');
|
||||
} catch (err) {
|
||||
console.error(err.message);
|
||||
throw err;
|
||||
}
|
||||
|
||||
await acceptInvitationPage.open(expiredToken);
|
||||
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();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user