1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

chore: remove e2e that is not needed anymore (#7124)

We talked with @nunogois that this test is testing migration from 2023,
but time has passed and the migration is working properly, so we think
to cut down on test run time, we can remove it.
This commit is contained in:
Jaanus Sellin 2024-05-23 12:49:12 +03:00 committed by GitHub
parent c4566baeac
commit d9e631c326
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 899 deletions

View File

@ -1,736 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Favor permission name over id migration correctly assigns permissions by name 1`] = `
[
{
"display_name": "A test permission",
"permission": "TEST_PERMISSION_1",
"type": "root",
},
{
"display_name": "A test permission",
"permission": "TEST_PERMISSION_2",
"type": "root",
},
{
"display_name": "A test permission",
"permission": "TEST_PERMISSION_3",
"type": "root",
},
{
"display_name": "A test permission",
"permission": "TEST_PERMISSION_4",
"type": "root",
},
{
"display_name": "Admin",
"permission": "ADMIN",
"type": "root",
},
{
"display_name": "Create feature toggles",
"permission": "CREATE_FEATURE",
"type": "project",
},
{
"display_name": "Create activation strategies",
"permission": "CREATE_STRATEGY",
"type": "root",
},
{
"display_name": "Create addons",
"permission": "CREATE_ADDON",
"type": "root",
},
{
"display_name": "Delete addons",
"permission": "DELETE_ADDON",
"type": "root",
},
{
"display_name": "Update addons",
"permission": "UPDATE_ADDON",
"type": "root",
},
{
"display_name": "Update feature toggles",
"permission": "UPDATE_FEATURE",
"type": "project",
},
{
"display_name": "Delete feature toggles",
"permission": "DELETE_FEATURE",
"type": "project",
},
{
"display_name": "Update applications",
"permission": "UPDATE_APPLICATION",
"type": "root",
},
{
"display_name": "Update tag types",
"permission": "UPDATE_TAG_TYPE",
"type": "root",
},
{
"display_name": "Delete tag types",
"permission": "DELETE_TAG_TYPE",
"type": "root",
},
{
"display_name": "Create projects",
"permission": "CREATE_PROJECT",
"type": "root",
},
{
"display_name": "Update project",
"permission": "UPDATE_PROJECT",
"type": "project",
},
{
"display_name": "Delete project",
"permission": "DELETE_PROJECT",
"type": "project",
},
{
"display_name": "Update strategies",
"permission": "UPDATE_STRATEGY",
"type": "root",
},
{
"display_name": "Delete strategies",
"permission": "DELETE_STRATEGY",
"type": "root",
},
{
"display_name": "Update context fields",
"permission": "UPDATE_CONTEXT_FIELD",
"type": "root",
},
{
"display_name": "Create context fields",
"permission": "CREATE_CONTEXT_FIELD",
"type": "root",
},
{
"display_name": "Delete context fields",
"permission": "DELETE_CONTEXT_FIELD",
"type": "root",
},
{
"display_name": "Read roles",
"permission": "READ_ROLE",
"type": "root",
},
{
"display_name": "Create activation strategies",
"permission": "CREATE_FEATURE_STRATEGY",
"type": "environment",
},
{
"display_name": "Update activation strategies",
"permission": "UPDATE_FEATURE_STRATEGY",
"type": "environment",
},
{
"display_name": "Delete activation strategies",
"permission": "DELETE_FEATURE_STRATEGY",
"type": "environment",
},
{
"display_name": "Create CLIENT API tokens",
"permission": "CREATE_CLIENT_API_TOKEN",
"type": "root",
},
{
"display_name": "Create/edit variants",
"permission": "UPDATE_FEATURE_VARIANTS",
"type": "project",
},
{
"display_name": "Change feature toggle project",
"permission": "MOVE_FEATURE_TOGGLE",
"type": "project",
},
{
"display_name": "Create segments",
"permission": "CREATE_SEGMENT",
"type": "root",
},
{
"display_name": "Edit segments",
"permission": "UPDATE_SEGMENT",
"type": "root",
},
{
"display_name": "Delete segments",
"permission": "DELETE_SEGMENT",
"type": "root",
},
{
"display_name": "Read api tokens for a specific project",
"permission": "READ_PROJECT_API_TOKEN",
"type": "project",
},
{
"display_name": "Create api tokens for a specific project",
"permission": "CREATE_PROJECT_API_TOKEN",
"type": "project",
},
{
"display_name": "Delete api tokens for a specific project",
"permission": "DELETE_PROJECT_API_TOKEN",
"type": "project",
},
{
"display_name": "Update variants",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"type": "environment",
},
{
"display_name": "Enable/disable toggles",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"type": "environment",
},
{
"display_name": "Apply change requests",
"permission": "APPLY_CHANGE_REQUEST",
"type": "environment",
},
{
"display_name": "Update CLIENT API tokens",
"permission": "UPDATE_CLIENT_API_TOKEN",
"type": "root",
},
{
"display_name": "Create/edit project segment",
"permission": "UPDATE_PROJECT_SEGMENT",
"type": "project",
},
{
"display_name": "Skip change request process",
"permission": "SKIP_CHANGE_REQUEST",
"type": "environment",
},
{
"display_name": "Delete CLIENT API tokens",
"permission": "DELETE_CLIENT_API_TOKEN",
"type": "root",
},
{
"display_name": "Read CLIENT API tokens",
"permission": "READ_CLIENT_API_TOKEN",
"type": "root",
},
{
"display_name": "Approve/Reject change requests",
"permission": "APPROVE_CHANGE_REQUEST",
"type": "environment",
},
{
"display_name": "Create FRONTEND API tokens",
"permission": "CREATE_FRONTEND_API_TOKEN",
"type": "root",
},
{
"display_name": "Update FRONTEND API tokens",
"permission": "UPDATE_FRONTEND_API_TOKEN",
"type": "root",
},
{
"display_name": "Delete FRONTEND API tokens",
"permission": "DELETE_FRONTEND_API_TOKEN",
"type": "root",
},
{
"display_name": "Read FRONTEND API tokens",
"permission": "READ_FRONTEND_API_TOKEN",
"type": "root",
},
{
"display_name": "Update feature dependency",
"permission": "UPDATE_FEATURE_DEPENDENCY",
"type": "project",
},
{
"display_name": "Create tag types",
"permission": "CREATE_TAG_TYPE",
"type": "root",
},
]
`;
exports[`Favor permission name over id migration correctly assigns permissions by name 2`] = `
[
{
"environment": null,
"permission": "ADMIN",
"role_id": 6,
},
{
"environment": null,
"permission": "CREATE_FEATURE",
"role_id": 7,
},
{
"environment": null,
"permission": "CREATE_STRATEGY",
"role_id": 7,
},
{
"environment": null,
"permission": "CREATE_ADDON",
"role_id": 7,
},
{
"environment": null,
"permission": "DELETE_ADDON",
"role_id": 7,
},
{
"environment": null,
"permission": "UPDATE_ADDON",
"role_id": 7,
},
{
"environment": null,
"permission": "UPDATE_FEATURE",
"role_id": 7,
},
{
"environment": null,
"permission": "DELETE_FEATURE",
"role_id": 7,
},
{
"environment": null,
"permission": "UPDATE_APPLICATION",
"role_id": 7,
},
{
"environment": null,
"permission": "UPDATE_TAG_TYPE",
"role_id": 7,
},
{
"environment": null,
"permission": "DELETE_TAG_TYPE",
"role_id": 7,
},
{
"environment": null,
"permission": "CREATE_PROJECT",
"role_id": 7,
},
{
"environment": null,
"permission": "UPDATE_PROJECT",
"role_id": 7,
},
{
"environment": null,
"permission": "DELETE_PROJECT",
"role_id": 7,
},
{
"environment": null,
"permission": "UPDATE_STRATEGY",
"role_id": 7,
},
{
"environment": null,
"permission": "DELETE_STRATEGY",
"role_id": 7,
},
{
"environment": null,
"permission": "UPDATE_CONTEXT_FIELD",
"role_id": 7,
},
{
"environment": null,
"permission": "CREATE_CONTEXT_FIELD",
"role_id": 7,
},
{
"environment": null,
"permission": "DELETE_CONTEXT_FIELD",
"role_id": 7,
},
{
"environment": null,
"permission": "UPDATE_FEATURE_VARIANTS",
"role_id": 7,
},
{
"environment": "default",
"permission": "CREATE_FEATURE_STRATEGY",
"role_id": 7,
},
{
"environment": "development",
"permission": "CREATE_FEATURE_STRATEGY",
"role_id": 7,
},
{
"environment": "production",
"permission": "CREATE_FEATURE_STRATEGY",
"role_id": 7,
},
{
"environment": "default",
"permission": "UPDATE_FEATURE_STRATEGY",
"role_id": 7,
},
{
"environment": "development",
"permission": "UPDATE_FEATURE_STRATEGY",
"role_id": 7,
},
{
"environment": "production",
"permission": "UPDATE_FEATURE_STRATEGY",
"role_id": 7,
},
{
"environment": "default",
"permission": "DELETE_FEATURE_STRATEGY",
"role_id": 7,
},
{
"environment": "development",
"permission": "DELETE_FEATURE_STRATEGY",
"role_id": 7,
},
{
"environment": "production",
"permission": "DELETE_FEATURE_STRATEGY",
"role_id": 7,
},
{
"environment": "default",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"role_id": 7,
},
{
"environment": "development",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"role_id": 7,
},
{
"environment": "production",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"role_id": 7,
},
{
"environment": "default",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"role_id": 7,
},
{
"environment": "development",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"role_id": 7,
},
{
"environment": "production",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"role_id": 7,
},
{
"environment": null,
"permission": "MOVE_FEATURE_TOGGLE",
"role_id": 7,
},
{
"environment": null,
"permission": "CREATE_SEGMENT",
"role_id": 7,
},
{
"environment": null,
"permission": "UPDATE_SEGMENT",
"role_id": 7,
},
{
"environment": null,
"permission": "DELETE_SEGMENT",
"role_id": 7,
},
{
"environment": null,
"permission": "READ_PROJECT_API_TOKEN",
"role_id": 7,
},
{
"environment": null,
"permission": "CREATE_PROJECT_API_TOKEN",
"role_id": 7,
},
{
"environment": null,
"permission": "DELETE_PROJECT_API_TOKEN",
"role_id": 7,
},
{
"environment": null,
"permission": "READ_CLIENT_API_TOKEN",
"role_id": 7,
},
{
"environment": null,
"permission": "READ_FRONTEND_API_TOKEN",
"role_id": 7,
},
{
"environment": null,
"permission": "CREATE_TAG_TYPE",
"role_id": 7,
},
{
"environment": null,
"permission": "CREATE_FEATURE",
"role_id": 9,
},
{
"environment": null,
"permission": "UPDATE_FEATURE",
"role_id": 9,
},
{
"environment": null,
"permission": "DELETE_FEATURE",
"role_id": 9,
},
{
"environment": null,
"permission": "UPDATE_PROJECT",
"role_id": 9,
},
{
"environment": null,
"permission": "DELETE_PROJECT",
"role_id": 9,
},
{
"environment": null,
"permission": "UPDATE_FEATURE_VARIANTS",
"role_id": 9,
},
{
"environment": "default",
"permission": "CREATE_FEATURE_STRATEGY",
"role_id": 9,
},
{
"environment": "development",
"permission": "CREATE_FEATURE_STRATEGY",
"role_id": 9,
},
{
"environment": "production",
"permission": "CREATE_FEATURE_STRATEGY",
"role_id": 9,
},
{
"environment": "default",
"permission": "UPDATE_FEATURE_STRATEGY",
"role_id": 9,
},
{
"environment": "development",
"permission": "UPDATE_FEATURE_STRATEGY",
"role_id": 9,
},
{
"environment": "production",
"permission": "UPDATE_FEATURE_STRATEGY",
"role_id": 9,
},
{
"environment": "default",
"permission": "DELETE_FEATURE_STRATEGY",
"role_id": 9,
},
{
"environment": "development",
"permission": "DELETE_FEATURE_STRATEGY",
"role_id": 9,
},
{
"environment": "production",
"permission": "DELETE_FEATURE_STRATEGY",
"role_id": 9,
},
{
"environment": "default",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"role_id": 9,
},
{
"environment": "development",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"role_id": 9,
},
{
"environment": "production",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"role_id": 9,
},
{
"environment": "default",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"role_id": 9,
},
{
"environment": "development",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"role_id": 9,
},
{
"environment": "production",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"role_id": 9,
},
{
"environment": null,
"permission": "MOVE_FEATURE_TOGGLE",
"role_id": 9,
},
{
"environment": null,
"permission": "READ_PROJECT_API_TOKEN",
"role_id": 9,
},
{
"environment": null,
"permission": "CREATE_PROJECT_API_TOKEN",
"role_id": 9,
},
{
"environment": null,
"permission": "DELETE_PROJECT_API_TOKEN",
"role_id": 9,
},
{
"environment": null,
"permission": "UPDATE_FEATURE_DEPENDENCY",
"role_id": 9,
},
{
"environment": null,
"permission": "CREATE_FEATURE",
"role_id": 10,
},
{
"environment": null,
"permission": "UPDATE_FEATURE",
"role_id": 10,
},
{
"environment": null,
"permission": "DELETE_FEATURE",
"role_id": 10,
},
{
"environment": null,
"permission": "UPDATE_FEATURE_VARIANTS",
"role_id": 10,
},
{
"environment": "default",
"permission": "CREATE_FEATURE_STRATEGY",
"role_id": 10,
},
{
"environment": "development",
"permission": "CREATE_FEATURE_STRATEGY",
"role_id": 10,
},
{
"environment": "production",
"permission": "CREATE_FEATURE_STRATEGY",
"role_id": 10,
},
{
"environment": "default",
"permission": "UPDATE_FEATURE_STRATEGY",
"role_id": 10,
},
{
"environment": "development",
"permission": "UPDATE_FEATURE_STRATEGY",
"role_id": 10,
},
{
"environment": "production",
"permission": "UPDATE_FEATURE_STRATEGY",
"role_id": 10,
},
{
"environment": "default",
"permission": "DELETE_FEATURE_STRATEGY",
"role_id": 10,
},
{
"environment": "development",
"permission": "DELETE_FEATURE_STRATEGY",
"role_id": 10,
},
{
"environment": "production",
"permission": "DELETE_FEATURE_STRATEGY",
"role_id": 10,
},
{
"environment": "default",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"role_id": 10,
},
{
"environment": "development",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"role_id": 10,
},
{
"environment": "production",
"permission": "UPDATE_FEATURE_ENVIRONMENT",
"role_id": 10,
},
{
"environment": "default",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"role_id": 10,
},
{
"environment": "development",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"role_id": 10,
},
{
"environment": "production",
"permission": "UPDATE_FEATURE_ENVIRONMENT_VARIANTS",
"role_id": 10,
},
{
"environment": null,
"permission": "READ_PROJECT_API_TOKEN",
"role_id": 10,
},
{
"environment": null,
"permission": "CREATE_PROJECT_API_TOKEN",
"role_id": 10,
},
{
"environment": null,
"permission": "DELETE_PROJECT_API_TOKEN",
"role_id": 10,
},
{
"environment": null,
"permission": "UPDATE_FEATURE_DEPENDENCY",
"role_id": 10,
},
]
`;

View File

@ -1,163 +0,0 @@
import { getDbConfig } from './helpers/database-config';
import { createTestConfig } from '../config/test-config';
import { getInstance } from 'db-migrate';
import { log } from 'db-migrate-shared';
import { Client } from 'pg';
import type { IDBOption } from '../../lib/types';
log.setLogLevel('error');
async function initSchema(db: IDBOption): Promise<void> {
const client = new Client(db);
await client.connect();
await client.query(`DROP SCHEMA IF EXISTS ${db.schema} CASCADE`);
await client.query(`CREATE SCHEMA IF NOT EXISTS ${db.schema}`);
await client.end();
}
test('Favor permission name over id migration correctly assigns permissions by name', async () => {
jest.setTimeout(15000);
const config = createTestConfig({
db: {
...getDbConfig(),
pool: { min: 1, max: 4 },
schema: 'favor_permission_name_over_id_test',
ssl: false,
},
});
await initSchema(config.db);
const custom = {
...config.db,
connectionTimeoutMillis: 2000,
};
// disable Intellij/WebStorm from setting verbose CLI argument to db-migrator
process.argv = process.argv.filter((it) => !it.includes('--verbose'));
const dbm = getInstance(true, {
cwd: `${__dirname}/../../`, // relative to src/test/e2e
config: { custom },
env: 'custom',
});
dbm.config.custom = custom;
// Run all migrations up to, and including, this one, the last one before the favor permission name over id migration
await dbm.up('20231123100052-drop-last-seen-foreign-key.js');
// Set up the test data
const client = new Client(config.db);
await client.connect();
await client.query(`
DELETE FROM "favor_permission_name_over_id_test"."roles";
INSERT INTO "favor_permission_name_over_id_test"."roles" (id, name, description, type) VALUES (101, 'Role 1', 'A test role', 'custom');
`);
await client.query(`
DELETE FROM "favor_permission_name_over_id_test"."permissions";
INSERT INTO "favor_permission_name_over_id_test"."permissions" (id, permission, display_name, type) VALUES (101, 'TEST_PERMISSION_1', 'A test permission', 'root');
INSERT INTO "favor_permission_name_over_id_test"."permissions" (id, permission, display_name, type) VALUES (102, 'TEST_PERMISSION_2', 'A test permission', 'root');
INSERT INTO "favor_permission_name_over_id_test"."permissions" (id, permission, display_name, type) VALUES (103, 'TEST_PERMISSION_3', 'A test permission', 'root');
INSERT INTO "favor_permission_name_over_id_test"."permissions" (id, permission, display_name, type) VALUES (104, 'TEST_PERMISSION_4', 'A test permission', 'root');
`);
await client.query(`
DELETE FROM "favor_permission_name_over_id_test"."role_permission";
INSERT INTO "favor_permission_name_over_id_test"."role_permission" (role_id, permission_id) VALUES (101, 101);
INSERT INTO "favor_permission_name_over_id_test"."role_permission" (role_id, permission_id) VALUES (101, 102);
INSERT INTO "favor_permission_name_over_id_test"."role_permission" (role_id, permission_id) VALUES (101, 103);
INSERT INTO "favor_permission_name_over_id_test"."role_permission" (role_id, permission_id) VALUES (101, 104);
`);
// Run the drop permissions id migration
await dbm.up('20231123155649-favor-permission-name-over-id.js');
// Check the results
const { rows: resultsPermissions } = await client.query(`
SELECT * FROM "favor_permission_name_over_id_test"."permissions" ORDER BY created_at;
`);
const { rows: resultsRolePermission } = await client.query(`
SELECT * FROM "favor_permission_name_over_id_test"."role_permission" WHERE role_id = 101 ORDER BY created_at;
`);
// We keep the id for now, but will remove it in the next major version
expect('id' in resultsPermissions[0]).toEqual(true);
expect(
resultsPermissions.map(({ permission, display_name, type }) => ({
permission,
display_name,
type,
})),
).toMatchSnapshot();
// We keep the permission_id for now, but will remove it in the next minor version
expect('permission_id' in resultsRolePermission[0]).toEqual(true);
expect('permission' in resultsRolePermission[0]).toEqual(true);
expect(resultsRolePermission.length).toEqual(4);
expect(
resultsRolePermission.map(({ role_id, permission }) => ({
role_id,
permission,
})),
).toEqual([
{ role_id: 101, permission: 'TEST_PERMISSION_1' },
{ role_id: 101, permission: 'TEST_PERMISSION_2' },
{ role_id: 101, permission: 'TEST_PERMISSION_3' },
{ role_id: 101, permission: 'TEST_PERMISSION_4' },
]);
// Run the toggle to flag update migration
await dbm.up('20240523113322-roles-toggle-to-flag-rename.js');
// Check the results that ensure the default roles exist and have the correct permissions
const { rows: resultsRoles } = await client.query(`
SELECT name, description, type FROM "favor_permission_name_over_id_test"."roles" WHERE id != 101 ORDER BY created_at;
`);
const { rows: resultsDefaultRolePermissions } = await client.query(`
SELECT role_id, environment, permission FROM "favor_permission_name_over_id_test"."role_permission" WHERE role_id != 101 ORDER BY created_at;
`);
expect(resultsRoles.length).toEqual(5);
expect(resultsRoles).toEqual([
{
name: 'Admin',
description:
'Users with the root admin role have superuser access to Unleash and can perform any operation within the Unleash platform.',
type: 'root',
},
{
name: 'Editor',
description:
'Users with the root editor role have access to most features in Unleash, but can not manage users and roles in the root scope. Editors will be added as project owners when creating projects and get superuser rights within the context of these projects. Users with the editor role will also get access to most permissions on the default project by default.',
type: 'root',
},
{
name: 'Viewer',
description:
'Users with the root viewer role can only read root resources in Unleash. Viewers can be added to specific projects as project members. Users with the viewer role may not view API tokens.',
type: 'root',
},
{
name: 'Owner',
description:
'Users with the project owner role have full control over the project, and can add and manage other users within the project context, manage feature flags within the project, and control advanced project features like archiving and deleting the project.',
type: 'project',
},
{
name: 'Member',
description:
"Users with the project member role are allowed to view, create, and update feature flags within a project, but have limited permissions in regards to managing the project's user access and can not archive or delete the project.",
type: 'project',
},
]);
expect(resultsDefaultRolePermissions).toMatchSnapshot();
await client.end();
await dbm.reset();
});