Skip to content

Commit

Permalink
Deprecate name, use slug (cleanId) instead (#5681)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored Oct 17, 2024
1 parent 26d1c74 commit 3cb8861
Show file tree
Hide file tree
Showing 91 changed files with 1,465 additions and 1,285 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ module.exports = {
plugins: ['@graphql-eslint'],
rules: {
'@graphql-eslint/require-id-when-available': 'error',
'@graphql-eslint/no-deprecated': 'error',
},
},
{
Expand Down
27 changes: 18 additions & 9 deletions cypress/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
function randomSlug() {
return Math.random().toString(36).substring(2);
}

const getUser = () =>
({
email: `${crypto.randomUUID()}@local.host`,
Expand Down Expand Up @@ -33,7 +37,8 @@ describe('basic user flow', () => {
it('should log in and log out', () => {
cy.login(user);

cy.get('input[name="name"]').type('Bubatzbieber');
const slug = randomSlug();
cy.get('input[name="slug"]').type(slug);
cy.get('button[type="submit"]').click();

// Logout
Expand All @@ -44,12 +49,13 @@ describe('basic user flow', () => {
});

it('create organization', () => {
const slug = randomSlug();
const user = getUser();
cy.visit('/');
cy.signup(user);
cy.get('input[name="name"]').type('Bubatzbieber');
cy.get('input[name="slug"]').type(slug);
cy.get('button[type="submit"]').click();
cy.get('[data-cy="organization-picker-current"]').contains('Bubatzbieber');
cy.get('[data-cy="organization-picker-current"]').contains(slug);
});

describe('oidc', () => {
Expand All @@ -58,7 +64,8 @@ describe('oidc', () => {
cy.visit('/');
cy.signup(organizationAdminUser);

cy.createOIDCIntegration('Bubatzbieber').then(({ loginUrl }) => {
const slug = randomSlug();
cy.createOIDCIntegration(slug).then(({ loginUrl }) => {
cy.visit('/logout');

cy.clearAllCookies();
Expand All @@ -70,7 +77,7 @@ describe('oidc', () => {
cy.get('input[id="Input_Password"]').type('password');
cy.get('button[value="login"]').click();

cy.get('[data-cy="organization-picker-current"]').contains('Bubatzbieber');
cy.get('[data-cy="organization-picker-current"]').contains(slug);
});
});

Expand All @@ -79,7 +86,8 @@ describe('oidc', () => {
cy.visit('/');
cy.signup(organizationAdminUser);

cy.createOIDCIntegration('Bubatzbieber').then(({ organizationSlug }) => {
const slug = randomSlug();
cy.createOIDCIntegration(slug).then(({ organizationSlug }) => {
cy.visit('/logout');

cy.clearAllCookies();
Expand All @@ -95,7 +103,7 @@ describe('oidc', () => {
cy.get('input[id="Input_Password"]').type('password');
cy.get('button[value="login"]').click();

cy.get('[data-cy="organization-picker-current"]').contains('Bubatzbieber');
cy.get('[data-cy="organization-picker-current"]').contains(slug);
});
});

Expand All @@ -104,7 +112,8 @@ describe('oidc', () => {
cy.visit('/');
cy.signup(organizationAdminUser);

cy.createOIDCIntegration('Bubatzbieber').then(({ organizationSlug }) => {
const slug = randomSlug();
cy.createOIDCIntegration(slug).then(({ organizationSlug }) => {
cy.visit('/logout');

cy.clearAllCookies();
Expand All @@ -120,7 +129,7 @@ describe('oidc', () => {
cy.get('input[id="Input_Password"]').type('password');
cy.get('button[value="login"]').click();

cy.get('[data-cy="organization-picker-current"]').contains('Bubatzbieber');
cy.get('[data-cy="organization-picker-current"]').contains(slug);
});
});

Expand Down
8 changes: 4 additions & 4 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ namespace Cypress {
}): Chainable;
login(data: { email: string; password: string }): Chainable;
dataCy(name: string): Chainable<JQuery<HTMLElement>>;
createOIDCIntegration(organizationName: string): Chainable<{
createOIDCIntegration(organizationSlug: string): Chainable<{
loginUrl: string;
organizationSlug: string;
}>;
}
}

Cypress.Commands.add('createOIDCIntegration', (organizationName: string) => {
cy.get('input[name="name"]').type(organizationName);
Cypress.Commands.add('createOIDCIntegration', (organizationSlug: string) => {
cy.get('input[name="slug"]').type(organizationSlug);
cy.get('button[type="submit"]').click();
cy.get('[data-cy="organization-picker-current"]').contains(organizationName);
cy.get('[data-cy="organization-picker-current"]').contains(organizationSlug);
cy.get('a[href$="/view/settings"]').click();
cy.get('a[href$="/view/settings#create-oidc-integration"]').click();
cy.get('input[id="tokenEndpoint"]').type('http://oidc-server-mock:80/connect/token');
Expand Down
86 changes: 38 additions & 48 deletions integration-tests/testkit/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import type {
TargetSelectorInput,
UpdateBaseSchemaInput,
UpdateMemberRoleInput,
UpdateOrganizationNameInput,
UpdateOrganizationSlugInput,
UpdateProjectNameInput,
UpdateProjectRegistryModelInput,
UpdateTargetNameInput,
UpdateProjectSlugInput,
UpdateTargetSlugInput,
UpdateTargetValidationSettingsInput,
} from './gql/graphql';
import { execute } from './graphql';
Expand All @@ -47,7 +46,6 @@ export function createOrganization(input: CreateOrganizationInput, authToken: st
createdOrganizationPayload {
organization {
id
name
cleanId
owner {
id
Expand All @@ -69,7 +67,7 @@ export function createOrganization(input: CreateOrganizationInput, authToken: st
error {
message
inputErrors {
name
slug
}
}
}
Expand All @@ -90,7 +88,6 @@ export function getOrganization(organizationId: string, authToken: string) {
organization {
id
cleanId
name
getStarted {
creatingProject
publishingSchema
Expand Down Expand Up @@ -135,37 +132,7 @@ export function inviteToOrganization(input: InviteToOrganizationByEmailInput, au
});
}

export function renameOrganization(input: UpdateOrganizationNameInput, authToken: string) {
return execute({
document: graphql(`
mutation updateOrganizationName($input: UpdateOrganizationNameInput!) {
updateOrganizationName(input: $input) {
ok {
updatedOrganizationPayload {
selector {
organization
}
organization {
id
name
cleanId
}
}
}
error {
message
}
}
}
`),
variables: {
input,
},
authToken,
});
}

export function changeOrganizationSlug(input: UpdateOrganizationSlugInput, authToken: string) {
export function updateOrganizationSlug(input: UpdateOrganizationSlugInput, authToken: string) {
return execute({
document: graphql(`
mutation updateOrganizationSlug($input: UpdateOrganizationSlugInput!) {
Expand Down Expand Up @@ -204,7 +171,6 @@ export function joinOrganization(code: string, authToken: string) {
... on OrganizationPayload {
organization {
id
name
cleanId
me {
id
Expand Down Expand Up @@ -263,6 +229,30 @@ export function getOrganizationMembers(selector: OrganizationSelectorInput, auth
});
}

export function getOrganizationProjects(selector: OrganizationSelectorInput, authToken: string) {
return execute({
document: graphql(`
query getOrganizationProjects($selector: OrganizationSelectorInput!) {
organization(selector: $selector) {
organization {
projects {
nodes {
id
cleanId
name
}
}
}
}
}
`),
authToken,
variables: {
selector,
},
});
}

export function getOrganizationTransferRequest(
selector: OrganizationTransferRequestSelector,
authToken: string,
Expand Down Expand Up @@ -342,6 +332,7 @@ export function createProject(input: CreateProjectInput, authToken: string) {
createdProject {
id
cleanId
name
}
createdTargets {
id
Expand All @@ -359,20 +350,20 @@ export function createProject(input: CreateProjectInput, authToken: string) {
});
}

export function renameProject(input: UpdateProjectNameInput, authToken: string) {
export function updateProjectSlug(input: UpdateProjectSlugInput, authToken: string) {
return execute({
document: graphql(`
mutation updateProjectName($input: UpdateProjectNameInput!) {
updateProjectName(input: $input) {
mutation updateProjectSlug($input: UpdateProjectSlugInput!) {
updateProjectSlug(input: $input) {
ok {
selector {
organization
project
}
updatedProject {
project {
id
cleanId
name
cleanId
}
}
error {
Expand All @@ -396,7 +387,6 @@ export function updateRegistryModel(input: UpdateProjectRegistryModelInput, auth
ok {
id
cleanId
name
}
error {
message
Expand Down Expand Up @@ -435,18 +425,18 @@ export function createTarget(input: CreateTargetInput, authToken: string) {
});
}

export function renameTarget(input: UpdateTargetNameInput, authToken: string) {
export function updateTargetSlug(input: UpdateTargetSlugInput, authToken: string) {
return execute({
document: graphql(`
mutation updateTargetName($input: UpdateTargetNameInput!) {
updateTargetName(input: $input) {
mutation updateTargetSlug($input: UpdateTargetSlugInput!) {
updateTargetSlug(input: $input) {
ok {
selector {
organization
project
target
}
updatedTarget {
target {
id
cleanId
name
Expand Down
21 changes: 18 additions & 3 deletions integration-tests/testkit/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
fetchVersions,
getOrganization,
getOrganizationMembers,
getOrganizationProjects,
inviteToOrganization,
joinOrganization,
publishSchema,
Expand Down Expand Up @@ -91,8 +92,8 @@ export function initSeed() {
ownerEmail,
ownerToken,
async createOrg() {
const orgName = generateUnique();
const orgResult = await createOrganization({ name: orgName }, ownerToken).then(r =>
const orgSlug = generateUnique();
const orgResult = await createOrganization({ slug: orgSlug }, ownerToken).then(r =>
r.expectNoGraphQLErrors(),
);

Expand Down Expand Up @@ -177,6 +178,20 @@ export function initSeed() {

return members;
},
async projects() {
const projectsResult = await getOrganizationProjects(
{ organization: organization.cleanId },
ownerToken,
).then(r => r.expectNoGraphQLErrors());

const projects = projectsResult.organization?.organization.projects.nodes;

if (!projects) {
throw new Error(`Could not get projects for org ${organization.cleanId}`);
}

return projects;
},
async createProject(
projectType: ProjectType = ProjectType.Single,
options?: {
Expand All @@ -188,7 +203,7 @@ export function initSeed() {
{
organization: organization.cleanId,
type: projectType,
name: generateUnique(),
slug: generateUnique(),
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
Expand Down
Loading

0 comments on commit 3cb8861

Please sign in to comment.