-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cypress tests for custom schema
- Loading branch information
1 parent
c8299d8
commit 5db9fb7
Showing
5 changed files
with
150 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/// <reference types="cypress" /> | ||
|
||
describe("Substrait Fiddle Custom Schema test", () => { | ||
|
||
it("add custom schema", { browser: 'electron' }, () => { | ||
cy.visit("/") | ||
|
||
cy.get("select").select("sql"); | ||
|
||
cy.get("button").contains("Show/Add Schema").click(); | ||
|
||
cy.get("#addSchema").click(); | ||
|
||
cy.get("#schemaModal") | ||
.focused() | ||
.contains("New Schema") | ||
|
||
cy.get("#schemaTextArea") | ||
.type(` | ||
{ | ||
"table": "test", | ||
"fields": [ | ||
{ | ||
"name": "field_1", | ||
"type": "INTEGER", | ||
"properties": [ | ||
"NOT NULL" | ||
] | ||
} | ||
] | ||
} | ||
`); | ||
|
||
cy.get("button").contains("Validate").click(); | ||
cy.on('window:alert', (str) => { | ||
expect(str).to.equal(`Schema validated!`); | ||
}); | ||
|
||
cy.get("button").contains("Save changes").click(); | ||
|
||
cy.get("#editor") | ||
.click() | ||
.focused() | ||
.type("{ctrl}a") | ||
.clear() | ||
.type("select * from test;"); | ||
|
||
cy.get("button").contains("Generate").click(); | ||
|
||
cy.get("#status").should("contain", "Plan generation successful!"); | ||
|
||
cy.get("svg").should("not.be.empty"); | ||
|
||
}); | ||
|
||
it("schema for lineitem table", { browser: 'electron' }, () => { | ||
cy.visit("/") | ||
|
||
cy.get("select").select("sql"); | ||
|
||
cy.get("button").contains("Show/Add Schema").click(); | ||
|
||
cy.get("#addSchema").click(); | ||
|
||
cy.get("#schemaModal") | ||
.focused() | ||
.contains("New Schema") | ||
|
||
cy.get("#schemaTextArea") | ||
.type(` | ||
{ | ||
"table": "lineitem", | ||
"fields": [ | ||
{ | ||
"name": "field_1", | ||
"type": "INTEGER", | ||
"properties": [ | ||
"NOT NULL" | ||
] | ||
} | ||
] | ||
} | ||
`); | ||
|
||
cy.get("button").contains("Validate").click(); | ||
cy.on('window:alert', (str) => { | ||
expect(str).to.equal(`Invalid schema: Table name cannot be "lineitem"`); | ||
}); | ||
|
||
}); | ||
|
||
it("schema with invalid format", { browser: 'electron' }, () => { | ||
cy.visit("/") | ||
|
||
cy.get("select").select("sql"); | ||
|
||
cy.get("button").contains("Show/Add Schema").click(); | ||
|
||
cy.get("#addSchema").click(); | ||
|
||
cy.get("#schemaModal") | ||
.focused() | ||
.contains("New Schema") | ||
|
||
cy.get("#schemaTextArea") | ||
.type(` | ||
{ | ||
"table": "lineitem", | ||
"field": [ | ||
{ | ||
"name": "field_1", | ||
"type": "INTEGER", | ||
} | ||
] | ||
} | ||
`); | ||
|
||
cy.get("button").contains("Validate").click(); | ||
cy.on('window:alert', (str) => { | ||
expect(str).to.contain(`Invalid JSON: SyntaxError:`); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters