Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyakhajanchi committed Dec 2, 2023
1 parent 2691caa commit 9559c72
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 69 deletions.
1 change: 1 addition & 0 deletions ui/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default defineConfig({
setupNodeEvents(on, config) {
// implement node event listeners here
},
supportFile: false
},
});
41 changes: 37 additions & 4 deletions ui/cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
import mockIConv from "../../src/mocks/conv";

describe('template spec', () => {
let url = window.location.origin;
beforeEach(() => {
cy.visit('http://localhost:8080/');
cy.fixture('config.json').as('configData');
// Intercept the backend APIs and return desired response.
cy.intercept('GET', `${url}/IsOffline`, { statusCode: 200, body: false }).as('getIsOffline');
cy.intercept('GET', `${url}/GetSessions`, { statusCode: 200, body: [] }).as('getSessions');
cy.intercept('GET', `${url}/GetConfig`, { statusCode: 200 }).as('getConfig');
cy.intercept('GET', `${url}/GetLatestSessionDetails`, { statusCode: 200 }).as('getLatestSessionDetails');
cy.visit('http://localhost:4200/');
});

it('verify direct connection to mysql non-sharded database', () => {
cy.get('.primary-header').eq(0).should('have.text', 'Get started with Spanner migration tool');
cy.intercept('GET', `${url}/ping`, { statusCode: 200 }).as('checkBackendHealth');
cy.intercept('GET', `${url}/convert/infoschema`, { statusCode: 200, body: mockIConv }).as('directConnection');

cy.get('.primary-header').eq(0).should('have.text', 'Get started with Spanner migration tool');
cy.get('#edit-icon').should('exist').click();

cy.fixture('config').then((json) => {
cy.intercept('POST', `${url}/SetSpannerConfig`, (req) => {
req.reply({
status: 200,
body: {
GCPProjectID: json.projectId,
SpannerInstanceID: json.instanceId,
IsMetadataDbCreated: false,
IsConfigValid: true,
},
});
}).as('setSpannerConfig');
cy.get('#project-id').clear().type(json.projectId)
cy.get('#instance-id').clear().type(json.instanceId)
})
Expand All @@ -27,6 +47,18 @@ describe('template spec', () => {
cy.get('mat-option').contains('MySQL').click();

cy.fixture('mysql-config').then((json) => {
cy.intercept('POST', `${url}/connect`, (req) => {
if (req.body && req.body.Host === json.hostname && req.body.User === json.username && req.body.Driver === 'mysql'
&& req.body.Password === json.password && req.body.Port === json.port && req.body.Database === json.dbName) {
req.reply({
statusCode: 200,
});
} else {
req.reply({
statusCode: 400,
});
}
}).as('testConnection');
cy.get('#hostname-input').clear().type(json.hostname)
cy.get('#username-input').clear().type(json.username)
cy.get('#password-input').clear().type(json.password)
Expand All @@ -44,9 +76,10 @@ describe('template spec', () => {

// Submit the form
cy.get('#test-connect-btn').click();
cy.get('#connect-btn', { timeout: 10000 }).should('be.enabled')
cy.get('#connect-btn').click();

// Check that workspace is rendered with 2 tables in Object Viewer
// Check that workspace is rendered with correct number of tables in Object Viewer
cy.url().should('include', '/workspace');
cy.fixture('mysql-config').then((json) => {
cy.get('#table-and-index-list').find('tbody tr').should('have.length', json.tableCount + 2);
Expand Down
2 changes: 1 addition & 1 deletion ui/cypress/fixtures/mysql-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"password": "root",
"port": "3306",
"dbName": "test_interleave_table_data",
"tableCount": 2
"tableCount": 1
}
37 changes: 0 additions & 37 deletions ui/cypress/support/commands.ts

This file was deleted.

20 changes: 0 additions & 20 deletions ui/cypress/support/e2e.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h3 class="primary-header">Connection Detail</h3>
<br />
<h3 class="primary-header">Spanner Dialect</h3>
<mat-form-field class="full-width" appearance="outline">
<mat-label>Select a spanner dialect</mat-label>
<mat-label>Spanner dialect</mat-label>
<mat-select matSelect name="dialect" formControlName="dialect" appearance="outline" id="spanner-dialect-input">
<mat-option *ngFor="let element of dialect" [value]="element.value">
{{ element.displayName }}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/services/fetch/fetch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import IStructuredReport from 'src/app/model/structured-report'
providedIn: 'root',
})
export class FetchService {
private url: string = 'http://localhost:8080'
private url: string = window.location.origin
constructor(private http: HttpClient) {}

connectTodb(payload: IDbConfig, dialect: string) {
Expand Down
92 changes: 87 additions & 5 deletions ui/src/mocks/conv.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,91 @@
import IConv from "src/app/model/conv";

const mockIConv: IConv = {
SpSchema: {},
SpSchema: {
"t1": {
Name: "table1",
Id: "t1",
ColIds:["c1"],
ColDefs:{
"c1": {
Id: "c1",
Name: "column1",
NotNull: false,
Comment: "",
T: {
Name: "STRING",
Len: 50,
IsArray: false
}
}
},
ShardIdColumn: "",
PrimaryKeys: [],
ForeignKeys: [],
Indexes: [
{
Name: "index1",
Id: "ind1",
Unique: false,
TableId: "t1",
Keys: [
{
ColId: "c1",
Desc: false,
Order: 1
},
]
},
],
ParentId: "",
Comment: ""
}
},
SyntheticPKeys: {},
SrcSchema: {},
SrcSchema: {
"t1": {
Name: "table1",
Id: "t1",
ColIds:["c1"],
ColDefs:{
"c1": {
Id: "c1",
Name: "column1",
NotNull: false,
Type: {
Name: "STRING",
Mods: [],
ArrayBounds: []
},
Ignored: {
Check: false,
Identity: false,
Default: false,
Exclusion: false,
ForeignKey: false,
AutoIncrement: false
}
}
},
PrimaryKeys: [],
ForeignKeys: [],
Indexes: [
{
Name: "index1",
Id: "ind1",
Unique: false,
Keys: [
{
ColId: "c1",
Desc: false,
Order: 1
},
]
},
],
Schema: ""
}
},
SchemaIssues: [],
Rules: [],
ToSpanner: {},
Expand All @@ -19,10 +101,10 @@ const mockIConv: IConv = {
},
UniquePKey: {},
SessionName: 'SampleSession',
DatabaseType: 'SampleDatabaseType',
DatabaseName: 'SampleDatabaseName',
DatabaseName: "testdb",
DatabaseType: 'mysql',
EditorName: 'SampleEditorName',
SpDialect: 'SampleSpDialect',
SpDialect: 'googlestandardsql',
IsSharded: false,
};

Expand Down

0 comments on commit 9559c72

Please sign in to comment.