Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/devs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
run: |
cat <<EOF > .env
APP_ENV=TEST
NEXTAUTH_URL=http://localhost:3000
REDIS_DB_ADDRESS=localhost
REDIS_DB_PORT=6379
REDIS_DB_PASSWORD=
Expand Down
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default defineConfig({
},
env: {
APP_ENV: "TEST",
DCUP_PARSER: "http://localhost:9000",
NEXT_PUBLIC_GOOGLE_CLIENT_ID: "xxxxxxxxx",
GOOGLE_CLIENT_SECRET: "xxxxx",
NEXT_PUBLIC_GOOGLE_API_KEY: "xxx",
Expand Down
71 changes: 66 additions & 5 deletions cypress/e2e/connections.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('connect to google drive', () => {
.location('pathname')
.should('eq', '/')
// create new connection
cy.intercept("GET", "https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&prompt=consent&response_type=code&client_id=195646197640-f2guf0p5q1ueb7jpu1tarrcvlr2bvn65.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fconnections%2Fgoogle-drive%2Fcallback", (res) => {
cy.intercept("GET", "https://accounts.google.com/o/oauth2/v2/auth*", (res) => {
res.reply(200, "OK")
}).as("googleAuth")

Expand All @@ -43,7 +43,18 @@ describe('connect to google drive', () => {
cy.task('deleteUser', { email: fakeUser.email })
})

it('should create a new Google Drive connection, show it on the dashboard, and delete it', () => {

it('connect and config with no settings and delete ( 0 file ) , check the database', () => {
cy.task('getConnection', { email: fakeUser.email })
.then(res => {
const { conns } = res as { conns: typeof connections.$inferSelect[] }
cy.visit('/connections')
.get(`[data-test="btn-config-${conns[0].identifier}"]`)
.click()
.get(`[data-test="btn-config-connection"]`)
.click()
}).wait(10000)

cy.task('getConnection', { email: fakeUser.email })
.then(res => {
const { conns } = res as { conns: typeof connections.$inferSelect[] }
Expand All @@ -54,6 +65,12 @@ describe('connect to google drive', () => {
.within(() => {
cy.contains(conns[0].identifier).should('exist');
});

expect(conns[0].service).eq("GOOGLE_DRIVE")
expect(conns[0].metadata).eq("{}")
expect(conns[0].limitPages).to.be.null
expect(conns[0].limitFiles).to.be.null

cy.visit('/connections')
.get(`[data-test="btn-delete-${conns[0].identifier}"]`)
.click()
Expand All @@ -75,17 +92,61 @@ describe('connect to google drive', () => {
.should('not.exist')
});

it("should start processing without configuration", () => {
it("connect and config with settings and delete (0 file), check the database", () => {
cy.task('getConnection', { email: fakeUser.email })
.then(res => {
const { conns } = res as { conns: typeof connections.$inferSelect[] }

cy.visit('/connections')
.get(`[data-test="btn-config-${conns[0].identifier}"]`)
.click()
.get('input[name="connectionName"]')
.clear()
.type("testing_connection")
.get('textarea[name="metadata"]')
.clear()
.type('{"job": "my test files"}', { parseSpecialCharSequences: false })
.get('input[name="documentLimit"]')
.type('2')
.get('input[name="pageLimit"]')
.type('5')
.get(`[data-test="btn-config-connection"]`)
.click()
// todo intercept with msw https://www.googleapis.com/drive/v3/files
}).wait(10000)
cy.task('getConnection', { email: fakeUser.email })
.then(res => {
const { conns } = res as { conns: typeof connections.$inferSelect[] }
cy.visit("/")
.contains(/google drive/i)
.should('exist')
.parent()
.within(() => {
cy.contains(conns[0].identifier).should('exist');
});

expect(conns[0].service).eq("GOOGLE_DRIVE")
expect(conns[0].metadata).eq('{"job": "my test files"}')
expect(conns[0].limitPages).eq(5)
expect(conns[0].limitFiles).eq(2)

cy.visit('/connections')
.get(`[data-test="btn-delete-${conns[0].identifier}"]`)
.click()
.get(`[data-test="delete-connection-btn"]`)
.click()

cy.get('[data-test="delete-connection-btn"]', { timeout: 15000 })
.should('not.exist');
cy.get(`[data-test="btn-delete-${conns[0].identifier}"]`, { timeout: 15000 })
.should('not.exist')
})

cy.task('getConnection', { email: fakeUser.email })
.then(res => {
const { conns } = res as { conns: typeof connections.$inferSelect[] }
expect(conns).to.have.length(0);
})
cy.visit("/")
.contains(/google drive/i)
.should('not.exist')
})
})
Loading