mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
console: e2e snapshot testing for rs-to-x relationships
This PR has e2e snapshot testing for the rs-to-x relationship. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8407 GitOrigin-RevId: 4e288ba5efca3668db638eac1ce8ba1255c7f8e6
This commit is contained in:
parent
305eebb3ab
commit
abcb2b4489
@ -0,0 +1,24 @@
|
||||
exports[`check if remote schema to db relationships are created properly > verify creating a new rs-to-db relationship #0`] =
|
||||
[
|
||||
{
|
||||
"relationships": [
|
||||
{
|
||||
"definition": {
|
||||
"to_source": {
|
||||
"field_mapping": {
|
||||
"id": "name"
|
||||
},
|
||||
"relationship_type": "array",
|
||||
"source": "default",
|
||||
"table": {
|
||||
"name": "destination_table",
|
||||
"schema": "public"
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "RelationshipName"
|
||||
}
|
||||
],
|
||||
"type_name": "Pokemon"
|
||||
}
|
||||
];
|
@ -1,5 +1,7 @@
|
||||
import { replaceMetadata, resetMetadata } from '../helpers/metadata';
|
||||
import { replaceMetadata } from '../helpers/metadata';
|
||||
import { postgres } from '../../data/manage-database/postgres.spec';
|
||||
import { HasuraMetadataV3 } from '@hasura/console-legacy-ce';
|
||||
import { readMetadata } from '../../actions/withTransform/utils/services/readMetadata';
|
||||
|
||||
describe('check if remote schema to db relationships are created properly', () => {
|
||||
before(() => {
|
||||
@ -53,17 +55,17 @@ describe('check if remote schema to db relationships are created properly', () =
|
||||
|
||||
it('verify creating a new rs-to-db relationship', () => {
|
||||
cy.visit('/remote-schemas/manage/source_rs/relationships');
|
||||
cy.get('[data-test=add-a-new-rs-relationship').click();
|
||||
cy.get('[data-test=radio-select-remoteDB').click();
|
||||
cy.get('[data-test=rs-to-db-rel-name').type('RelationshipName');
|
||||
cy.get('[data-test=select-rel-type').select('array');
|
||||
cy.get('[data-test=select-source-type').select('Pokemon');
|
||||
cy.get('[data-test=select-ref-db').select('default', { force: true });
|
||||
cy.get('[data-test=select-ref-schema').select('public');
|
||||
cy.get('[data-test=select-ref-table').select('destination_table');
|
||||
cy.findByText('Add a new relationship').click();
|
||||
cy.findByText('Remote Database').click();
|
||||
cy.get('[name=relationshipName]').type('RelationshipName');
|
||||
cy.get('[name=relationshipType]').select('array');
|
||||
cy.get('[name=typeName]').select('Pokemon');
|
||||
cy.get('[name=database]').select('default', { force: true });
|
||||
cy.get('[name=schema]').select('public');
|
||||
cy.get('[name=table]').select('destination_table');
|
||||
cy.get('[data-test=select-source-field').select('id');
|
||||
cy.get('[data-test=select-ref-col').select('name');
|
||||
cy.get('[data-test=add-rs-relationship').click();
|
||||
cy.findByRole('button', { name: 'Add Relationship' }).click();
|
||||
|
||||
cy.get('[data-test=remote-schema-relationships-table').should('exist');
|
||||
cy.get('[data-test=remote-schema-relationships-table')
|
||||
@ -73,11 +75,30 @@ describe('check if remote schema to db relationships are created properly', () =
|
||||
'td',
|
||||
'RelationshipName'
|
||||
);
|
||||
});
|
||||
readMetadata().then((md: { body: HasuraMetadataV3 }) => {
|
||||
cy.wrap(
|
||||
md.body?.remote_schemas?.find(rs => rs?.name === 'source_rs')
|
||||
?.remote_relationships
|
||||
).toMatchSnapshot({ name: 'rs-to-db-relationship' });
|
||||
});
|
||||
|
||||
after(() => {
|
||||
// reset the metadata
|
||||
resetMetadata();
|
||||
// delete rs-to-rs relationship
|
||||
cy.visit('/remote-schemas/manage/source_rs/relationships', {
|
||||
timeout: 10000,
|
||||
onBeforeLoad(win) {
|
||||
cy.stub(win, 'prompt').returns('RelationshipName');
|
||||
},
|
||||
});
|
||||
cy.findByRole('button', { name: 'Remove' }).click();
|
||||
|
||||
// delete both remote schemas
|
||||
cy.visit('/remote-schemas/manage/source_rs/modify', {
|
||||
timeout: 10000,
|
||||
onBeforeLoad(win) {
|
||||
cy.stub(win, 'prompt').returns('source_rs');
|
||||
},
|
||||
});
|
||||
cy.findByRole('button', { name: 'Delete' }).click();
|
||||
|
||||
// delete the table
|
||||
postgres.helpers.deleteTable('destination_table');
|
@ -0,0 +1,22 @@
|
||||
exports[`check if remote schema to remote schema relationships are created properly > verify creating a new rs-to-db relationship #0`] =
|
||||
[
|
||||
{
|
||||
"relationships": [
|
||||
{
|
||||
"definition": {
|
||||
"to_remote_schema": {
|
||||
"lhs_fields": [],
|
||||
"remote_field": {
|
||||
"continent": {
|
||||
"arguments": {}
|
||||
}
|
||||
},
|
||||
"remote_schema": "ref_rs"
|
||||
}
|
||||
},
|
||||
"name": "RelationshipName"
|
||||
}
|
||||
],
|
||||
"type_name": "Pokemon"
|
||||
}
|
||||
];
|
@ -0,0 +1,118 @@
|
||||
import { replaceMetadata } from '../helpers/metadata';
|
||||
import { postgres } from '../../data/manage-database/postgres.spec';
|
||||
import { HasuraMetadataV3 } from '@hasura/console-legacy-ce';
|
||||
import { readMetadata } from '../../actions/withTransform/utils/services/readMetadata';
|
||||
|
||||
describe('check if remote schema to remote schema relationships are created properly', () => {
|
||||
before(() => {
|
||||
// create a table called destination_table
|
||||
postgres.helpers.createTable('destination_table');
|
||||
|
||||
// load stuff into the metadata
|
||||
replaceMetadata({
|
||||
version: 3,
|
||||
sources: [
|
||||
{
|
||||
name: 'default',
|
||||
kind: 'postgres',
|
||||
tables: [
|
||||
{
|
||||
table: {
|
||||
schema: 'public',
|
||||
name: 'destination_table',
|
||||
},
|
||||
},
|
||||
],
|
||||
configuration: {
|
||||
connection_info: {
|
||||
use_prepared_statements: true,
|
||||
database_url: {
|
||||
from_env: 'HASURA_GRAPHQL_DATABASE_URL',
|
||||
},
|
||||
isolation_level: 'read-committed',
|
||||
pool_settings: {
|
||||
connection_lifetime: 600,
|
||||
retries: 1,
|
||||
idle_timeout: 180,
|
||||
max_connections: 50,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
remote_schemas: [
|
||||
{
|
||||
name: 'source_rs',
|
||||
definition: {
|
||||
url: 'https://graphql-pokemon2.vercel.app/',
|
||||
timeout_seconds: 60,
|
||||
},
|
||||
comment: '',
|
||||
},
|
||||
{
|
||||
name: 'ref_rs',
|
||||
definition: {
|
||||
url: 'https://countries.trevorblades.com/',
|
||||
timeout_seconds: 60,
|
||||
},
|
||||
comment: '',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('verify creating a new rs-to-db relationship', () => {
|
||||
cy.visit('/remote-schemas/manage/source_rs/relationships');
|
||||
cy.findByText('Add a new relationship').click();
|
||||
cy.findByText('Remote Schema').click();
|
||||
cy.get('[name=name]').type('RelationshipName');
|
||||
cy.get('[name=rsSourceType]').select('Pokemon');
|
||||
cy.get('[name=referenceRemoteSchema]').select('ref_rs');
|
||||
cy.get('.ant-tree-switcher').click();
|
||||
cy.get('.ant-tree-switcher_close').first().click();
|
||||
cy.findByRole('button', { name: 'Add Relationship' }).click();
|
||||
|
||||
cy.get('[data-test=remote-schema-relationships-table').should('exist');
|
||||
cy.get('[data-test=remote-schema-relationships-table')
|
||||
.find('tr')
|
||||
.should('have.length', 2);
|
||||
cy.get('[data-test=remote-schema-relationships-table').contains(
|
||||
'td',
|
||||
'RelationshipName'
|
||||
);
|
||||
readMetadata().then((md: { body: HasuraMetadataV3 }) => {
|
||||
cy.wrap(
|
||||
md.body?.remote_schemas?.find(rs => rs?.name === 'source_rs')
|
||||
?.remote_relationships
|
||||
).toMatchSnapshot({ name: 'rs-to-rs-relationship' });
|
||||
});
|
||||
|
||||
// delete rs-to-rs relationship
|
||||
cy.visit('/remote-schemas/manage/source_rs/relationships', {
|
||||
timeout: 10000,
|
||||
onBeforeLoad(win) {
|
||||
cy.stub(win, 'prompt').returns('RelationshipName');
|
||||
},
|
||||
});
|
||||
cy.findByRole('button', { name: 'Remove' }).click();
|
||||
|
||||
// delete both remote schemas
|
||||
cy.visit('/remote-schemas/manage/source_rs/modify', {
|
||||
timeout: 10000,
|
||||
onBeforeLoad(win) {
|
||||
cy.stub(win, 'prompt').returns('source_rs');
|
||||
},
|
||||
});
|
||||
cy.get('[data-test=remote-schema-edit-delete-btn]').click();
|
||||
cy.visit('/remote-schemas/manage/ref_rs/modify', {
|
||||
timeout: 10000,
|
||||
onBeforeLoad(win) {
|
||||
cy.stub(win, 'prompt').returns('ref_rs');
|
||||
},
|
||||
});
|
||||
cy.findByRole('button', { name: 'Delete' }).click();
|
||||
|
||||
// delete the table
|
||||
postgres.helpers.deleteTable('destination_table');
|
||||
});
|
||||
});
|
@ -52,6 +52,7 @@ export { remoteSchemaReducer } from './lib/components/Services/RemoteSchema';
|
||||
export { modalReducer } from './lib/store/modal/modal.reducer';
|
||||
|
||||
export { metadataReducer } from './lib/metadata/reducer';
|
||||
export { HasuraMetadataV3 } from './lib/metadata/types';
|
||||
export { default as mainReducer } from './lib/components/Main/Actions';
|
||||
export { default as notificationsReducer } from './lib/components/Services/Common/notifications.reducer';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user